Temporarily disabling/uninstalling grub in a dual-boot setup and then restore grub to the state it was at the start

5,279

Okay, today I finally had some time and did this. Brace yourselves this one takes a while. BEFORE YOU EXECUTE ANY OF THESE COMMANDS, make sure you know if you have a UEFI or a BIOS system and if you have a GPT or an MBR partition table. Obviously, this comes with 0 warranty, this is just what worked for me, I used many StackOverflow and other forum answers. Sadly I'm only allowed to link 2.

Step 0: BACKUP BACKUP BACKUP. I used Reflect, its free, it does the job, there's plenty of other options. Get some large external HDD, put your files in the cloud (I can recommend Cryptomator if you're concerned about privacy. E.g. Google drive gives you 15 Gig for free.) Seriously, all kinds of stuff can go wrong and there's a real chance you might have to reinstall at least 1 OS.

Step 1: Uninstall/Overwrite GRUB.

For me, this one was what took the longest. Basically, what you want to do is just overwrite the MBR (I'm not the savviest with these technicalities. You'll want to check if you have a UEFI or a BIOS - I have a UEFI - and if your partition table is GPT or MBR. I have MBR for some reason, it's the older standard.) of GRUB to point directly to Windows, then you can install the update.

A description how to do this can be found here. I'd advise trying this out of Windows first, this one took me very long as my Windows didn't boot at all at this point for 2 hours or so. In the end, the startup fix did not work. I had to choose USB: not UEFI: in the BIOS and run a lot of commands in the prompt:

bootrec /fixmbr
bootrec /fixboot

fixboot failed for me with "element not found". Then I followed this article, especially (CAREFUL! CHANGE THE DRIVE LETTER TO THE CORRECT ONE FOR YOU) bcdboot C:\Windows /S C: Execute the bootrec stuff, set the partition as active, execute the startup help once and hopefully, your windows will boot now.

Once we achieved this status we can reboot windows a few times, install all the updates and be happy about our new secure system. Then we realize we want Linux back.

Step 2: Reinstall grub

For this, I used to boot an arch linux from my HDD. Here I had to do mv /dev/disk/by-label/MYLINUXLIVE /dev/disk/by-label/ARCH_ in order to get it to boot. Then I used sudo fdisk -l to find the Linux partition. Now you want to mount it and chroot into it sudo mount /dev/sdXY /mnt sudo arch-chroot Now we want to install grub, which will overwrite the MBR again. sudo grub-install --target=i386-pc --recheck /dev/sdUV grub-mkconfig -o /boot/grub/grub.cfg exit reboot

This hopefully will now boot into grub. Now for me, this didn't find windows at first, but this is easily fixed.

Step 3: Add the windows entry back to grub (optional)

Boot into your old arch/Linux installation, run os-probe, it will detect windows, and run sudo grub-update. Arch doesn't have grub-update by default, so here's the source code:

#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"

After this, everything is the same as before except the problematic update is installed and I lost a few nerves.

Share:
5,279

Related videos on Youtube

Gaze
Author by

Gaze

Updated on September 18, 2022

Comments

  • Gaze
    Gaze over 1 year

    I'm using a dual-boot setup with grub 2.02-beta2 which allows me to switch between Windows 7 and arch linux on a x64 desktop machine. These are both installed on my C: drive on the same physical HDD. (A common solution was to switch in the BIOS to boot from the windows HDD, this is not possible for me)

    Now Microsoft released a troublesome October 2016 Security update whose installation fails upon reboot when you use a GRUB bootloader. Thus I'm trying to achieve the following:

    • Somehow disable the GRUB bootloader so that my PC automatically boots into windows, without losing any Linux data (one partition on C and one partition on D)
    • Install all the updates, reboot a few times
    • Using a Live CD or similar, restore the previous configuration I had for GRUB, without data loss