PDA

View Full Version : Force Grub to load correct LVM volume



ni_boy
15th May 2008, 09:12 AM
Hi,

I'm trying to build a system based on a two HDs.
First HD (sda) has 2 partitions, sda1 = boot, sda2 has LVM.
Root is on (sda1) /dev/VolGroup00/LogVol00

I use dd to clone sda to sdb.

The idea behind this is that dd dreates a duplicate disk on the system. In event of failure & me not being around, anyone here can swap sdb to sda & the system goes live.

I've tested the process sbd dropped in as sda, looks exactly the same & boots fine.

The problem I am having is that the system booted a couple of days ago either loaded the sdb disk OR loaded /dev/VolGroup00/LogVol00 from the sdb disk as after I ran the sda to sdb clone I lost about a weeks coding (I'm now doing an off system backup as well).

I'll output my grub.conf & other details below but what I'm looking for is a way to ensure that the system will always & ONLY load the sda partitions & volumes.

------------------
System Version
------------------

Linux version 2.6.21-1.3194.fc7 (kojibuilder@xenbuilder4.fedora.phx.redhat.com) (gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)) #1 SMP Wed May 23 22:35:01 EDT 2007

-----------
grub.conf
-----------

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.21-1.3194.fc7)
root (hd0,0)
kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.21-1.3194.fc7.img

-------------
device.map
-------------

# this device map was generated by anaconda
(hd0) /dev/sda
(hd1) /dev/sdb

--------
fdisk -l (sdb currently blank - don't want this happenning again)
--------
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 19457 156183930 8e Linux LVM

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


Thanks in advance for any assistance.

ni_boy

algej
15th May 2008, 10:30 PM
You cannot make this work. When you used dd to copy sda to sdb, not only did you end up with 2 different devices containing the same exact volume group, but even worse, they have the same UUID. There is simply no way for the system, which is trying to reference /dev/VolGroup00/LogVol00, to figure out which one you meant.

I'd recommend that you instead look into mirroring the disks, rather than trying to periodically dd one to the other. If they are IDE drives, invest in a separate controller for /dev/sdb. The last thing you want is a failed IDE drive corrupting the other one. Software RAID-1 has great performance (no parity calculations), works with both your /boot partition and your LVM partition, and the mdadm tool is reasonably easy to figure out and use.

ni_boy
15th May 2008, 10:40 PM
thanks algej, makes sense. I don't suppose you can point me to a "how to convert current system to RAID" page. I've used software RAID before but not converted. Any pointers appreciated.

algej
16th May 2008, 12:43 AM
Try these:

The Software RAID howto (http://tldp.org/HOWTO/Software-RAID-HOWTO.html)
How to migrate LVM to LVM on RAID-1 (http://www.trilug.org/pipermail/trilug/Week-of-Mon-20060213/040520.html)
Migrating to RAID-1 mirror on Sarge (http://www.debian-administration.org/articles/238)

After you recover from the massive headache reading all of this will give you, I'd suggest putting together a plan to get there in stages:

1. Set up /dev/sdb as a degraded mirror. Make sure the system sees it properly.

2. Get /boot copied over to the mirror.

3. Set up a new LVM volume group on the mirror and copy your existing root over to it. (DON'T just pvmove it - you really don't want to cross points of no return - migrating to RAID-1 for the first time is an ugly process.) Fix up the mirror's copy of /boot/grub/menu.lst to point to the root filesystem on the new volume group. Don't forget to create a swap LV if you had one before.

4. Boot the degraded mirror and make sure it works. (at this point you still haven't messed with /dev/sda, so it still works in case you screwed something up on the mirror)

5. Lastly, add /dev/sda into your mirror.

If you want to try this, feel free to post back with questions.

ni_boy
16th May 2008, 10:18 AM
Thanks again. Got me started & found out what I needed to look for. So now have found a howtoforge page on this & am using a combination of

http://www.howtoforge.com/set-up-raid1-on-a-running-lvm-system-debian-etch

plus

http://www.howtoforge.com/software-raid1-grub-boot-fedora-8

The first site gives the LVM details & the second site has the commands & syntaxes for fedora specific stuff (fstab, mtab, ramdisk, etc)

Going OK so far & currently moving the data from sda2 to md1 using pvmove. Fingers crossed for the rest....

If it all works I actually need to do it again so will capture & post details.

ni_boy
19th May 2008, 08:18 AM
This worked perfectly.

I know I said I'd post the process but there's so little to change it doesn't make sense. Just refer to the fedora page as suggested above.

Thanks for your help algej