卸载分区并还原硬盘
一 卸载分区
1 临时卸载/dev/sdb1 umount /dev/sdb1
[root@linuxprobe ~]# umount /dev/sdb1
2 删除开机挂载信息 vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jun 8 06:02:20 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2c1949d3-5cd8-4b71-b60d-8885bfc326e0 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/sdb1 /root/new_disk/sdb/sdb1 xfs defaults 0 0
~
删除/dev/sdb1行,效果如下
#
# /etc/fstab
# Created by anaconda on Tue Jun 8 06:02:20 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2c1949d3-5cd8-4b71-b60d-8885bfc326e0 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
~
3 验证是否卸载成功
重启系统 reboot
[root@linuxprobe ~]# reboot
查看挂载情况 df -hT
[root@linuxprobe ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 9.9M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/rhel-root xfs 44G 4.1G 40G 10% /
/dev/sda1 xfs 1014M 152M 863M 15% /boot
tmpfs tmpfs 796M 16K 796M 1% /run/user/42
tmpfs tmpfs 796M 3.5M 792M 1% /run/user/0
发现确实已经没有/dev/sbd1,说明卸载成功。
二 还原硬盘
1 删除分区 fdisk /dev/sdb
[root@linuxprobe ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d //输入d按回车删除分区,如果有多个分区会让用户选择分区序号,这里只有单个分区会直接删除
Selected partition 1
Partition 1 has been deleted.
Command (m for help): w //保存修改并退出
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
2 查看硬盘情况 fdisk -l
[root@linuxprobe ~]# fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0xd3084162
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 104857599 102758400 49G 8e Linux LVM
Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 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
Disklabel type: dos
Disk identifier: 0x2a5160b4
Disk /dev/sdc: 1 GiB, 1073741824 bytes, 2097152 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
Disklabel type: dos
Disk identifier: 0x3af1d685
Disk /dev/mapper/rhel-root: 44 GiB, 47240445952 bytes, 92266496 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 /dev/mapper/rhel-swap: 5 GiB, 5368709120 bytes, 10485760 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
发现/dev/sdb下已经没有分区了,还原成功!