LINUX运维--麒麟操作系统基于PV丢失情况下删除PV

1.发现问题

1.1 查看磁盘信息

[root@hx ~]# pvs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  PV         VG     Fmt  Attr PSize    PFree
  /dev/vdb1  vgdata lvm2 a--  <200.00g    0
  [unknown]  vgdata lvm2 a-m   <10.00g    0
[root@hx ~]# vgs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  VG     #PV #LV #SN Attr   VSize   VFree
  vgdata   2   1   0 wz-pn- 209.99g    0
[root@hx ~]# lvs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  LV     VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvdata vgdata -wi-----p- 209.99g
[root@hx ~]# pvdisplay
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  --- Physical volume ---
  PV Name               [unknown]
  VG Name               vgdata
  PV Size               10.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              2559
  Free PE               2559
  Allocated PE          0
  PV UUID               aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT

  --- Physical volume ---
  PV Name               /dev/vdb1
  VG Name               vgdata
  PV Size               <200.00 GiB / not usable 3.03 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              51199
  Free PE               51199
  Allocated PE          0
  PV UUID               5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2

 可以看到aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT对应的PV Name已丢失。

1.2 删除LV

[root@hx ~]# lvremove /dev/vgdata/lvdata
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  Logical volume "lvdata" successfully removed
[root@hx ~]# lvs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.

1.3 删除VG 

[root@hx ~]# vgremove /dev/vgdata
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  Volume group "vgdata" not found, is inconsistent or has PVs missing.
  Consider vgreduce --removemissing if metadata is inconsistent.
[root@hx ~]# vgs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  VG     #PV #LV #SN Attr   VSize   VFree
  vgdata   2   0   0 wz-pn- 209.99g 209.99g

 由于aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT对应的PV丢失导致vg无法删除

2.问题处理

2.1 创建新的分区

由于vdb已经将所有空间都分配给了第一个分区,因此目前的情况无法创建新的分区

[root@hx ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1  378K  0 rom
vda    253:0    0  100G  0 disk
├─vda1 253:1    0  200M  0 part /boot/efi
└─vda2 253:2    0 99.8G  0 part /
vdb    253:16   0  200G  0 disk
└─vdb1 253:17   0  200G  0 part

此时删除vdb的第一个分区

[root@hx backup]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): 1
1: unknown command

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

查看磁盘信息

[root@hx backup]# vgs
  WARNING: Device for PV 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2 not found or rejected by a filter.
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  WARNING: Device for PV 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2 not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  Couldn't find device with uuid 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2.
  VG     #PV #LV #SN Attr   VSize   VFree
  vgdata   2   0   0 wz-pn- 209.99g 209.99g
[root@hx backup]# pvs
  WARNING: Device for PV 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2 not found or rejected by a filter.
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  WARNING: Device for PV 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2 not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  Couldn't find device with uuid 5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2.
  PV         VG     Fmt  Attr PSize    PFree
  [unknown]  vgdata lvm2 a-m   <10.00g  <10.00g
  [unknown]  vgdata lvm2 a-m  <200.00g <200.00g

 创建两个分区,大小随意

[root@hx backup]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition number (1-128, default 1): 1
First sector (34-419430366, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-419430366, default 419430366): +100G

Created a new partition 1 of type 'Linux filesystem' and of size 100 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@hx backup]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition number (2-128, default 2): 2
First sector (209717248-419430366, default 209717248):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (209717248-419430366, default 419430366):

Created a new partition 2 of type 'Linux filesystem' and of size 100 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@hx backup]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1  378K  0 rom
vda    253:0    0  100G  0 disk
├─vda1 253:1    0  200M  0 part /boot/efi
└─vda2 253:2    0 99.8G  0 part /
vdb    253:16   0  200G  0 disk
├─vdb1 253:17   0  100G  0 part
└─vdb2 253:18   0  100G  0 part
[root@hx backup]# pvs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  PV         VG     Fmt  Attr PSize    PFree
  /dev/vdb1  vgdata lvm2 a--  <200.00g <200.00g
  [unknown]  vgdata lvm2 a-m   <10.00g  <10.00g
