Recovering a Linux server on different disk partitions

We lost a disk in the RAID 5 array on one our Dell 2550 Linux servers today. Usually this is no big deal, just replace the disk and the array rebuilds right? Not quite – for some unexplained reason the array was “inconsistent” and we had to destroy and rebuild the container. No big deal, we have backups so it should just be a matter of reinstalling the OS, installing our backup client software (NetWorker) and doing a restore allowing the restore to overwrite files. This should be a no-brainer. But, what if the disk was not partitioned on the new install the same as the original system? Once the restore completed we have now overwritten /boot/grub/grub.conf with the file that matches the original install – what if the boot partition is no longer at the same location?

After the restore the system administrator attempted to reboot, and was informed that the system could not find the boot file. Now what? No worries, simply do the following:

  • Insert the install CD and boot from it
  • Hit F5, and then enter Linux rescue
  • Select OK to search for Linux installs
  • Select continue to mount the install disk found

Once you get to the command prompt do the following:

  • cd /mnt/sysimage/boot/grub
  • TERM=VT100;export TERM
  • vi grub.conf

You should see a file that looks like this:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,1)
# kernel /boot/vmlinuz-version ro root=/dev/sda2
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Red Hat Enterprise Linux ES (2.4.21-40.EL)
root (hd0,0)
kernel /boot/vmlinuz-2.4.21-40.EL ro root=LABEL=/
initrd /boot/initrd-2.4.21-40.EL.img
title Red Hat Enterprise Linux ES (2.4.21-20.EL)
root (hd0,0)
kernel /boot/vmlinuz-2.4.21-20.EL ro root=LABEL=/
initrd /boot/initrd-2.4.21-20.EL.img

The bolded entries above are the ones of interest. hd0 is obviously the first hard drive, and the 0 after the comma is the partition on that disk. In our case the original system had the boot partition located on partition 1 but after the rebuild I changed it as indicated here to what you see 0. If you aren’t sure which partition is which you should be able to enter command line mode in grub after your boot fails by entering “c”. Then by entering “geometry (hd0)” which should display something like this:

grub> geometry (hd0)
drive 0×80: C/H/S = 6637/255/63, The number of sectors = 106633728, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0×83
Partition num: 1, Filesystem type is ext2fs, partition type 0×83
Partition num: 2, Filesystem type is ext2fs, partition type 0×83
Partition num: 4, Filesystem type is ext2fs, partition type 0×83
Partition num: 5, Filesystem type is ext2fs, partition type 0×83
Partition num: 6, Filesystem type unknown, partition type 0×82
Partition num: 7, Filesystem type is ext2fs, partition type 0×83 grub>

Good information, but which one is /boot? Try entering the below and you will get your answer:

grub> find /boot/grub/grub.conf
(hd0,0)

Partition 0 is /boot on this system – your mileage may vary :)

Leave a Response