• 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*

     注:

    • 逻辑卷部署顺序:物理劵→卷组→逻辑卷
    • 逻辑卷删除顺序:逻辑卷→卷组→物理劵
  • 相关阅读:
    feq ifneq ifdef ifndef
    clock gating | ODC-based Clock Gating
    clock gating | clock gating的timing check
    更换ICC2图形界面主题
    git 学习心得
    CSS颜色混合模式
    常用meta整理
    75份开发者、设计师必备的速查表
    jquery 编程的最佳实践
    JQuery总结一:选择器归纳
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/13945634.html
Copyright © 2020-2023  润新知