[root@soulchild ~]# fdisk /dev/sdaWelcome 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.
Command (m forhelp): p # 查看当前分区信息Disk /dev/sda: 107.4 GB, 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
Disk label type: dos
Disk identifier: 0x000d0785
Device Boot Start End Blocks Id System
/dev/sda1 20484196351209715282 Linux swap / Solaris
/dev/sda2 41963521258291196081638483 Linux
Command (m forhelp): d # 删除2号分区, 删除后切记不要保存Partition number (1,2, default 2):
Partition 2 is deleted
Command (m forhelp): n # 创建新分区Partition type:
p primary (1 primary, 0 extended, 3 free) e extended
Select (default p): # 默认 p 即可, 直接回车Using default response p
Partition number (2-4, default 2): # 分区号 2, 直接回车First sector (4196352-209715199, default 4196352): # 起始扇区, 和之前删掉的分区保持一致, 直接回车Using default value 4196352Last sector, +sectors or +size{K,M,G}(4196352-209715199, default 209715199): # 结束扇区 这里根据自己需求选择, 默认是能用的最大值Using default value 209715199Command (m forhelp): w # 保存后退出The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.