卸载文件系统
确保我们已使用要删除的分区卸载文件系统。
要查看分区是否已安装,请使用以下命令。
# cat /proc/mounts
要卸载挂载点,请使用以下命令。
# umount /data
本文说明了使用 fdisk 命令删除磁盘分区的步骤。
请注意删除主分区和扩展分区的过程是相同的。
在本文的示例中,我们使用磁盘 /dev/sdc,要删除的分区是 /dev/sdc1.
列出要删除的分区
要获取当前分区方案的列表,请使用“fdisk -/dev/sdc”。
使用打印命令 (p) 列出分区表:
# fdisk /dev/sdc 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. Command (m for help): p Disk /dev/sdc: 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: 0x085579f4 Device Boot Start End Blocks Id System /dev/sdc1 2048 2099199 1048576 83 Linux /dev/sdc2 2099200 4196351 1048576 83 Linux
我们还可以使用命令“fdisk -l”来查看系统上所有可用的分区。
on It Road.com
删除分区
使用删除命令 (d) 删除分区,它会提示我们输入分区号。
在本例中,我们将删除 /dev/sdc1.
所以在提示要删除的分区号时使用数字 1.
Command (m for help): d Partition number (1,2, default 2): 1 Partition 1 is deleted
如果还有最后一个分区需要删除,使用deleted命令不会提示要删除的分区号,直接删除最后一个分区。
保存分区表并验证
使用打印命令 (p) 再次列出分区表并确认分区 1 是否已删除:
Command (m for help): p Disk /dev/sdc: 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: 0x085579f4 Device Boot Start End Blocks Id System /dev/sdc2 2099200 4196351 1048576 83 Linux
最后使用 write/quit 命令 (w) 保存并退出 fdisk。
执行此命令后,更改将是永久性的。
Command (m for help): 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.
日期:2020-09-17 00:13:29 来源:oir作者:oir