在生产环境中想要重新部署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