关闭虚拟机
设置虚拟机
存储 -> 控制器:SATA -> 添加虚拟硬盘
创建新的虚拟盘 -> 选择VDI -> 选择动态分配 -> 命名、设置极限大小
启动虚拟机
分区
执行[fdisk –l]命令查看磁盘信息
# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x0000e692
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1045 7875584 8e Linux LVM
/dev/sda3 1045 1305 2093804+ 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x9eec6ec5
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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
Disk /dev/mapper/vg_hicamp-lv_root: 9344 MB, 9344909312 bytes
255 heads, 63 sectors/track, 1136 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
Disk /dev/mapper/vg_hicamp-lv_swap: 855 MB, 855638016 bytes
255 heads, 63 sectors/track, 104 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
执行[fdisk /dev/sdc]命令来添加分区
根据提示内容,依次输入:n p 1 回车 回车 w
# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building 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): m
Command 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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The 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 bytes
255 heads, 63 sectors/track, 2610 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: 0x283ab7e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux
Disk /dev/mapper/vg_hicamp-lv_root: 9344 MB, 9344909312 bytes
255 heads, 63 sectors/track, 1136 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
...
格式化
执行[mkfs -t ext4 /dev/sdc1]进行格式化
# mkfs -t ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
160 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
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
挂载
执行[df -h]查看目前挂载状况
# df -h
Filesystem 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 -h
Filesystem 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
...