📅  最后修改于: 2023-12-03 14:50:18.198000             🧑  作者: Mango
在 CentOS 6 中,删除一个主分区可以使用以下几个步骤:
使用命令 fdisk -l
查看磁盘分区信息:
$ sudo fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00006026
Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 256000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 2611 20740096 8e Linux LVM
首先,确保要删除的主分区没有被挂载。否则,需要先使用 umount
命令卸载分区。
$ sudo umount /dev/sda1
使用 fdisk
命令删除主分区。首先,输入 fdisk /dev/sda
进入磁盘分区编辑工具。
$ sudo fdisk /dev/sda
此时,fdisk
命令会显示磁盘分区的详细信息。输入 p
命令,fdisk
命令将会打印分区信息。
Command (m for help): p
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00006026
Device Boot Start End Blocks Id System
/dev/sda1 * 1 32 256000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 32 2611 20740096 8e Linux LVM
Command (m for help):
输入 d
命令,并选择要删除的分区号,然后按下回车键。
Command (m for help): d
Partition number (1-4): 1
Command (m for help):
现在,主分区已经被删除了。使用 p
命令再次查看分区信息,可以发现主分区已经不存在了。
Command (m for help): p
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00006026
Device Boot Start End Blocks Id System
/dev/sda2 32 2611 20740096 8e Linux LVM
Command (m for help):
fdisk
工具最后,输入 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.
现在,主分区已经被成功删除了。
以上就是在 CentOS 6 中删除主分区的步骤。