zoukankan      html  css  js  c++  java
  • [Linux]vbox 虚拟机加入新磁盘

    情况是这种,開始创建虚拟机的时候硬盘设置太小了。仅仅有10g,我如今通过vbox的设置给这个linux(centos6.6)虚拟机加入了一块硬盘。


    以下的操作就是怎么把硬盘挂载到系统中。

    通过 fdisk查看如今物理磁盘的信息(这个要用root权限才行)

    以下操作均是root权限。

    [root@orangleliu ~]# fdisk -l
    ...
    
    Disk /dev/sdb: 32.2 GB, 32212254720 bytes
    255 heads, 63 sectors/track, 3916 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
    ...

    写分区表

    以下是个交互是过程,每次输入之后依据提示。在进行输入

    [root@orangleliu ~]# fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0xa4378777.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-3916, default 1):
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916):
    Using default value 3916
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.

    操作完之后我们再来看磁盘信息

    # fdisk -l
    ...
    
    Disk /dev/sdb: 32.2 GB, 32212254720 bytes
    255 heads, 63 sectors/track, 3916 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xa4378777
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        3916    31455238+  83  Linux
    
    ...

    多了一块分区信息

    格式化分区

    一个命令就能够搞定了

    # mkfs.ext4 /dev/sdb1
    mke2fs 1.41.12 (17-May-2010)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    1966080 inodes, 7863809 blocks
    393190 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=4294967296
    240 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
    ​
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 26 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.

    创建新卷标(可忽略)

    这一步,我看到有些人做了,有些人没有做,于是查了下资料。
    能够看下參考 e2label命令
    后面没用上,能够不操作的。

    # e2label /dev/sdb1 /data

    检查一下

    # e2label /dev/sdb1
    /data

    挂载

    创建挂载文件夹,跟上一步一致

    mkdir /data

    为了开机自己主动挂载。还须要编辑 /etc/fstab 文件,文件后面加入一行

    /dev/sdb1       /data                   ext4    defaults        0 0

    有些可能对这个配置文件不太熟悉,请參见[fatab中文解释](https://wiki.archlinux.org/index.php/Fstab_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

    測试

    # mount -a
    # df -lh
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_orangleliu-lv_root
                          6.5G  3.2G  3.0G  52% /
    tmpfs                 499M     0  499M   0% /dev/shm
    /dev/sda1             477M   29M  424M   7% /boot
    /dev/sdb1              30G   44M   28G   1% /data

    然后重新启动下。再次查看挂载情况,正常挂载。成功。

  • 相关阅读:
    软件工程第一次作业
    7.9-7.22日团队进展及博客更新状况
    2018 软件工程暑期培训小结
    结对编程(第7组)
    6.3日前团队项目打分情况
    第六周实践作业:软件测试和评估
    第4周小组作业:WordCount优化
    第2周个人作业:WordCount
    博客阅读和思考
    个人总结
  • 原文地址:https://www.cnblogs.com/clnchanpin/p/7297593.html
Copyright © 2011-2022 走看看