Here is the case:
The hard disk containing your /boot partition has just died, you have a separate RAID1 array (using mdadm) with all the information on the array intact, but the system is unable to boot because all the files in /boot got lost.
Your best bet is to get the following iso onto a USB flash drive or CD:
http://sourceforge.net/p/ubuntu-secured/home/Home/
Ubuntu secure remix provides the following functionalities:
- Full Ubuntu DVD distro
- integrates Clean-Ubiquity: automatic backup of the MBRs and partition tables when installing Ubuntu, which is highly recommended for dual-boot Ubuntu-Windows (or MacOS)
- integrates OS-Uninstaller (tool to uninstall any Operating System from your PC)
- integrates Boot-Repair (tool to fix the PC boot)
the one highlighted in bold is what we are going to use to fix the boot partition.
With the ubuntu DVD and Boot-repair you will be able replace the missing kernels and initrds, reinstall any broken packages and get grub again onto the MBR, successfully restoring the computer or server to a bootable state.
Now, burn your iso to cd (I assume you know how to do this) or get into an USB drive like this:
dd if=/path/to/file.iso of=/dev/sdb
where /dev/sdb is your USB drive, you can use the mount command to double check this. If you make a mistake here (for example if you input /dev/sda and /dev/sda is your laptop hard drive) you will end up writing the iso to your hard drive and DESTROY all of your data. So please double-check this.
After you boot into the Ubuntu Secure Remix, first thing to do is chroot and then create a /boot directory (since the old one is lost). Chroot is a command that will mount the operating system stored on the hard drive so you are able to execute commands inside it. This is a very important step. To do this:
# means run with root or sudo
1. Create a mountpoint
# mkdir /mnt/mountpoint
2. Mount /dev and /dev/pts to chroot
# mount -o bind /dev /mnt/mountpoint/dev
# mount -o bind /dev/pts /mnt/mountpoint/dev/pts
3.Open bash in chroot
# chroot /mnt/mountpoint /bin/bash
4. create the /boot directory
#mkdir /boot
At this point, you are now inside your unbootable linux system with and empty /boot directory, now do:
sudo apt-get install linux-image-server
That command (on a debian/ubuntu based system) will pull the latest kernel image and install it, populating the /boot directory with some files (which are the kernel and initrd images). If you have a different distro do the same with your distro’s package manager.
Next open up Boot-repair from the GUI and follow the onscreen instructions to restore grub into the mbr. I won’t post them here because:
a) it varies from system to system and depends on how screwed the OS got
b) On screen instructions are easy to understand and get the job done
After Boot-repair finishes, exit your chrooted terminal (by typing exit at the terminal) and restart your system.
Everything should be in order now and the machine should boot without a problem. If it does not, feel free to leave a comment below and I will do my best to help you.
NOTE: This procedure was tested under a Software RAID using mdadm on Ubuntu Server 10.04.4 LTS, I haven’t tested this with any other RAID array configuration or distro, be it fake, firmware or hardware RAID.