# [SOLVED] lvm duplicate volume groups

## redwood

I have a laptop which had a hard drive crash, so I've booted the laptop with a rescue CD, and

I am copying the hard drive with dd_rescue to an image file on a nfs-mounted partition exported

from my desktop:

```

dd_rescue /dev/hda /mnt/nfs/images/Toshiba.dmg -l /mnt/nfs/images/Toshiba.log

```

I've run fdisk -ul Toshiba.dmg

```

fdisk -ul Toshiba.dmg

You must set cylinders.

You can do this from the extra functions menu.

Disk Toshiba.dmg: 0 MB, 0 bytes

255 heads, 63 sectors/track, 0 cylinders, total 0 sectors

Units = sectors of 1 * 512 = 512 bytes

Disk identifier: 0x95aa95aa

      Device Boot      Start         End      Blocks   Id  System

Toshiba.dmg1   *          63    31551659    15775798+   7  HPFS/NTFS

Partition 1 has different physical/logical endings:

     phys=(1023, 254, 63) logical=(1963, 254, 63)

Toshiba.dmg2   *    31551660    31648049       48195   83  Linux

Partition 2 has different physical/logical beginnings (non-Linux?):

     phys=(1023, 254, 63) logical=(1964, 0, 1)

Partition 2 has different physical/logical endings:

     phys=(1023, 254, 63) logical=(1969, 254, 63)

Toshiba.dmg3        31648050    33607979      979965   82  Linux swap / Solaris

Partition 3 has different physical/logical beginnings (non-Linux?):

     phys=(1023, 254, 63) logical=(1970, 0, 1)

Partition 3 has different physical/logical endings:

     phys=(1023, 254, 63) logical=(2091, 254, 63)

Toshiba.dmg4        33607980   195366464    80879242+   5  Extended

Partition 4 has different physical/logical beginnings (non-Linux?):

     phys=(1023, 254, 63) logical=(2092, 0, 1)

Partition 4 has different physical/logical endings:

     phys=(1023, 254, 63) logical=(12160, 254, 63)

Toshiba.dmg5        33608043    62910539    14651248+   7  HPFS/NTFS

Toshiba.dmg6        62910603    92213099    14651248+   7  HPFS/NTFS

Toshiba.dmg7        92213163    94253354     1020096   83  Linux

Toshiba.dmg8        94253418   195366464    50556523+  8e  Linux LVM

```

and I've been able to mount my partitions from this image file

using offsets of 512xStartpos:

```

mount -o loop,offset=32256 -t auto Toshiba.dmg           laptop/C:

mount -o loop,offset=16154449920 -t ext2 Toshiba.dmg laptop/boot

mount -o loop,offset=17207318016 -t auto Toshiba.dmg laptop/D:

mount -o loop,offset=32210228736 -t auto Toshiba.dmg laptop/E:

mount -o loop,offset=47213139456 -t auto Toshiba.dmg laptop/rootfs

```

However /dev/hda8 is an LVM partition,

so I've setup up a loop device:

```

losetup -a

losetup -o 48257750016 /dev/loop0 Toshiba.dmg

```

But when scanning for volume groups and logical volumes on /dev/loop0

I get duplicate volume groups because both my desktop and laptop were setup

with similar volume groups {vg, bkup} and my desktop's volume groups are active:

```

Desktop# pvs

  PV         VG   Fmt  Attr PSize   PFree

  /dev/md4   vg   lvm2 a-   925.82G 626.82G

  /dev/sda   temp lvm2 a-   232.88G  32.88G

  /dev/sdb   bkup lvm2 a-   232.88G   7.88G

```

