Skip to contentSkip to conversation

Import duplicate VG from a read-only device

DISCUSSION Gionatan Danti 4 participants 6 messages Nov 15, 2024 – Nov 18, 2024

lore
Share & tools
lore
#0 lore raw

Hi list,
is it possible to import a duplicate VG name from a read-only device?

I know about vgrename, but it needs to update metadata - which is not possible for read-only device.

I tried to un-manage the host native read/write VG, deleting it from system.devices, but lvchange -ay shown an error about not being able to create the /dev/VG/LV symlink (and a "device busy" issue, probably related to the already-existing symlink). I also tried to activate the specific LV via lvchange -S lv_uuid, but it shown the same error as above.

In this specific case I put the device in r/w mode and solved the issue with a plain vgrename. But what if I could not enable writes on the device? Is the only solution to mount it on a machine without the same VG name (ie: on a live USB), or can a VG/LV be enabled specifying a different path for the symlink?

Thanks.

#1 lore raw

Dne 15. 11. 24 v 21:07 Gionatan Danti napsal(a):

Quoted 8 lines

Hi list,
is it possible to import a duplicate VG name from a read-only device?

I know about vgrename, but it needs to update metadata - which is not possible for read-only device.

I tried to un-manage the host native read/write VG, deleting it from system.devices, but lvchange -ay shown an error about not being able to create the /dev/VG/LV symlink (and a "device busy" issue, probably related to the already-existing symlink). I also tried to activate the specific LV via lvchange -S lv_uuid, but it shown the same error as above.

In this specific case I put the device in r/w mode and solved the issue with a plain vgrename. But what if I could not enable writes on the device? Is the only solution to mount it on a machine without the same VG name (ie: on a live USB), or can a VG/LV be enabled specifying a different path for the symlink?

Hi

You can always write appropriate lvm.conf filter or use devicesfile to list only those devices/PV you want to use and not cause 'duplicate VG' problem for command processing.

However there is no chance to activate duplicated VG/LV as clearly there cannot exist 2 DM devices with the same name/uuid - they must be unique!

So perhaps maybe you can 'rename' VG of the system you are running from - if you cannot change the metadata on you read-only device.

Here I'd probably suggest to simply avoid creating such problems upfront,
AKA - if all your systems are using the same VG name and then you want to 'share/swap' such devices between your systems - you should always pick a unique VG name for each such system. That way avoids all the problems....

Regards

Zdenek

PS: I think ATM lvm2 is already complicated enough to creating some 'overlay' level of referencing lvm2 names in the system through some 'abstract' mechanism to solve the issue that can be easily eliminated ahead makes not much sense to implement....

#2 lore raw
Quoted 36 lines · Zdenek Kabelac

Dne 15. 11. 24 v 21:07 Gionatan Danti napsal(a):

Quoted 12 lines

Hi list,
is it possible to import a duplicate VG name from a read-only device?

I know about vgrename, but it needs to update metadata - which is not possible for read-only device.

I tried to un-manage the host native read/write VG, deleting it from system.devices, but lvchange -ay shown an error about not being able to create the /dev/VG/LV symlink (and a "device busy" issue, probably related to the already-existing symlink). I also tried to activate the specific LV via lvchange -S lv_uuid, but it shown the same error as above.

Quoted 4 lines

In this specific case I put the device in r/w mode and solved the issue with a plain vgrename. But what if I could not enable writes on the device? Is the only solution to mount it on a machine without the same VG name (ie: on a live USB), or can a VG/LV be enabled specifying a different path for the symlink?

Hi

You can always write appropriate lvm.conf filter or use devicesfile to list only those devices/PV you want to use and not cause 'duplicate VG' problem for command processing.

However there is no chance to activate duplicated VG/LV as clearly there cannot exist 2 DM devices with the same name/uuid - they must be unique!

So perhaps maybe you can 'rename' VG of the system you are running from - if you cannot change the metadata on you read-only device.

Here I'd probably suggest to simply avoid creating such problems upfront, AKA - if all your systems are using the same VG name and then you want to 'share/swap' such devices between your systems - you should always pick a unique VG name for each such system. That way avoids all the problems....

Regards

Quoted 9 lines

Zdenek

PS: I think ATM lvm2 is already complicated enough to creating some 'overlay' level of referencing lvm2 names in the system through some 'abstract' mechanism to solve the issue that can be easily eliminated ahead makes not much sense to implement....

Do I agree with the above sentence!!!!.  I've seen major issues where administrators have created a massively complex system out of LVM to the extend they dug themselves a rabithole from which they couldn't escape anymore. ALWAYS keep it as simple as possible and only use what you actually need. Try to stay away from bells and whistles if you don't needs them....

Cheers

Erwin

#3 lore raw

Il 2024-11-18 14:38 Erwin van Londen ha scritto:

Quoted 14 lines · Zdenek Kabelac
Quoted 6 lines

PS: I think ATM lvm2 is already complicated enough to creating some 'overlay' level of referencing lvm2 names in the system through some 'abstract' mechanism to solve the issue that can be easily eliminated ahead makes not much sense to implement....

Do I agree with the above sentence!!!!.  I've seen major issues where administrators have created a massively complex system out of LVM to the extend they dug themselves a rabithole from which they couldn't escape anymore. ALWAYS keep it as simple as possible and only use what you actually need. Try to stay away from bells and whistles if you don't needs them....

Quoted 3 lines

Cheers

Erwin

Sure, I completely agree with both.
I was just curious to know if I was missing something obvious.

Thanks.

#4 lore raw
Quoted 2 lines · Gionatan Danti

Sure, I completely agree with both.
I was just curious to know if I was missing something obvious.

I would use device mapper to create a writable overlay block device of the readonly block device (like Live media does) and rename that to import. No monkeying about with namespaces.

#5 lore raw

Il 2024-11-18 19:25 Stuart D Gathman ha scritto:

Quoted 3 lines

I would use device mapper to create a writable overlay block device of the readonly block device (like Live media does) and rename that to import. No monkeying about with namespaces.

Yes, it would probably be the only solution with a real read-only device.

Still, I remember the good old advice to not touch the dm table when using LVM (to avoid doing something wrong with the LVM-managed tables) - so I would probably be more comfortable using a live media to rename the duplicate VG.

Thanks.