Import and rename duplicated volume group

If you like to use a cloned volume with a volume group on it, then normally you will have a problem with the VG UUID and the VG Name. The good answer there is a nice solution for the problem and you can import and rename duplicated volume groups.

To rename and generate a new UUID for the volume group on the volume use the program vgimportclone.

sudo gimportclone -n old /dev/sdb1
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Physical volume "/tmp/snap.cozRdFdC/vgimport0" changed
1 physical volume changed / 0 physical volumes not changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "system" successfully changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "system" successfully renamed to "old"
Reading all physical volumes. This may take a while...
Found volume group "system" using metadata type lvm2

After the successfully rename of the volume group activate it.

sudo vgchange -a y

Now you can use the renamed volume group old normally as other volume groups.

xfs filesystem duplicate UUID

If you clone a volume with xfs filesystem on it and you try to mount this on the same node, than normally you will receive error messages, like wrong fs type, bas superblock,… you have the problem with xfs filesystem duplicate UUID.

In the dmesg you should file a message like:

XFS: Filesystem sdb1 has duplicate UUID - can't mount.

If its a one time mount you can do it with:

sudo mount -o nouuid /dev/sdb1 /mnt

But the better solution is to generate a new uuid for the filesystem, because its clean and you can mount it easy without problems:

sudo xfs_admin -U generate /dev/sdb1
Clearing log and setting UUID
writing all SBs
new UUID = 01fbb4f2-1ers0-4dde-94fc-024efb3cd2a4
after that, you can mount this XFS partition regularly.

Then mount the volume normally with mount:

sudo mount /dev/sdb1 /mnt