[root@hx backup]# vgs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  VG     #PV #LV #SN Attr   VSize   VFree
  vgdata   2   0   0 wz-pn- 209.99g 209.99g
[root@hx backup]# lvs
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.

 2.2 查看VG备份信息

进入vg信息的备份目录

[root@hx ~]# cd /etc/lvm/backup
[root@hx backup]# ll
total 4
-rw------- 1 root root 1129 May  7 14:29 vgdata
[root@hx backup]# cat vgdata
# Generated by LVM2 version 2.02.1812 20180801: Tue May  7 14:29:59 2024

contents = "Text Format Volume Group"
version = 1

description = "Created *after* executing 'lvremove /dev/vgdata/lvdata'"

creation_host = "localhost"     # Linux localhost 4.19.90-23.8.v2101.ky10.aarch64 #1 SMP Mon May 17 17:07:38 CST 2021 aarch64
creation_time = 1715063399      # Tue May  7 14:29:59 2024

vgdata {
        id = "6AcdCD-2l68-ua7t-RfKP-CxLt-0K4u-yA9T6I"
        seqno = 5
        format = "lvm2"                 # informational
        status = ["RESIZEABLE", "READ", "WRITE"]
        flags = []
        extent_size = 8192              # 4 Megabytes
        max_lv = 0
        max_pv = 0
        metadata_copies = 0

        physical_volumes {

                pv0 {
                        id = "aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT"
                        device = "[unknown]"    # Hint only

                        status = ["ALLOCATABLE"]
                        flags = ["MISSING"]
                        dev_size = 20971520     # 10 Gigabytes
                        pe_start = 2048
                        pe_count = 2559 # 9.99609 Gigabytes
                }

                pv1 {
                        id = "5CAbQT-qAB4-HaT7-EeJf-X3EE-A2aX-dx94e2"
                        device = "/dev/vdb1"    # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 419428414    # 199.999 Gigabytes
                        pe_start = 2048
                        pe_count = 51199        # 199.996 Gigabytes
                }
        }


}

2.3 修复丢失的PV 

[root@hx backup]# pvcreate /dev/vdb2 -u aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT --restorefile /etc/lvm/backup/vgdata
  Couldn't find device with uuid aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT.
  WARNING: Device for PV aSyF11-trxa-WUUW-CX7k-rAur-0Brm-EYYizT not found or rejected by a filter.
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  Physical volume "/dev/vdb2" successfully created.

 2.4 查看磁盘信息

[root@hx backup]# pvs
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  PV         VG     Fmt  Attr PSize    PFree
  /dev/vdb1  vgdata lvm2 a--  <200.00g <200.00g
  /dev/vdb2  vgdata lvm2 a--   <10.00g  <10.00g
[root@hx backup]# vgs
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  VG     #PV #LV #SN Attr   VSize   VFree
  vgdata   2   0   0 wz--n- 209.99g 209.99g
[root@hx backup]# lvs
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.

3.删除PV

[root@hx backup]# vgremove /dev/vgdata
  WARNING: Device /dev/vdb1 has size of 209715200 sectors which is smaller than corresponding PV size of 419428414 sectors. Was device resized?
  One or more devices used as PVs in VG vgdata have changed sizes.
  Volume group "vgdata" successfully removed
[root@hx backup]# vgs
[root@hx backup]# pvs
  PV         VG Fmt  Attr PSize    PFree
  /dev/vdb1     lvm2 ---   100.00g  100.00g
  /dev/vdb2     lvm2 ---  <100.00g <100.00g
[root@hx backup]# pvremove /dev/vdb1
  Labels on physical volume "/dev/vdb1" successfully wiped.
[root@hx backup]# pvremove /dev/vdb2
  Labels on physical volume "/dev/vdb2" successfully wiped.
[root@hx backup]# pvs

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值