Altering a Physical Volume's UUID on SATA hard drives [solved]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I bit-copied a backup LVM disk using dd from a Knoppix LiveCD (based on Debian) and wound up with duplicate volume and uuids, meaning I couldn't mount both the main and backup volumes simultaneously at the same time for subsequent backups. Of course, vgrename is ineffective to allow simultaneous mounting without changing the uuids.

My system hardware is:
Biostar Geforce 6100 AM2, with the usual IDE setup and 2 SATA channels. Note that if a drive is plugged into the JSATA2 connector in the absence of anything plugged into JSATA1, it appears to the OS as SDA, NOT SDB. I don't know if that's normal for SATA or not. It is disconcerting.

My main and backup hard drives are Samsung SATA2 HD403LJ, the backup drive is plugged into a mobile rack.

NOTE: I'd really like to see a specific Linux LVM command that will change uuids for an LVM volume without manual intervention.

However, the workaround in the "HOW TO ALTER SATA LVM VOLUME UUIDs" section below will keep SATA users going in the meantime, readers in a hurry should scroll down to that part of this post.

When I used the recommended method described in
Re: Altering a Physical Volume's UUID [solved]
( http://www.spinics.net/lists/lvm/msg16090.html ) involving extracting the uuids via vcfgbackup and incrementing them all by 1, creating a physical volume via pvcreate, then writing it back via vgcfgrestore from a Knoppix LiveCD on a pair of SATA hard drives.

It failed as below:

original terrarium.cfg file:
# Generated by LVM2: Thu Aug 16 16:24:03 2007

contents = "Text Format Volume Group"
version = 1

description = "vgcfgbackup -f terrarium.cfg terrarium"

creation_host = "terrarium" # Linux terrarium 2.6.21-2-k7 #1 SMP Wed Jul 11 04:29:08 UTC 2007 i686
creation_time = 1187306643	# Thu Aug 16 16:24:03 2007

terrarium {
	id = "gX4iKn-9GCb-TKSG-mKQE-dqc0-Kt1Q-FAo1Ne"
	seqno = 3
	status = ["RESIZEABLE", "READ", "WRITE"]
	extent_size = 8192		# 4 Megabytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "5fmUbT-7liU-DUoI-6C0z-98Pq-uDE4-d3zkuL"
			device = "/dev/sda5"	# Hint only

			status = ["ALLOCATABLE"]
			pe_start = 384
			pe_count = 95327	# 372.371 Gigabytes
		}
	}

	logical_volumes {

		root {
			id = "hZBRED-nxBj-v1xU-8TFP-le4B-ye16-fWyn5e"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 94664	# 369.781 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
		}

		swap_1 {
			id = "dQ248n-d62X-G6Dn-E9iJ-aHSA-cFbp-4hFuYW"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 663	# 2.58984 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 94664
				]
			}
		}
	}
}
After incrementing the uuids by one, I got:

root@1[knoppix]# pvcreate -ff --uuid gX4iKn-9GCb-TKSG-mKQE-dqc0-Kt1Q-FAo1Nf --restorefile terrarium.cfg /dev/loop2 Found duplicate PV 5fmUbT7liUDUoI6C0z98PquDE4d3zkuL: using /dev/sda5 not /dev/loop0 Found duplicate PV 5fmUbT7liUDUoI6C0z98PquDE4d3zkuL: using /dev/loop0 not /dev/sda5 Found duplicate PV 5fmUbT7liUDUoI6C0z98PquDE4d3zkuL: using /dev/sda5 not /dev/loop0 Found duplicate PV 5fmUbT7liUDUoI6C0z98PquDE4d3zkuL: using /dev/loop0 not /dev/sda5 Found duplicate PV 5fmUbT7liUDUoI6C0z98PquDE4d3zkuL: using /dev/sda5 not /dev/loop0
  Couldn't find device with uuid '5fmUbT-7liU-DUoI-6C0z-98Pq-uDE4-d3zkuM'.
Can't find uuid gX4iKn-9GCb-TKSG-mKQE-dqc0-Kt1Q-FAo1Nf in backup file terrarium.cfg

While "can't find" is what I expected, nothing wrote back when I tried vgcfgrestore, all I got was an error message.

There's at least one other variation of this basic method that doesn't involve loop mounting, and it also fails. What appears to be going on is that at least in an SATA vgcfgrestore , the copy one tried to modify is checked against the original and fails.

HOW TO ALTER SATA LVM VOLUME UUIDs

I got this working by using LVM commands to change uuids for PV (physical_volume) and for VG (volume group), then manually incremented the LV (logical_volume) uuids. As far as I can see, this should work for either IDE or SATA HDs. The original uuids are different from the above because I did some experimentation with this before submitting this solution to the list.

In the example below, replace "terrarium" with the actual volume name you're using, /dev/sda5 with the actual disk partition you're trying to use. In-line comments marked with *** .

Only the drive you are trying to change UUIDs for should be plugged in at this point.
DO NOT LVM-MOUNT IT USING vgchange -ay .

root@1[knoppix]# pvchange -u /dev/sda5
  Physical volume "/dev/sda5" changed
  1 physical volume changed / 0 physical volumes not changed
root@1[knoppix]# vgchange -u terrarium
  Volume group "terrarium" successfully changed
root@1[knoppix]# vgcfgbackup -f terrarium.cfg terrarium
  Volume group "terrarium" successfully backed up.
*** This creates a LVM configuration file that can be manually edited containing the above uuid changes produced by pvchange -u and vgchange -u.

root@1[knoppix]# nano terrarium.cfg

