Ubuntu – Dual booting Windows 7 and Ubuntu 19.04

19.04bootdual-bootgrub2windows 7

I'm not a beginner with creating a dual booting system, but I guess I have a lot to learn still because I have been struggling with the current system for days.

I started off with a Windows 7 system that occupied two physical disks. I took the second and made it into an Ubuntu system. Currently, it looks like this:

/dev/sda1     NTFS    (labeled as "system reserved")
/dev/sda2     NTFS    Windows 7
/dev/sda3     NTFS    (Data for Windows 7 system to access)

/dev/sdb1     FAT32   Mounted on /boot/efi (flags "boot" and "esp")
/dev/sdb3     Ext4    Mounted on /

(There was a /dev/sdb2, but I deleted it and merged it into
/dev/sdb3 with gparted.)

I installed Ubuntu 19.04 and it is working fine. But I cannot boot into Windows 7. I want to add Windows 7 to the grub menu or at least access it; I can't even do that now.

So, I've tried the following:

  • Run sudo update-grub.
  • Run sudo os-prober after mounting /dev/sda2.
  • Running boot-repair on the computer and also with a bootable
    live disk.
  • Running grub-customizer.

None of them work.

For boot-repair, I've tried several things such as "Reinstall GRUB" and
"Restore MBR". If I do the "Recommended repair", I get a "GPT detected. Please
create a BIOS-Boot partition (>1 MB, unformatted filesystem, …).
…Alternatively, you can retry after activating the [Separate
/boot/efi partition:] option." After running boot-repair for many
years on other systems, this is the first time I've seen this message.

With grub-customizer, it created these lines for /dev/sda2
(Chainloader):

set root='(hd0,2)'
search --no-floppy --fs-uuid --set XXX
drivemap -s (hd0) ${root}
chainloader +1

When I reboot, I get errors like "no such device: XXX", "can't find command drivemap", and "disk hd0,2 not found".

Of all the times I've gone through this problem with other computers, I guess this is the oldest I've had. (It has Windows 7, after all.) Likewise, the BIOS is old as well. So, that is stumping me. I'm also a bit concerned I've some how destroyed the (Windows) system. I tried the "Restore MBR" option of boot-repair and wrote the MBR to /dev/sda2 and I still couldn't boot into Windows — it goes to grub instead. (When I realised this, then I thought I need to ask others for help…this feels bad now.)

The Ubuntu side is a fresh install and if I need to somehow destroy that to undo a mistake I made in order to get it to dual boot, I'm fine with that.

Can anyone offer suggestions on what I should try? As I'm honestly guessing, I'm sure the answer is right in front of me but some suggestions on what I should try and perhaps the order would help.

Best Answer

Boot mode (legacy vs EFI) matters. Grub is not able to chainload a bootloader in a different boot mode, so to achieve a proper multi-boot, all OS's must be installed in the same boot mode. It seems to be a common mistake to install in the wrong boot mode.

From the little information in the question I couldn't be 100% sure, but it looked like your Windows is installed in legacy mode, while Ubuntu appeared to be installed in EFI mode.

You can solve this in different ways, one way is to reinstall Ubuntu in legacy mode. You have to make sure to boot the installer in legacy mode, that's all.

Another way is to reinstall only the bootloader (Grub). Just boot into your installed Ubuntu (in EFI-mode) and run

sudo apt update
sudo apt install grub-pc

This will remove grub-efi (the EFI version of Grub) and install grub-pc (the BIOS version of Grub). During installation you will be asked where to place the bootloader. This is interesting as you have multiple disks and you don't need to overwrite Windows bootloader which should reside in sda. So you should place Grub on sdb. In BIOS you will have to check the boot order then. Additional clean-up is not absolutely necessary but removing the line regarding /boot/efi from /etc/fstab makes sense, it's not needed anymore.

Another thing you should know:

If the disk where you want to place Grub uses GPT you need to create a small (2MB) partition with bios-boot flag and leave it unformatted (no file system). Grub's core.img will be placed there.

Related Question