Thursday 5 May 2016

grub rescue after fixing partition order

Windows 10 (from Windows 7) upgrade on my HP dv6tqe left it with partition table entries not in the disk order. Windows 10 itself took out ~800 MB from the end of the C drive to create a new Windows RE partition.

When I used fdisk (dv6tqe has MBR) to lisk partitions [fdisk -lu] the output showed included the following:

Partition table entries are not in disk order. 

Although it wasn't causing any problems, I decided to tidy it up.

Fix partition table entry order using fdisk (on MBR discs)
sudo fdisk /dev/sda
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): x (extra functionality)
f (for fix partition order)
r (return to main menu)
w (write table to disk and exit)

After this on rebooting grub threw me to the rescue prompt.

Code
error: file '/grub2/i386-pc/normal.mod' not found. Entering rescue mode .... grub rescue >

Because the partition table order had changed, grub could no longer locate the /boot partition

commands typed at grub rescue
# List partitions
grub rescue> ls
(hd0,msdos1)(hd0,msdos2)...
# After a bit of trial and error the following command listed out the contents of the grub folder, thus identifying the correct partition to use
grub rescue> ls (hd0,msdos5)/grub
# to view the existing values
grub rescue> set 

Next, set the partition for grub to use.

Code
set prefix=(hd0,msdos5)/grub set root=(hd0,msdos5) insmod normal normal

This should bring up the familiar grub menu. Boot into Linux and fix the grub installation as below.

Code
grub2-install /dev/sda grub2-install /dev/sda

References



https://www.howtoforge.com/tutorial/repair-linux-boot-with-grub-rescue/ 

No comments:

Post a Comment