注意:以下操作均在root用户操作。
使用df -h命令查看当前系统中已挂载的磁盘,使用fdisk -l命令查看虚机的所有磁盘:
# df -h
# fdisk -l
对于新增的硬盘/dev/xvdc,使用fdisk /dev/xvdc进入分区视图,根据里面的信息完成相关操作。
# fdisk /dev/xvdc
注意,分区完成后要按w,将分区信息写入分区表,才算分区完成,
再次使用fdisk -l就会发现新创建的分区信息了。
root@ubuntu-sz:~# fdisk -l
Disk /dev/xvde: 1131.7 GB, 1131723882496 bytes
255 heads, 63 sectors/track, 137590 cylinders, total 2210398208 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/xvde doesn't contain a valid partition table
Disk /dev/xvdc: 2040.1 GB, 2040109465600 bytes
47 heads, 17 sectors/track, 4986969 cylinders, total 3984588800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x39510b8b
Device Boot Start End Blocks Id System
/dev/xvdc1 2048 3984588799 1992293376 83 Linux
Disk /dev/xvda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000db93c
Device Boot Start End Blocks Id System
/dev/xvda1 2048 192432127 96215040 83 Linux
/dev/xvda2 192434174 209713151 8639489 5 Extended
/dev/xvda5 192434176 209713151 8639488 82 Linux swap / Solaris
Disk /dev/xvdb: 2040.1 GB, 2040109465600 bytes
47 heads, 17 sectors/track, 4986969 cylinders, total 3984588800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc16ca43a
Device Boot Start End Blocks Id System
/dev/xvdb1 2048 3984588799 1992293376 83 Linux
完成分区之后使用mkfs.ext4 /dev/xvdc1,创建文件系统,并使用mount /dev/xvdc1 /data挂载到目录即可使用新的分区工作。
最后,可以把新增的硬盘信息写入自动挂载表/etc/fstab中
# vim /etc/fstab
使用mount -a分区表生效
# mount -a