How to reinstall a crashed boot partition
– Boot partition got crashed/corrupted or it’s contents deleted mistakenly.
– System is not booting up.
– Recover the data from backups without reinstalling the whole system.
1. Boot from Cent-OS installation disc (for example, CD #1 or DVD).
2.For CentOS-4 or CentOS-5 type “linux rescue” at the “boot:” prompt. For CentOS-6 pick “Rescue installed system” from the boot menu.
3. Mount the / partition of the system. On Cent-OS this is automatically done and the / is mounted on /mnt/sysimage. Otherwise just do (assuming the root partition is on /dev/sda2)
mount /dev/sda2 /mnt/sysimage
4. Chroot into the old root partition since that is where we actually want to make all the changes
5. If the filesystem labels got deleted up for some reason or they don’t agree with what is described in /etc/fstab we should fix that (Assuming the boot partition is /dev/sda1):
e2label /dev/sda1 /boot
6. Make sure the boot partition is mounted:
mount /dev/sda1 /boot
7. Mount the CD-ROM we used to boot the machine
mount -o loop,ro /dev/hdc /media/cdrom
8. Now we need to install the relevant rpms. Make sure you pick the correct kernel for your configuration system.
cd /media/cdrom/CentOS (this will vary depending on the distro)
rpm -ivh –force kernel-2.6.18-164.el5.i686.rpm
rpm -Uvh –force grub-0.97-13.5.i386.rpm
rpm -Uvh –force redhat-logos-4.9.99-11.el5.centos.noarch.rpm
9. Install GRUB:
grub-install /dev/sda1 (or whichever partition boot is mounted on)
10. If /boot/grub/grub.conf is also lost, you need to create it manually.
kernel /vmlinuz-6.18-164.el5 ro root=/dev/VolGroup00/LogVol00
11. Lastly make a soft link to grub.conf:
ln -s grub.conf menu.lst
Reboot the system and if everything goes well it should boot normally. Run immediately a yum upgrade incase you had to install an older version of the kernel from the CD-ROM.
That’s it. Hope this will help you to resolve the issue.