||08-25-2009 09:48 AM
Install grub for a filesystem on sdb from a rescue system on sda
I boot a CentOS 5 image running on /dev/sda and I have a dormant CentOS 5 image on /dev/sdb that I need to install grub on.
I do the following sequence of commands to mount the other installation (I copied these mounts from the rescue CD).
mkdir -p /mnt/target
mount /dev/VolGroup00/LogVol00 /mnt/target
mount /dev/sdb1 /mnt/target/boot
mount /tmp/sysfs /mnt/target/sys -t sysfs
mount /tmp/proc /mnt/target/proc -t proc
mount /dev /mnt/target/dev -o bind
mount /dev/pts /mnt/target/dev/pts -t devpts
mount /selinux /mnt/target/selinux -t selinuxfs
I then chroot and install grub...
Filesystem type is ext2fs, partition type 0x83
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded.
Running "install /boot/grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
I then unmount all the target directories...
I then reboot with the target system now as sda. It just drops to a grub shell. I have no idea why. I can re-install grub from this shell, it reports success and then it still does the same thing next time I boot. If I install grub from a rescue CD then it works fine. However I don't what to do this from a rescue CD since I have to script the process (for a VM backup and disaster recovery system) and the CD requires manual intervention.
The grub.conf file is correct for a system booting off sda, after all, the install CD is able to get grub working.