运行fdisk -u /dev/vdb命令:分区数据盘。 输入p:查看数据盘的分区情况。本示例中,数据盘没有分区。 输入n:创建一个新分区。 输入p:选择分区类型为主分区。 说明 本示例中创建一个单分区数据盘,所以只需要创建主分区。如果要创建四个以上分区,您应该创建至少一个扩展分区,即选择e(extended)。 输入分区编号并按回车键。本示例中,仅创建一个分区,输入1。 输入第一个可用的扇区编号:按回车键采用默认值2048。 输入最后一个扇区编号。本示例中,仅创建一个分区,按回车键采用默认值。 输入p:查看该数据盘的规划分区情况。 输入w:开始分区,并在完成分区后退出。 [root@ecshost~ ]# fdisk -u /dev/vdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x3e60020e.
Command (m for help): p Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x3e60020e Device Boot Start End Blocks Id System
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): p
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x3e60020e Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
运行fdisk -lu /dev/vdb命令查看新分区。
如果出现以下信息,表示新分区已创建完成。
1 2 3 4 5 6 7 8 9 10 11
[root@ecshost~ ]# fdisk -lu /dev/vdb
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x3e60020e
Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux
[root@ecshost~ ]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Wed Dec 12 07:53:08 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=d67c3b17-255b-4687-be04-f29190d37396 / ext4 defaults 1 1 /dev/vdb1 /www ext4 defaults 0 0