Linux 卸载及删除磁盘分区

1.卸载分区

[root@centos7 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        17G  4.0G   14G  24% /
devtmpfs                devtmpfs  974M     0  974M   0% /dev
tmpfs                   tmpfs     991M     0  991M   0% /dev/shm
tmpfs                   tmpfs     991M   11M  981M   2% /run
tmpfs                   tmpfs     991M     0  991M   0% /sys/fs/cgroup
/dev/sdb1               xfs       8.0G   33M  8.0G   1% /mnt/sdb1
/dev/sdb2               xfs        12G   33M   12G   1% /mnt/sdb2
/dev/sda1               xfs      1014M  166M  849M  17% /boot
tmpfs                   tmpfs     199M  8.0K  199M   1% /run/user/42
tmpfs                   tmpfs     199M     0  199M   0% /run/user/0
[root@centos7 ~]# umount /dev/sdb1
[root@centos7 ~]# umount /dev/sdb2

将fstab文件最后两行关于/dev/sdb1和/dev/sdb2的内容删除

[root@centos7 ~]# vi /etc/fstab
[root@centos7 ~]# cat /etc/fstab

2.删除分区

[root@centos7 ~]# fdisk /dev/sdb
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): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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
Partition number (1,2, default 2):
Partition 2 is deleted

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): p

Disk /dev/sdb: 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: 0x302fa02d

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

————————————————
版权声明:本文为CSDN博主「z气泡」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41904732/article/details/99579528

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值