April 23, 2019

Point-and-Click Linux LVM Filesystem Workstation Backup, Part 1 - page 3

Taking Advantage of LVM

  • May 24, 2007
  • By A. Lizard

The problem with your new identical drive is that there are numeric IDs called uuids attached to the drive as a whole, the physical volume, and the logical volume. These IDs are supposed to be unique for each, so LVM won't recognize or deal correctly with two drives where any of the uuids are identical. It'll see one, but not the other. So you have to extract the uuids from the new backup drive, modify them, write them back to the backup drive. The good news is that knoppix seems to recognize the second drive created, not the original when it comes to having two drives open with the same uuids. You can identify what it actually did by seeing which LVM volumes are assigned to which drive.

Do not attempt to change the volume name until you've changed the UUIDs.

To find out what your volume IDs are, type:

root@1[/]# pvs; vgs; lvs
   PV         VG         Fmt  Attr PSize   PFree
   /dev/hda2  VolGroup00 lvm2 a-   152.56G 32.00M
   VG         #PV #LV #SN Attr   VSize   VFree
   VolGroup00   1   2   0 wz--n- 152.56G 32.00M
   LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%
   LogVol00 VolGroup00 -wi-a- 151.53G
   LogVol01 VolGroup00 -wi-a-   1.00G

Now plug in your backup drive, boot from Knoppix, and enter the next commands.

$ su
terrarium:/home/alizard# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "terrarium" using metadata type lvm2
terrarium:/home/alizard# vgcfgbackup -f terrarium.cfg terrarium
  Volume group "terrarium" successfully backed up.
terrarium:/home/alizard# nano terrarium.cfg

nano terrarium.cfg

Opening the files will make access to the UUIDs possible. Increment the last character by one on all four of the UUIDs, e.g. on terrarium id, V becomes W, 1 becomes 2, etc. This is what the file looks like.

terrarium {
        id = "Dpe3dB-xfce-BYvi-bu1U-OGP4-CHO3-cY5cgV"
. . .
        physical_volumes {

		pv0 {
                id = "SNKs3k-hppI-ycTS-KSv1-qpEn-R9Dn-8I7rVg"
. . .
                root {
                        id = "2yt2FJ-NZap-Bno5-aJ1i-EP3I-SxLv-aNQkZW"
. . .
                swap_1 {
                        id = "kiIium-A8Qx-2oOO-EECP-E3gZ-RzIo-PsK6B8"

Close and save the file.

# pvcreate -ff --uuid Dpe3dB-xfce-BYvi-bu1U-OGP4-CHO3-cY5cgW --restorefile terrarium.cfg /dev/hda5

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

Now change the LVM volumeID.

# vgrename userdrive userdrive-back

Most Popular LinuxPlanet Stories