5

Using MaaS to reinstall Ubuntu 18.04, I ended up in the situation where I've got two Volume Group's named "vgroot", two logical volumes named lvroot and an extra PV now named [unknown].

How do I get rid of the extra stuff? I can't pvremove by uuid, LVM unknown device: how to recover? says you're supposed to use vgreduce --removemissing to remove those.

 $ sudo vgreduce --removemissing --verbose vgroot
 Multiple VGs found with the same name: skipping vgroot
 Use --select vg_uuid=<uuid> in place of the VG name.

vgreduce doesn't have a --select option.

How to rename a logical volume when there are multiple volume groups with the same name has an answer for that, but now:

$ sudo vgrename 4vrdpY-MCJM-HBfT-RVhe-WnTr-2NGr-NDOJ6H old --force
Processing VG vgroot because of matching UUID 4vrdpY-MCJM-HBfT-RVhe-WnTr-2NGr-NDOJ6H
WARNING: Device for PV hKK5e2-wVbK-H6GR-0kly-Z5f6-UDUP-jImvr4 not found or rejected by a  filter.
Cannot change VG vgroot while PVs are missing.
Consider vgreduce --removemissing.
Cannot process volume group vgroot

and now we're back to what I tried first.

  • 1
    I had a similar issue last week, try to add a new (or even better the same) device to the machine, create a dummy PV if necessary. Then try to rename one of the volume groups and then remove all unused VGs/PVs. This worked for me. – eblock May 20 '20 at 13:04
  • Sounds like the genesis of a better answer than the one I posted below. But I'm out of the situation now and can't try it. Rather than renaming the bad VG, rename the good VG. Obvious in retrospect. – Bryan Larsen May 20 '20 at 13:08
  • Well, as long as you got it fixed it's all good. – eblock May 20 '20 at 13:19

2 Answers2

2

You can do this by twice force. The following command must be executed for your case:

pvremove /dev/sdb2 --force --force
1

Not an answer to my question as posted, but a solution to my problem and hopefully useful to anybody in the same boat.

LVM was picking up the old metadata from an old partition lying around, so by wiping the old partition and rebooting, I removed the duplicates.

 $ sudo wipefs -a /dev/sdb2
 $ reboot
  • Instead of rebooting, you could use pvscan --cache to rebuild the cache so you don't get warnings that the device for a PV cannot be found. – egrubbs Oct 25 '22 at 21:21