linux系統中完整刪除邏輯卷、卷組、物理劵


 

  • 刪除邏輯卷前備份數據
  • 邏輯卷刪除順序為邏輯卷、卷組、物理劵,不可顛倒

1、查看系統中當前的邏輯卷

[root@PC1linuxprobe /]# lvscan ACTIVE '/dev/rhel/swap' [2.00 GiB] inherit ACTIVE '/dev/rhel/root' [17.51 GiB] inherit ACTIVE '/dev/vg1/lv1' [100.00 MiB] inherit ACTIVE '/dev/vg1/lv2' [300.00 MiB] inherit

 

2、查看邏輯卷掛載情況

[root@PC1linuxprobe /]# 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 140K 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/vg1-lv2 283M 2.1M 262M 1% /lvmounttest

 

3、卸載邏輯卷

[root@PC1linuxprobe /]# umount /lvmounttest

 

4、刪除邏輯卷

[root@PC1linuxprobe /]# lvscan ACTIVE '/dev/rhel/swap' [2.00 GiB] inherit ACTIVE '/dev/rhel/root' [17.51 GiB] inherit  ACTIVE '/dev/vg1/lv1' [100.00 MiB] inherit ACTIVE '/dev/vg1/lv2' [300.00 MiB] inherit [root@PC1linuxprobe /]# lvremove /dev/vg1/lv1 Do you really want to remove active logical volume lv1? [y/n]: y Logical volume "lv1" successfully removed [root@PC1linuxprobe /]# lvremove /dev/vg1/lv2 Do you really want to remove active logical volume lv2? [y/n]: y Logical volume "lv2" successfully removed [root@PC1linuxprobe /]# lvscan ACTIVE '/dev/rhel/swap' [2.00 GiB] inherit ACTIVE '/dev/rhel/root' [17.51 GiB] inherit

 

5、刪除卷組

[root@PC1linuxprobe /]# vgscan Reading all physical volumes. This may take a while... Found volume group "rhel" using metadata type lvm2  Found volume group "vg1" using metadata type lvm2 [root@PC1linuxprobe /]# vgremove vg1 Volume group "vg1" successfully removed [root@PC1linuxprobe /]# vgscan Reading all physical volumes. This may take a while... Found volume group "rhel" using metadata type lvm2

 

6、刪除物理劵

[root@PC1linuxprobe /]# pvscan PV /dev/sda2   VG rhel            lvm2 [19.51 GiB / 0 free]  PV /dev/sdb lvm2 [20.00 GiB] PV /dev/sdc lvm2 [20.00 GiB] PV /dev/sdd lvm2 [20.00 GiB] Total: 4 [79.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 3 [60.00 GiB] [root@PC1linuxprobe /]# pvremove /dev/sdb /dev/sdc /dev/sdd Labels on physical volume "/dev/sdb" successfully wiped Labels on physical volume "/dev/sdc" successfully wiped Labels on physical volume "/dev/sdd" successfully wiped [root@PC1linuxprobe /]# pvscan PV /dev/sda2   VG rhel   lvm2 [19.51 GiB / 0 free] Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0   ]

 

總結,完整刪除邏輯卷步驟:

  • 卸載,示例:umount /mountpoint
  • 刪除邏輯卷,示例:lvremove /dev/vgname/lvname
  • 刪除卷組,示例:vgremove vgname
  • 刪除物理劵,示例:pvremove /dev/disk*

 注:

  • 邏輯卷部署順序:物理劵→卷組→邏輯卷
  • 邏輯卷刪除順序:邏輯卷→卷組→物理劵


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM