如何从 Linux 中的卷组中删除逻辑和物理卷

从卷组中删除物理卷

验证要删除的物理卷

# vgdisplay -v
    Finding all volume groups
    Finding volume group "VolGroup"
  --- Volume group --
  VG Name               VolGroup
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  25
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               10.81 GiB
  PE Size               4.00 MiB
  Total PE              2767
  Alloc PE/Size       2265/8.85 GiB
  Free  PE/Size       502/1.96 GiB
  VG UUID               uH5AP5-b24E-92h7-nL8b-7Bio-fXe3-pstWIW
  --- Logical volume --
  LV Path                /dev/VolGroup/root
  LV Name                root
  VG Name                VolGroup
  LV UUID                Qn8TnI-TLNm-rl4Y-ORnd-zU3p-2Kj1-ALSLAg
  LV Write Access        read/write
  LV Creation host, time ,
  LV Status              available
  # open                 1
  LV Size                6.85 GiB
  Current LE             1753
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume --
  LV Path                /dev/VolGroup/swap
  LV Name                swap
  VG Name                VolGroup
  LV UUID                M1ucwx-2sjb-o9Q4-a2td-aPvi-FO1C-ggHuPn
  LV Write Access        read/write
  LV Creation host, time ,
  LV Status              available
  # open                 1
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  --- Physical volumes --
  PV Name               /dev/sda2
  PV UUID               uYfzd6-4jh1-YTP7-I3hx-WdSJ-4mTR-HZcdtq
  PV Status             allocatable
  Total PE/Free PE    2509/244
  PV Name               /dev/sdb1
  PV UUID               Am341r-9WLV-NgWo-Un0Y-sVLQ-fyXM-0zyDix
  PV Status             allocatable
  Total PE/Free PE    258/258

如我们所见,我的 VolGroup 包含 /dev/sda2 和 /dev/sdb1 分区。
让我们尝试删除 /dev/sdb1

要首先删除物理卷,我们需要使用以下语法将其从卷组中删除

语法:

# vgreduce name_of_vol_grp  path/of/pv
# vgreduce VolGroup /dev/sdb1
  Removed "/dev/sdb1" from volume group "VolGroup"

从 volgroup 中减少后,我们可以使用以下命令轻松删除 PV

# pvremove /dev/sdb1
  Labels on physical volume "/dev/sdb1" successfully wiped

从卷组中删除逻辑卷

注意:确保要删除的逻辑卷已卸载。

语法:

# lvremove /path/to/lvm

卸载逻辑卷后,从终端运行以下命令

# lvremove /dev/NewGroup/office
Do you really want to remove active logical volume office? [y/n]: y
  Logical volume "office" successfully removed

检查变更(可以看到“office”逻辑卷已成功删除)

[root@test2 ~]# lvdisplay
  --- Logical volume --
  LV Path                /dev/NewGroup/root
  LV Name                root
  VG Name                NewGroup
  LV UUID                52mm9d-feyC-AWVH-NTMC-VwNa-Ns1p-cJc8vJ
  LV Write Access        read/write
  LV Creation host, time test2.example, 2014-03-14 02:37:58 +0530
  LV Status              available
  # open                 1
  LV Size                9.92 GiB
  Current LE             2539
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume --
  LV Path                /dev/NewGroup/swap
  LV Name                swap
  VG Name                NewGroup
  LV UUID                48hszS-I0uT-Zsxr-jnoY-yEbj-hfBJ-isofU7
  LV Write Access        read/write
  LV Creation host, time test2.example, 2014-03-14 02:38:00 +0530
  LV Status              available
  # open                 1
  LV Size                1.95 GiB
  Current LE             500
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
日期:2020-06-02 22:18:32 来源:oir作者:oir