```

Desktop# lvs

  LV        VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert

  backups   bkup -wi-ao  60.00G

  distfiles bkup -wi-a-  10.00G

  dwnld     bkup -wi-ao   5.00G

  media     bkup -wi-ao 150.00G

  images    temp -wi-ao 200.00G

  M         vg   -wi-ao  10.00G

  P         vg   -wi-ao  10.00G

  V         vg   -wi-ao 150.00G

  Z         vg   -wi-ao  20.00G

  distfiles vg   -wi-ao  10.00G

  home      vg   -wi-ao  10.00G

  oldhd     vg   -wi-ao  40.00G

  opt       vg   -wi-ao   4.00G

  portage   vg   -wi-ao   2.00G

  tmp       vg   -wi-ao   2.00G

  usr       vg   -wi-ao  30.00G

  var       vg   -wi-ao   4.00G

  vartmp    vg   -wi-ao   7.00G

```

```

Desktop# pvs /dev/loop0

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Physical Volume /dev/loop0 is too large for underlying device

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

Desktop# vgs

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Physical Volume /dev/loop0 is too large for underlying device

  VG   #PV #LV #SN Attr   VSize   VFree

  bkup   1   4   0 wz--n- 232.88G   7.88G

  temp   1   1   0 wz--n- 232.88G  32.88G

  vg     1  13   0 wz--n- 925.82G 626.82G

  vg     1   9   0 wz--n-  48.21G   8.00M

```

Since my Desktop volume group "vg" is active and in use, I can't vgrename it.

Nor can I rename the laptop's "vg"

```

# vgrename sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb vg_laptop

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  WARNING: Duplicate VG name vg: sEgBkv-qUWS-GTLB-Qah0-CKol-liDB-0Qd3Sb (created here) takes precedence over aBD3UY-Y50Z-lwBY-aD35-q6Nm-biMH-ADVcSD

  Volume group "vg" still has active LVs

```

Is there any way to rename the laptop's vg 

Or must I unmount my desktop's {usr,var,opt,home,tmp,vartmp,portage,...}

then "vgchange -an"

Then edit an /etc/lvmtmp/lvm.conf so that I don't scan my desktop's drives:

```

filter = [ "a/loop0/", "r/.*/" ]

```

then scan my laptop's vol groups:

```

export LVM_SYSTEM_DIR=/etc/lvmtmp

vgs  --config 'global{activation=0}'

vgrename vg vg_laptop

vgrename bkup bkup_laptop

unset  LVM_SYSTEM_DIR

```

So far, dd_rescue has been running for 2 days and has copied 70g out of 100g toshiba disk.

When finished, I suppose I can go to single user mode and unmount my Desktop's vg,

unless someone knows of another way of mounting my laptop's lvm volumes.

(I'd like to see how my laptop's /dev/vg/home looks)Last edited by redwood on Fri Feb 06, 2009 10:17 pm; edited 1 time in total

----------

## salahx

vgrename allows you to specifiy the "old" volume group using its UUID instead of its name (which i've seen you tried).  You have to deactive the volume group before you can rename it, however.  Unfortunately, vgchange only accepts names. But there is a workaround: use dmsetup to manipulate the device mapper directly. Use "dmsetup remove" to remove the laptop vg's, then you can use vgrename.

----------

## redwood

I decided to rename my volume groups using my laptop instead of my desktop.

First I had to find a livecd with support for lvm and dd_rhelp.

Knoppix-4.0 didn't support lvm, so I tried new Knoppix-6.0 but it hung booting my laptop.

So I tried ArchLinux without luck. Then I tried various Gentoo livecd with boot option "dolvm"

but they all tried to mount my broken harddrive partitions and use my disk swap partition.

Finally, I booted a Sabayon LiveCD, which had lvm2 tools but did not automatically mount

any drives.

So I removed /etc/lvm/{archive/*, backup/*, cache/.cache}

and edited my laptop's /etc/lvm/lvm.conf 

```

filter = [ "a/loop?/", "r|/dev/nbd.*|", "r/.*/" ]

```

then I deactivated any volume groups: "vgchange -an"

then I setup my lvm partition on a loop device:

```

losetup -o 48257750016 /dev/loop2 Toshiba

```

and scanned it and renamed the volume group

```

pvs /dev/loop2

vgrename vg vg0

```

Now I can use the logical volumes from the image file on either my desktop or laptop without conflict.

----------

