1

After I accidentally created a GPT label on /dev/sdb, I need to fix the PV NAME "[unknown]" (which was /dev/sdb previously) :

$ sudo pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda3  ubuntu-vg lvm2 a--  <69.00g    0
  /dev/sdb   ubuntu-vg lvm2 a--  <20.00g    0

on the second PV from ubuntu-vg VG :

$ sudo pvs -v
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  PV         VG        Fmt  Attr PSize   PFree DevSize PV UUID
  /dev/sda3  ubuntu-vg lvm2 a--  <69.00g    0  <79.00g 3CHhp6-yMvu-Fnqj-8usZ-EHp8-k88B-Jm8MK3
  [unknown]  ubuntu-vg lvm2 a-m  <20.00g    0       0  CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q
$ sudo vgreduce --removemissing --verbose /dev/ubuntu-vg
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  There are 1 physical volumes missing.
  Archiving volume group "ubuntu-vg" metadata (seqno 12).
  WARNING: Partial LV ubuntu-lv needs to be repaired or removed.
  There are still partial LVs in VG ubuntu-vg.
  To remove them unconditionally use: vgreduce --removemissing --force.
  WARNING: Proceeding to remove empty missing PVs.
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  There are 1 physical volumes missing.
  Creating volume group backup "/etc/lvm/backup/ubuntu-vg" (seqno 13).
$ sudo pvdisplay -m
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               ubuntu-vg
  PV Size               <69.00 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              17663
  Free PE               0
  Allocated PE          17663
  PV UUID               3CHhp6-yMvu-Fnqj-8usZ-EHp8-k88B-Jm8MK3

  --- Physical Segments ---
  Physical extent 0 to 17662:
    Logical volume      /dev/ubuntu-vg/ubuntu-lv
    Logical extents     0 to 17662

  --- Physical volume ---
  PV Name               [unknown]
  VG Name               ubuntu-vg
  PV Size               20.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              5119
  Free PE               0
  Allocated PE          5119
  PV UUID               CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q

  --- Physical Segments ---
  Physical extent 0 to 5118:
    Logical volume      /dev/ubuntu-vg/ubuntu-lv
    Logical extents     17663 to 22781

EDIT0 : This /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg contains the LVM metadata prior (from the 2nd of August) to my incident (the 12th of September), can I use it to fix this UUID pb. and if so, how ? :

$ sudo ll /etc/lvm/archive/
total 48
drwx------ 2 root root 4096 Sep 12 16:47 ./
drwxr-xr-x 5 root root 4096 Nov  3  2021 ../
-rw------- 1 root root 1310 Mar  8  2022 ubuntu-vg_00002-434733304.vg
-rw------- 1 root root 1347 Mar  8  2022 ubuntu-vg_00003-1070329593.vg
-rw------- 1 root root 1350 Jun 20 13:04 ubuntu-vg_00004-1689574179.vg
-rw------- 1 root root 1351 Jul  8 09:02 ubuntu-vg_00005-1407536141.vg
-rw------- 1 root root 1332 Aug  2 12:30 ubuntu-vg_00006-1483580564.vg
-rw------- 1 root root 1593 Aug  2 12:33 ubuntu-vg_00007-1330575295.vg
-rw------- 1 root root 1731 Sep 12 14:20 ubuntu-vg_00008-589825908.vg
-rw------- 1 root root 1731 Sep 12 14:20 ubuntu-vg_00009-1110009706.vg
-rw------- 1 root root 1767 Sep 12 15:58 ubuntu-vg_00010-1978053106.vg
-rw------- 1 root root 1777 Sep 12 16:47 ubuntu-vg_00011-663327121.vg
$ sudo cat /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg
        id = "Wljig7-1EmZ-HWx6-HD3a-abaR-tAc0-IGTYnj"
        seqno = 9
        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 = "3CHhp6-yMvu-Fnqj-8usZ-EHp8-k88B-Jm8MK3"
                        device = "/dev/sda3"    # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 144695296    # 68.9961 Gigabytes
                        pe_start = 2048
                        pe_count = 17663        # 68.9961 Gigabytes
                }

                pv1 {
                        id = "CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q"
                        device = "/dev/sdb"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 41943040     # 20 Gigabytes
                        pe_start = 2048
                        pe_count = 5119 # 19.9961 Gigabytes
                }
        }

        logical_volumes {

                ubuntu-lv {
                        id = "slgzg5-CwNC-0sVo-4qFo-fnVj-A5Eu-4mVLE1"
                        status = ["READ", "WRITE", "VISIBLE"]
                        flags = []
                        creation_time = 1631117746      # 2021-09-08 18:15:46 +0200
                        creation_host = "ubuntu-server"
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 17663    # 68.9961 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }
        }

}

