Welcome to fdisk (util-linux 2.34). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m forhelp): p # 查看当前硬盘分区结构 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 209715199 209713152 100G 83 Linux
Command (m forhelp): d # 删除分区,因为原来只有一个分区,所以默认删除了第一个分区 Selected partition 1 Partition 1 has been deleted.
Command (m forhelp): p # 再次查看分区结构,显示已经没有分区 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Command (m forhelp): n # (new)新建分区,提示要选择分区类型,主分区或者逻辑分区。 Partition type# 逻辑分区也是一种主分区,占用一个主分区名额。 p primary (0 primary, 0 extended, 4 free) # 主分区一共只能有4个。 e extended (container for logical partitions) Select (default p): p # 选择新建一个主分区 Partition number (1-4, default 1): # 直接<回车>使用默认给的1号分区号 First sector (2048-209715199, default 2048): # 直接回车使用起始扇区 Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-209715199, default 209715199): +16G # 输入“+16G”表示分配16G的空间
Created a new partition 1 of type'Linux' and of size 16 GiB. Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: Y # 移除原有分区标志
The signature will be removed by a write command.
Command (m forhelp): t # 输入t表示修改分区类型 Selected partition 1 # 因为当前只有一个分区,所以fdisk默认选择了这个 Hex code (type L to list all codes): 82 # 输入82,表示swap分区的id类型 Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m forhelp): p # 查看当前分区表 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 33556479 33554432 16G 82 Linux swap / Solaris
Filesystem/RAID signature on partition 1 will be wiped.
Command (m forhelp): n # 新建分区 Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): e # 新建拓展分区 Partition number (2-4, default 2): # 直接回车使用默认起始扇区 First sector (33556480-209715199, default 33556480): # 直接回车使用默认结束扇区 Last sector, +/-sectors or +/-size{K,M,G,T,P} (33556480-209715199, default 209715199):
Created a new partition 2 of type'Extended' and of size 84 GiB.
Command (m forhelp): p # 查看当前分区表 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 33556479 33554432 16G 82 Linux swap / Solaris /dev/vdb2 33556480 209715199 176158720 84G 5 Extended
Filesystem/RAID signature on partition 1 will be wiped.
Command (m forhelp): n # 新建分区 All space for primary partitions is in use. # fdisk提示目前所有空间都被主分区使用了 Adding logical partition 5 # 所以在拓展分区中添加逻辑分区 First sector (33558528-209715199, default 33558528): # 直接回车使用默认起始扇区 Last sector, +/-sectors or +/-size{K,M,G,T,P} (33558528-209715199, default 209715199): +20G # 输入“+20G”表示限制当前分区大小20G
Created a new partition 5 of type'Linux' and of size 20 GiB.
Command (m forhelp): p # 查看当前分区表 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 33556479 33554432 16G 82 Linux swap / Solaris /dev/vdb2 33556480 209715199 176158720 84G 5 Extended /dev/vdb5 33558528 75501567 41943040 20G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m forhelp): n # 新建分区 All space for primary partitions is in use. # fdisk提示目前所有空间都被主分区使用了 Adding logical partition 6 # 所以在拓展分区中添加逻辑分区 First sector (75503616-209715199, default 75503616): # 直接回车使用默认起始扇区 Last sector, +/-sectors or +/-size{K,M,G,T,P} (75503616-209715199, default 209715199): # 直接回车使用默认结束扇区,使用所有剩余空间新建分区
Created a new partition 6 of type'Linux' and of size 64 GiB.
Command (m forhelp): p # 查看当前分区表 Disk /dev/vdb: 100 GiB, 107374182400 bytes, 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 Disklabel type: dos Disk identifier: 0x2681d385
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 33556479 33554432 16G 82 Linux swap / Solaris /dev/vdb2 33556480 209715199 176158720 84G 5 Extended /dev/vdb5 33558528 75501567 41943040 20G 83 Linux /dev/vdb6 75503616 209715199 134211584 64G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m forhelp): w # (write)写入改动,使得分区表生效 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/vda1 during installation ...