LVM (volume manager) and virtual disks

:eek:
Hi guys,

I'm pulling my hair out over this one. I am trying to set up a virtual server environment. ( I am using VirtualBox, but I think this is irrelevant to this problem.) I have downloaded a pre-packaged Linux virtual disk, with which I have successfully started a virtual instance of a Linux server. Now, my goal is (nevermind why for now) to use one virtual machine to modify the root disk of another (which is turned off during this process). Here are the steps I take:

  1. Create and test a virtual linux server (as noted above), called vs-A
  2. Clone the disk used by vs-A (while vs-A is stopped). Let's call the first disk vhd-A1 and the new clone, vhd-A2.
  3. Create a new virtual linux server, vs-B which uses vhd-A2. This works. Power it off.
  4. Now tell vs-A to use vhd-A1 at /dev/hda (as usual) and to use vhd-A2 as /dev/hdb.
  5. Start vs-A

So now, vs-A is running with /dev/hda and /dev/hdb. But trying to do anything with hdb doesn't seem to work. I'd like to know why and to try to remedy that.

# dumpe2fs /dev/hdb2
dumpe2fs 1.39 (29-May-2006)
dumpe2fs: Bad magic number in super-block while trying to open /dev/hdb2
[expected -- it's "encapsulated" in an LVM]

# pvs -a
  Found duplicate PV pLPlWtPxq1A8JBAfSqrDWdhYZM2PpVr0: using /dev/hdb2 not /dev/hda2
  PV                       VG         Fmt  Attr PSize  PFree
  /dev/VolGroup00/LogVol01                 --       0     0
  /dev/hda1                                --       0     0
  /dev/hdb1                                --       0     0
  /dev/hdb2                VolGroup00 lvm2 a-   19.88G    0
  /dev/hdb2                VolGroup00 lvm2 a-   19.88G    0
<other output>

# lvscan
  Found duplicate PV pLPlWtPxq1A8JBAfSqrDWdhYZM2PpVr0: using /dev/hdb2 not /dev/hda2
  ACTIVE            '/dev/VolGroup00/LogVol00' [18.88 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [1.00 GB] inherit


# pvscan
  Found duplicate PV pLPlWtPxq1A8JBAfSqrDWdhYZM2PpVr0: using /dev/hdb2 not /dev/hda2
  PV /dev/hdb2   VG VolGroup00   lvm2 [19.88 GB / 0    free]
  Total: 1 [19.88 GB] / in use: 1 [19.88 GB] / in no VG: 0 [0   ]

# pvs
  Found duplicate PV pLPlWtPxq1A8JBAfSqrDWdhYZM2PpVr0: using /dev/hdb2 not /dev/hda2
  PV         VG         Fmt  Attr PSize  PFree
  /dev/hdb2  VolGroup00 lvm2 a-   19.88G    0

# :Fine, I'll just overwrite the thing!
#  mke2fs -b 4096 -O dir_index,spare_super /dev/hdb2
mke2fs 1.39 (29-May-2006)
/dev/hdb2 is apparently in use by the system; will not make a filesystem here!

Is there a tool or a technique to deal with this situation? Is there a way to rename the uuid? If so, how do I specify that I want the uuid of /dev/hdb changed? Is there a way to associate an existing physical partition to a new group? How do admins do disaster recovery with LVM in these kinds of situations?

what is your ultimate goal for this disk. Do you care about the data on the disk? If so, have you thought about doing a vgchange and vgscan? It might even be better to, if you can, use the original machine to export the vg information and then import it on the other machine

well, preferably, i would like to keep it. the idea is to clone the disk, make some changes to it (using a "master" vm), and then use it in another vm.

I didn't see anything meaningful that I could with vgchange.

You should be able to take the disk with the LVM info on it, do a vgscan on it and import the VG information. You may need to do a vgimport

Thanks, mark54g. I read up on vgimport, and this didn't seem to be what I needed. Anyway, I decided to approach my problem differently: by using a Linux-recovery-DVD/ISO from which to boot the VM. This works and didn't cause configuration headaches.