Linux使用fdisk删除分区详解
2018-09-02 本文已影响64人
moxiaoxiao
在磁盘/dev/sdb 上有一个分区sdb1,现需要删除sdb1分区
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 420.8M 0 rom
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 9.5G 0 part
├─VolGroup-lv_swap (dm-0) 253:0 0 996M 0 lvm [SWAP]
└─VolGroup-lv_root (dm-1) 253:1 0 8.5G 0 lvm /
sdb 8:16 0 1G 0 disk
└─sdb1 8:17 0 509.9M 0 part
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
[root@localhost ~]#
使用fdisk /dev/sdb 进行操作
[root@localhost ~]# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): d #输入d 来进行删除
Selected partition 1
Command (m for help):
Command (m for help):
Command (m for help): w #最好按w进行保存刚才的操作
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
现在使用lsblk查看,发现sdb1分区已经删除
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 420.8M 0 rom
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 9.5G 0 part
├─VolGroup-lv_swap (dm-0) 253:0 0 996M 0 lvm [SWAP]
└─VolGroup-lv_root (dm-1) 253:1 0 8.5G 0 lvm /
sdb 8:16 0 1G 0 disk
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
[root@localhost ~]#