Windows 10 upgrade led to grub rescue

My computer came with Windows 8 pre-installed so I shrunk the Windows partition to make room for Ubuntu. That is how it worked for the last year. After the second reboot in Windows 10 upgrade the computer did not boot any more. GRUB only displayed a grub rescue command prompt. I found out later that the problem occurred because Windows somehow changed the partition scheme. The boot partition (containing normal GRUB data) was no longer where GRUB expected it. I don't know how and why this happened.

The first thing that you can do in the rescue mode is to see the partitions with the ls command. Mine were:

  • (hd0,gpt1),
  • (hd0,gpt2),
  • etc.

Try to find out which partition is your boot partition. There is no Tab completion, you have to type it out completely. I tried the following commands until I found the right partition:

ls (hd0,gpt1)/
ls (hd0,gpt1)/boot
ls (hd0,gpt2)/

etc.

Then type set in the same prompt. It will display where GRUB looks for its files. In my case (hd0,gpt6) has moved to (hd0,gpt7). The set command displayed:

prefix=(hd0,gpt6)/boot/grub
root=hd0,gpt6

To get back into normal GRUB, start by changing the prefix setting to point to the right partition. In my case the command was:

set prefix=(hd0,gpt7)/boot/grub

Then you can switch from rescue to normal mode:

insmod normal
normal

One could also have fixed the root setting with:

set root=(hd0,gpt7)

But this is not strictly necessary, as it doesn't matter for Windows chain-load entries. Once in the normal GRUB menu, you can boot Windows and finish your Windows upgrade. The problem is that you have to tell grub rescue about the right partitions on every reboot. That is how I did it. I left the problem of GRUB for later because I was not sure whether Windows would do some more changes to the partitions or boot.

When Windows finished I started to solve GRUB problems. Press e to edit boot options for Ubuntu. I changed all (hd0,gpt6) to (hd0,gpt7) and Ubuntu booted.

However, I use encrypted partition and cryptswap. At the boot Ubuntu asked me for the passphrase. Fortunately I saved it at the installation of Ubuntu and entered it at the boot. Ubuntu booted without problems.

I then corrected the /boot/grub/grub.cfg file where I replaced (hd0,gpt6) with (hd0,gpt7) and performed:

sudo grub-install

At that point the only remaining issue was the encryption. Since the root Ubuntu partition number was increased by one (7 instead of 6), the swap partition suffered a similar change. I had to change the /etc/crypttab file to point to /dev/sda8 instead of /dev/sda7.

I am using only two partitions for Ubuntu (root and swap). If other operating systems coexisting with Windows use more partitions there might be more changes required. Especially if partitions are mounted according to their numbers and not by their UUIDs. Take a look at your /etc/fstab. If the partitions are identified by UUID there should be no problems. But if there are /dev/... lines the number should be corrected if these partitions had been renumbered.


Installing windows (or upgrading it) alongside linux can be problematic.

Try this: https://help.ubuntu.com/community/Boot-Repair



I used it to fix a problem after I installed the Windows 10 tech preview, and it worked. Basically, what it does is reinstall grub to work with all currently installed operating systems. Make sure to tell it to install grub to your linux partition (sd#).

Good luck!