Scenario: You have a hard disk from one Linux computer, and you want the data off of it. So you attach it to another Linux machine. But, all hell breaks loose because both hard disks have the same Fedora default Logical Volume Management (LVM) configuration, same volume names, etc. so you can't mount them both at the same time. What to do?
This howto documents one possible method which worked for us, but may not necessarily be the best. For example purposes, it assumes that, to begin with, both host's LVM groups are named "VolGroup00", and that our approach is to rename the host's boot disk, leaving the secondary attached drive (the one we want to recover) untouched.
lvmand you will be in the Logical Volume Management shell. Then:
vgscanThe output will look something like this:
Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2Now:
vgrename VolGroup00 VolGroup99We have now renamed the boot device's volume group to something other than VolGroup00. Exit lvm.
mkdir -p /mnt/VolGroup99/LogVol00 mount -t ext3 /dev/VolGroup99/LogVol00 /mnt/VolGroup99/LogVol00
mkdir /mnt/hda1 mount /dev/hda1 /mnt/hda1Note that this assumes the usual, a single IDE hard disk. If you're unsure of which partition contains /boot, run
fdisk /dev/hda p (for print)The first, and smallest, partition with the asterisk in the Boot column is the one. Note the device name and mount that as noted above. E.g. if your disk is SCSI, it will probably be /dev/sda1.
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1 ... /dev/VolGroup00/LogVol01 swap swap defaults 0 0and change them to:
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1 ... /dev/VolGroup99/LogVol01 swap swap defaults 0 0NOTE: "Joe" writes: "in Step 5, I think you meant:
... and change them to: /dev/VolGroup99 ... ^^ this was 00He is probably right...I no longer remember! Govern yourself accordingly. :)
Then in /boot/grub/grub.conf, fine the line:
kernel /vmlinuz-2.6.19-1.2911.fc6 ro root=/dev/VolGroup00/LogVol00 rhgb quiet acpi=off
and change it to
kernel /vmlinuz-2.6.19-1.2911.fc6 ro root=/dev/VolGroup99/LogVol00 rhgb quiet acpi=off
Of course, your vmlinuz version and other kernel arguments may differ. rm /etc/lvm/.cache
cd /mnt/hda1 mkdir newinit cd newinit gunzip -c ../initrd-2.6.9-1.724_FC3.img | cpio -idmv # or whatever initrd version file you haveOnce that finishes, you've got an unpacked version of the initrd. Edit the "init" file, which is a nash script (NOT a normal bash shell script, so don't get cute with bash stuff). Find all instances of "VolGroup00" and change them to "VolGroup99". Save and exit.
Then, repackage up a new image. First rename the original one out of the way to save it so you can restore it later if need be. Then, still within the "newinit" directory, do:
find . | cpio --quiet -c -o > ../newinitrd cd .. # You are now in /boot, aka /mnt/hda1 gzip -9 < newinitrd > initrd-2.6.9-1.724_FC3.img # or whatever it was called before...EXACTLY
sync unmount /mnt/hda1 unmount /mnt/VolGroup99/LogVol00 syncExit the shell to reboot. If all goes well...your system should boot up normally.
lvm (to enter lvm shell) vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup99" using metadata type lvm2 Found volume group "VolGroup00" using metadata type lvm2Remember, 99 is your newly-renamed, main, boot drive. VolGroup00 is the secondary, to-be-recovered drive.
Still in the lvm shell, type:
vgchange --available y 2 logical volume(s) in volume group "VolGroup99" now active 2 logical volume(s) in volume group "VolGroup00" now activeExit lvm and do:
mkdir -p /mnt/VolGroup00/LogVol00 mount -t ext3 /dev/VolGroup00/LogVol00 /mnt/VolGroup00/LogVol00and your secondary disk's contents should now be available under that mountpoint.
References: