How to recover a grub boot partition
Posted by on 2015-02-17 10:34:22:
The RedHat / CentOS way.
Title should be "recover grub boot loader really"!
Boot into recovery mode from the linux rescue cd.
Type:
chroot /mnt/sysimage - this will make your main / partition (currently mounted under /mnt/sysimage) the / partition.
Type mount and find which device is your hard disk. This could be sda or sdd etc. then below changing sda for that of your drive.
You can also list partitions with
fdisk -lor parted
Run
/sbin/grub-install --no-floppy /dev/sda = could be sda or sdb or sdc or sdd and so on (whichever disk is your primary boot HDD)
For other distros:
Boot from a rescue CD, being sure that the boot image you use matches the architecture of your installation (e.g. 32 or 64 bit).
Then, establish your various partition with
fdisk -land mount them accordingly.
For example, if you have a basic layout, and you have /dev/sda1 (boot) and /dev/sda2 (root or '/') then do as follows:
Firstly, mount the / (root) partition.
mount /dev/sda2 /mnt/backup
Then, mount the /boot like this:
mount /dev/sda1 /mnt/backup/boot
Now, type ls -la /mnt/backup/boot/ and you should see your kernel image(s) listed.
Next, mount the various system partitions, '/dev/', '/proc' and '/sys'.
root #mount -o bind /dev /mnt/backup/dev root #mount -t proc none /mnt/backup/proc root #mount -o bind /sys /mnt/backup/sys root #mount -o bind /tmp /mnt/backup/tmp
Note, it's not always necessary to mount '/tmp' but it can be useful sometimes.
The next step is to 'chroot' into your mounted partition.
chroot /mnt/backup /mnt/backup/bin/bash
Following this step, you should now have your existing installation mounted as if you had booted from it, and most command should work normally.
You can now rebuild grub.
/sbin/grub-install --no-floppy /dev/sda
/dev/sda could be sda or sdb or sdc or sdd and so on (whichever disk is your primary boot HDD)
Tags: Grub , Storage , Linux
Return to home page: Home