Skip to contentSkip to conversation

Altering a Physical Volume's UUID

linux-lvm Mark Krenz 2 participants 3 messages Sep 8, 2006

lore
Share & tools
lore

Mark Krenz

author
#0 lore raw

Hi, I'm using LVM with Xen virtual machines by creating sparse image
files with something like

dd if=/dev/zero of=diskimage bs=1 count=1 seek=1073741824

Then I use a loopback device to use the diskimage as a block device and
create a physical volume, volume group and logical volumes on it.

This all works great, but when I copy the diskimage file to another
file and try to setup a loopback device for it, I get complaints about there being multiple identifical UUIDs for physical volumes and volume groups.

So is there a way to change the UUID of a physical volume and volume
group?

If you are wondering why I would need to copy the diskimage file, its
because I'm setting up Xen template images for different OSes that I can then simply copy into place, make a few modifications and then be on my way.

Signature · 4 lines
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/
#1 lore raw
Quoted 3 lines · Mark Krenz

So is there a way to change the UUID of a physical volume and volume
group?

i'd try with vgcfgbackup, sed, pvcreate, vgcfgrestore.

L.

Signature · 6 lines
Luca Berra -- [email protected]
       Communication Media & Services S.r.l.
/"\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \
author
#2 lore raw

Re: [linux-lvm] Altering a Physical Volume's UUID [solved]

Hey, that works! Thank you very much Luca. For other people's
benifit that may find this in a search, here is what I did:

This assumes that you ALREADY have a disk file called lvmdisk1 with lvm partitions on it

# losetup /dev/loop0 lvmdisk1
# vgscan
# vgcfgbackup -f TemplateVG.cfg TemplateVG

Now edit TemplateVG.cfg file and change the IDs for the volume group, physical volume and logical volumes too. I made it easy by just incrementing the last character by one, a becomes b, x becomes y, etc. Keep track of what ID you gave the physical volume.

# vgchange -a n TemplateVG 

Now run pvcreate using the --uuid option and use the NEW uuid that you generated an changed to in the VG config file.

# pvcreate -ff --uuid CFhjSe-EqSc-pnDz-4UcP-ylxh-hcY6-oV6BGR --restorefile TestDiskVG.cfg /dev/loop2

It will complain that it couldn't find the physical volume with the specified uuid, but it will still create the physical volume.

# vgcfgrestore -f TemplateVG.cfg TemplateVG
# vgchange -a y TemplateVG

That's it, now you can change the volume group name if that's what you need to do. You should try mounting one of the logical volumes now to make sure the data is still in tact.

On Fri, Sep 08, 2006 at 03:35:10PM GMT, Luca Berra [[email protected]] said the following:

Quoted 21 lines · Mark Krenz
Quoted 3 lines

So is there a way to change the UUID of a physical volume and volume group?

i'd try with vgcfgbackup, sed, pvcreate, vgcfgrestore.

L.

Signature · 12 lines
Luca Berra -- [email protected]
       Communication Media & Services S.r.l.
/"\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
Signature · 4 lines
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/