在生產環境中想要重新部署LVM或者不再需要使用LVM時,則需要執行LVM的刪除操作。為此,需要提前備份好重要的數據,
然后依次刪除邏輯卷、卷組、物理劵設備,順序不可顛倒。
1、查看物理劵、卷組、邏輯卷
[root@linuxprobe dev]# pvdisplay | head -n 3
--- Physical volume --- PV Name /dev/sdb VG Name vgtest1 [root@linuxprobe dev]# vgdisplay | head -n 3
--- Volume group --- VG Name vgtest1 System ID [root@linuxprobe dev]# lvdisplay | head -n 3
--- Logical volume --- LV Path /dev/vgtest1/lvtest1 LV Name lvtest1
2、卸載邏輯卷的掛載
[root@linuxprobe dev]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 2.9G 15G 17% / devtmpfs 985M 0 985M 0% /dev tmpfs 994M 80K 994M 1% /dev/shm tmpfs 994M 8.8M 986M 1% /run tmpfs 994M 0 994M 0% /sys/fs/cgroup /dev/sda1 497M 119M 379M 24% /boot /dev/sr0 3.5G 3.5G 0 100% /run/media/root/RHEL-7.0 Server.x86_64 /dev/mapper/vgtest1-lvtest1 93M 1.6M 85M 2% /linuxprobe [root@linuxprobe dev]# umount /linuxprobe/ ## 卸載 [root@linuxprobe dev]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 2.9G 15G 17% / devtmpfs 985M 0 985M 0% /dev tmpfs 994M 80K 994M 1% /dev/shm tmpfs 994M 8.8M 986M 1% /run tmpfs 994M 0 994M 0% /sys/fs/cgroup /dev/sda1 497M 119M 379M 24% /boot /dev/sr0 3.5G 3.5G 0 100% /run/media/root/RHEL-7.0 Server.x86_64
3、刪除邏輯卷
[root@linuxprobe dev]# lvremove /dev/vgtest1/lvtest1 Do you really want to remove active logical volume lvtest1? [y/n]: y Logical volume "lvtest1" successfully removed
4、刪除卷組(不需要絕對路徑)
[root@linuxprobe dev]# vgremove vgtest1 Volume group "vgtest1" successfully removed
5、刪除物理劵
[root@linuxprobe dev]# pvremove /dev/sdb /dev/sdc Labels on physical volume "/dev/sdb" successfully wiped Labels on physical volume "/dev/sdc" successfully wiped
6、查看物理劵、卷組、邏輯卷
[root@linuxprobe dev]# pvdisplay | head -n 3 ## 默認的???
--- Physical volume --- PV Name /dev/sda2 VG Name rhel [root@linuxprobe dev]# vgdisplay | head -n 3
--- Volume group --- VG Name rhel System ID [root@linuxprobe dev]# lvdisplay | head -n 3
--- Logical volume --- LV Path /dev/rhel/swap LV Name swap