I think this is something unique to your system that you had to do this. I created raid+lvm under Rocky 8, then disconnected the disks, and connected them to Rocky 9 and it was accessible as soon as I activated the mdadm.
As you found, mileage varies, what works for one person, not necessarily another. The good think is you were able to use lvmdevices to add the device and then the vgchange command to activate it. Maybe mine just worked because it was created under Rocky 8, rather than using LVM under CentOS 7. Perhaps that had something to do with it, perhaps not.
I’ve had varying issues with lvm, also had one inaccessible once, and was just enough to use vgchange to activate it. Others it was irrecoverable due to metadata loss but was able to get it back from a backup. So it’s handy to make a list of commands used that helped resolve it, just in case for the future you might need them again.
Thank you guys. This works great.
And This is for the posterity.
$ lvmdevices --addev /dev/sdb1
$ lvmdevices --addev /dev/sdb2
$ vgchange -ay vg-datastore
After this command, the system.devices file changed which contains the info above.
My lvm vg was made via Rocky linux 8.
This command is not for raid, but works.
I’ve been a CentOS user since V4 and I loved it when Rocky started up.
I’ve been on Rocky since its beginning.
But I’ve now been motivated by this thread.
My home server (web/file) has gone from CentOS V4 up to Rocky 8.7.
Of course it is and old server so I decided to upgrade.
Its now on Rocky 9.1.
All of my /home content is on a LV.
After installing Rocky 9.1 fresh on the new server I did the following on the old one to move the disks over:
systemctl stop httpd smb
vgchange -an vg_home
I then removed the drives and installed them on the new server and did:
systemctl stop httpd
And NOTHING of these drives was visible.
found I could use gdisk and see them but LVM couldn’t see anything.
So before I reformatted them I ran across this thread and used the
lvmdevices --adddev /dev/sd<1>
lvmdevices --adddev /dev/sd<2>
After that, pvscan could see them and i was able to vgimport, vgchange and mount it.
Saved recovering 7TB of data.
So LVM has more rules about what it can and can’t pay attention to, at least between Rock 8.7 and 9.1 (RHEL 8.7 RHEL 9.1).
Thanks to All of you for the FANTASTIC work.
I just had the same problem (after reinstaling CentOS 7 machine to Rocky 9), so thank you all for solution!
I had to use:
lvmdevices --adddev /dev/sdx
For pvscan and vgscan to see the old lvm, and then I was able to read its name and activate it:
vgchange -ay centos_xxx