EDIT1 : I added a new virtual disk to move the data from /dev/sdb but it did not work :

$ lsscsi -ss
[2:0:0:0]    cd/dvd  NECVMWar VMware SATA CD00 1.00  /dev/sr0        -
[32:0:0:0]   disk    VMware   Virtual disk     2.0   /dev/sda   80.0GiB
[32:0:1:0]   disk    VMware   Virtual disk     2.0   /dev/sdb   20.0GiB
$ ll /dev/sdc
ls: cannot access '/dev/sdc': No such file or directory
$ echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan
- - -
$ lsscsi -ss
[2:0:0:0]    cd/dvd  NECVMWar VMware SATA CD00 1.00  /dev/sr0        -
[32:0:0:0]   disk    VMware   Virtual disk     2.0   /dev/sda   80.0GiB
[32:0:1:0]   disk    VMware   Virtual disk     2.0   /dev/sdb   20.0GiB
[32:0:2:0]   disk    VMware   Virtual disk     2.0   /dev/sdc   20.0GiB
$ ll /dev/sdc
brw-rw---- 1 root disk 8, 32 Sep 13 10:41 /dev/sdc
$ sudo parted /dev/sdc
GNU Parted 3.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdc: unrecognised disk label
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt
(parted)
$ sudo gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sdc: 41943040 sectors, 20.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): F07182AE-3C90-419E-91ED-E1BF652C46A7
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (20.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-41943006, default = 41943006) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'

Command (? for help): p
Disk /dev/sdc: 41943040 sectors, 20.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): F07182AE-3C90-419E-91ED-E1BF652C46A7
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        41943006   20.0 GiB    8E00  Linux LVM

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
$ sudo pvcreate /dev/sdc1
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  Physical volume "/dev/sdc1" successfully created.
$ sudo vgextend /dev/ubuntu-vg /dev/sdc1
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  Volume group "ubuntu-vg" successfully extended
$ sudo pvs -o+pv_used,uuid
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  PV         VG        Fmt  Attr PSize   PFree   Used    PV UUID
  /dev/sda3  ubuntu-vg lvm2 a--  <69.00g      0  <69.00g 3CHhp6-yMvu-Fnqj-8usZ-EHp8-k88B-Jm8MK3
  /dev/sdc1  ubuntu-vg lvm2 a--  <20.00g <20.00g      0  CLOgz3-eXyz-nUWm-e1db-oqoR-vldX-hcK4d1
  [unknown]  ubuntu-vg lvm2 a-m  <20.00g      0  <20.00g CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q
$ sudo pvmove /dev/sdb
  Failed to find device for physical volume "/dev/sdb".
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  WARNING: VG ubuntu-vg is missing PV CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q (last written to [unknown]).
  WARNING: Couldn't find all devices for LV ubuntu-vg/ubuntu-lv while checking used and assumed devices.
  Cannot change VG ubuntu-vg while PVs are missing.
  See vgreduce --removemissing and vgextend --restoremissing.
  Cannot process volume group ubuntu-vg
  Run `pvmove --help' for more information.

EDIT2 : Trying a vcfgrestore from /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg :

$ sudo ll /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg
-rw------- 1 root root 1593 Aug  2 12:33 /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg
$ sudo vgcfgrestore --test -f /etc/lvm/archive/ubuntu-vg_00007-1330575295.vg /dev/ubuntu-vg
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Volume group ubuntu-vg has active volume: ubuntu-lv.
  WARNING: Found 1 active volume(s) in volume group "ubuntu-vg".
  Restoring VG with active LVs, may cause mismatch with its metadata.
Do you really want to proceed with restore of volume group "ubuntu-vg", while 1 volume(s) are active? [y/n]: y
  WARNING: Couldn't find device with uuid CdlY5k-IynC-hYTX-hH3h-HaLC-KAqy-n4h38q.
  Cannot restore Volume Group ubuntu-vg with 1 PVs marked as missing.
  Restore failed.

How can I fix lvm PV name "[unknown]" without forcing the removal of second PV from VG ?

0

You must log in to answer this question.

Browse other questions tagged .