*** At this point, open with a text editor (in this example, nano) and increment the last character in each of the "logical_volumes" uuids by 1 , f becomes g, 4 becomes 5, etc. In the example configuration files below, this would be the uuids for root and swap_1, e.g.
root {
                        id = "hZBRED-nxBj-v1xU-8TFP-le4B-ye16-fWyn5f"
becomes                 id = "hZBRED-nxBj-v1xU-8TFP-le4B-ye16-fWyn5g"
DO NOTHING WITH THE ID and PV uuids at this stage. Apparently, only the volume ID and PV ID uuids are checked against the original.

root@1[knoppix]# pvcreate -ff --uuid jEzDgz-S7nH-oTeU-nmWk-kTSM-tmpo-7O4Ryp --restorefile terrarium.cfg /dev/sda5 Can't find uuid jEzDgz-S7nH-oTeU-nmWk-kTSM-tmpo-7O4Ryp in backup file terrarium.cfg

*** This error message is usual, and not a problem as long as vgcfgrestore returns as below:

root@1[knoppix]# vgcfgrestore -f terrarium.cfg terrarium
  Restored volume group terrarium

*** This writes the LVM configuration file back to the disk's LVM configuration.-

*** At this point, you can use vgrename:
# vgrename terrarium terrarium-back

*** At this point, you have successfully changed the uuids and volume name now have a backup drive volume that will mount simultaneously with your main drive.

*** original cfg
-----------------------------------------------------
# Generated by LVM2: Sat Aug 18 09:23:35 2007
segment1 {
contents = "Text Format Volume Group"
version = 1

description = "vgcfgbackup -f terrarium.cfg terrarium"

creation_host = "Knoppix"       # Linux Knoppix 2.6.17 #4 SMP PREEMPT
Wed May 1$
creation_time = 1187443415      # Sat Aug 18 09:23:35 2007

terrarium {
        id = "tOezwV-ZnrW-wPM9-I3D1-4zjj-KDY2-Ikz1O4"
        seqno = 14
        status = ["RESIZEABLE", "READ", "WRITE"]
        extent_size = 8192              # 4 Megabytes
        max_lv = 0
        max_pv = 0

        physical_volumes {

  pv0 {
                        id = "GOe7U8-fU7p-xC0V-btvK-q1mh-sotC-0qqzht"
                        device = "/dev/sda5"    # Hint only

                        status = ["ALLOCATABLE"]
                        pe_start = 384
                        pe_count = 95327        # 372.371 Gigabytes
                }
        }

        logical_volumes {

                root {
                        id = "hZBRED-nxBj-v1xU-8TFP-le4B-ye16-fWyn5f"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
 start_extent = 0
                                extent_count = 94664    # 369.781 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }

                swap_1 {
                        id = "dQ248n-d62X-G6Dn-E9iJ-aHSA-cFbp-4hFuYX"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                              segment1 {
                                start_extent = 0
                                extent_count = 663      # 2.58984 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 94664
                                ]
                        }
                }
        }
}
-----------------------------------------------------
*** AFTER uuid change to verify that it worked (i.e. are the IDs changed from the original?):

root@1[knoppix]# vgcfgbackup -f terrarium.cfg terrarium
  Volume group "terrarium" successfully backed up.

nano terrarium.cfg

*** modified cfg
---------------------------------------------------
description = "vgcfgbackup -f terrarium.cfg terrarium"

creation_host = "Knoppix"       # Linux Knoppix 2.6.17 #4 SMP PREEMPT
Wed May 1$
creation_time = 1187444082      # Sat Aug 18 09:34:42 2007

terrarium {
        id = "jEzDgz-S7nH-oTeU-nmWk-kTSM-tmpo-7O4Ryp"
        seqno = 17
        status = ["RESIZEABLE", "READ", "WRITE"]
        extent_size = 8192              # 4 Megabytes
        max_lv = 0
        max_pv = 0

        physical_volumes {


                pv0 {
                        id = "lk7nC4-13Bo-YbhF-PiPD-f146-MP6V-lcArz1"
                        device = "/dev/sda5"    # Hint only

                        status = ["ALLOCATABLE"]
                        pe_start = 384
                        pe_count = 95327        # 372.371 Gigabytes
                }
        }

        logical_volumes {

                root {
                        id = "hZBRED-nxBj-v1xU-8TFP-le4B-ye16-fWyn5g"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
 start_extent = 0
                                extent_count = 94664    # 369.781 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }

                swap_1 {
                        id = "dQ248n-d62X-G6Dn-E9iJ-aHSA-cFbp-4hFuYY"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
 start_extent = 0
                                extent_count = 663      # 2.58984 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 94664
                                ]
                        }
                }
        }
}
--------------------------------
at this point, you can rename the volume.
member The Internet Society (ISOC), The HTML Writers Guild.
"You can't have in a democracy various groups with arms - you have to have the state with a monopoly on power." Condoleeza Rice, US Secretary of State
Personal Website http://www.ecis.com/~alizard
business Website http://www.reptilelabs.com
backup address (if ALL else fails) alizard@gmail.com
PGP 8.0 key available by request or keyserver. Download PGP from:
http://www.pgpi.org for e-mail privacy.
Disaster prep info: http://www.ecis.com/~alizard/y2k.html
***Looking for INTELLIGENT new technology public policy alternatives?*** http://www.ecis.com/~alizard/technology.html

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

[Index of Archives]     [Gluster Users]     [Kernel Development]     [Linux Clusters]     [Device Mapper]     [Security]     [Bugtraq]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]

  Powered by Linux