VirtualBox中为Linux添加磁盘

来源:互联网 发布:工程宝软件怎么样 编辑:程序博客网 时间:2024/06/04 19:38

关闭虚拟机

设置虚拟机

存储 -> 控制器:SATA -> 添加虚拟硬盘

这里写图片描述

创建新的虚拟盘 -> 选择VDI -> 选择动态分配 -> 命名、设置极限大小

启动虚拟机

分区

执行[fdisk –l]命令查看磁盘信息

# fdisk -lDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0000e692   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1          64      512000   83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              64        1045     7875584   8e  Linux LVM/dev/sda3            1045        1305     2093804+  8e  Linux LVMDisk /dev/sdb: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x9eec6ec5   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1305    10482381   83  LinuxDisk /dev/sdc: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/vg_hicamp-lv_root: 9344 MB, 9344909312 bytes255 heads, 63 sectors/track, 1136 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/vg_hicamp-lv_swap: 855 MB, 855638016 bytes255 heads, 63 sectors/track, 104 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000

执行[fdisk /dev/sdc]命令来添加分区
根据提示内容,依次输入:n p 1 回车 回车 w

# fdisk /dev/sdcDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x283ab7e6.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): mCommand action   a   toggle a bootable flag   b   edit bsd disklabel   c   toggle the dos compatibility flag   d   delete a partition   l   list known partition types   m   print this menu   n   add a new partition   o   create a new empty DOS partition table   p   print the partition table   q   quit without saving changes   s   create a new empty Sun disklabel   t   change a partition's system id   u   change display/entry units   v   verify the partition table   w   write table to disk and exit   x   extra functionality (experts only)Command (m for help): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2610, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):Using default value 2610Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.

再次执行[fdisk -l]命令,查看分区状况

# fdisk -l...Disk /dev/sdc: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x283ab7e6   Device Boot      Start         End      Blocks   Id  System/dev/sdc1               1        2610    20964793+  83  LinuxDisk /dev/mapper/vg_hicamp-lv_root: 9344 MB, 9344909312 bytes255 heads, 63 sectors/track, 1136 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000...

格式化

执行[mkfs -t ext4 /dev/sdc1]进行格式化

# mkfs -t ext4 /dev/sdc1mke2fs 1.41.12 (17-May-2010)文件系统标签=操作系统:Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks1310720 inodes, 5241198 blocks262059 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=4294967296160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,        4096000正在写入inode表: 完成Creating journal (32768 blocks): 完成Writing superblocks and filesystem accounting information: 完成This filesystem will be automatically checked every 25 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.

挂载

执行[df -h]查看目前挂载状况

# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/vg_hicamp-lv_root                      8.5G  4.1G  4.0G  51% /tmpfs                 499M     0  499M   0% /dev/shm/dev/sda1             477M   28M  425M   7% /boot/dev/sdb1             9.8G  9.2G  100M  99% /data01

创建/data02目录,并将/dev/sdc1挂载到此目录

# mkdir /data02# mount /dev/sdc1 /data02

再次执行[df -h]命令,查看挂载情况

# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/vg_hicamp-lv_root                      8.5G  4.1G  4.0G  51% /tmpfs                 499M     0  499M   0% /dev/shm/dev/sda1             477M   28M  425M   7% /boot/dev/sdb1             9.8G  9.2G  100M  99% /data01/dev/sdc1              20G   44M   19G   1% /data02

添加开机自动挂载

修改/etc/fstab文件,添加配置

# vi /etc/fstab.../dev/sdc1               /data02                 ext4    defaults        0 0...
0 0
原创粉丝点击