Adding Windows 10 to Grub

7,470

Solution 1

This is how I "solved" the problem, but from the comments, there does appear to be an underlying issue with the way that Windows decided to install itself (if the fact that it nicely put the boot partition on a different disc wasn't obvious enough).

As i mentioned, in my question when I hit Esc and then typed exit the machine booted to Windows 10. As a result I added to following to the 40_custom file:

menuentry "Exit to Windows 10"{
    exit
}

I then ran update-grub. When I select the option, this then has grub "boot" to Windows.

Solution 2

You should convert your Windows disk (sdb) to a GPT format. Here, Windows is using an MBR disk, which as it is, needs to run in Legacy BIOS. Ubuntu is running in your M.2 drive (nvme0n1) in a GPT format in UEFI mode (L.308 suggests this). UEFI is like the modern equivalent of the old BIOS system and has replaced it, but you can still switch to Legacy BIOS, except Windows will not support a computer running in UEFI mode with an MBR disk, which is the case here.

To convert your green SSD drive to GPT format is easy enough in Ubuntu, using Gparted. Except it will wipe everything on that drive so you would need to re-install Windows. You'd lose any data files on that disk too. Alternatively there is some free software, by EaseUs Partition Master which claims it can convert without loss of any files. I haven't used it so I cannot confirm whether it works OK, but it would save a lot of time and trouble if it does.

There's also the issue of your Windows MSR partition residing on sda. Why it's not on your main Windows sdb disk, I don't know, but for the time being I'd leave it where it is, but you will probably need to convert sda also to make everything UEFI compatible across the board. Just make sure you back-up all data files residing on sda/sdb first before converting said disks to GPT.

Share:
7,470

Related videos on Youtube

Larnu
Author by

Larnu

Larnu not Lamu. "Database Administrator" for a small Insurance Broker in England. I use the quotes as, being a small business, although my role is called Database Administrator, you often need to be a jack of all trades for small companies. As a result I have exposure to Network Administration, Web Development, and some server maintenance. So although I'm not trained I've had to assist enough times to know what I'm looking for or at (which greatly helps when a problem isn't SQL Server based). SQL Server enthusiast, however, little to no experience on other RDBMSs. Linux (Ubuntu) daily driver. I have some VB.Net experience, basic Python knowledge and enjoy to dabble in PoSH and Bash. I can read C#, it is a .Net language after all, but I'm hopeless at writing it; for some reason it's always escaped my grasp. I can't even blame it on the compulsory semi-colons as (one day) they'll be compulsory in T-SQL too (bring it on SQL Server 2037!). You can find articles I've written on my website, as well at on SQL Server Central. A favourite subject of mine is dynamic SQL, along with making sure that you are safe (from injection) when using it and SQL Server on Linux.

Updated on September 18, 2022

Comments

  • Larnu
    Larnu over 1 year

    I've had a look at a few other questions here (such as GRUB does not detect Windows), however, many of the options that have been voted up don't work.

    Currently my 40_custom file looks like the below (after a few different attempts):

    #8AEC5322EC5307B9
    menuentry "Windows 10" --class windows --class os {
       insmod ntfs
       search --no-floppy --set=root --fs-uuid 88F44DC9F44DB9E8
       #chainloader +1
       ntldr /bootmgr
    }
    

    When using this this I get the error cannot find command ntldr. if i comment out the above and change to chainloader +1 i get the error invalid efi file path.

    I suspect the problem is that when I installed Windows 10, it was "kind" enough to use a different storage device to one I installed Windows on for the System Reserved location. I won't lie, I wasn't frilled at it's choice, but nevermind. As a result the boot files are on /dev/sda1 (with the ID 88F44DC9F44DB9E8) and Windows 10 itself is on /dev/sdb1. Ubuntu is installed on a nvme device.

    os-prober doesn't detect Windows 10 (yes, both the partitions are mounted in ubuntu when I run it) and update-grub doesn't detect it either.

    I can still boot to Windows 10 at least, however, to do it I need to hit Esc in grub and then type exit in the command line. I'll then be greeted with the Windows 10 logo.

    Anyone any ideas here? I'm guessing I need to use a command like set root='(hd0,1)', but I'm honestly not sure which values need to go in for the parameters.

    PasteBin link for boot-repair logs.

    Relevant boot-repair section:

    =================== Suggested repair
    The default repair of the Boot-Repair utility would purge (in order to unsign) and reinstall the grub2 of nvme0n1p2 into the MBRs of all disks (except live-disks and removable disks without OS).
    Grub-efi would not be selected by default because: no-win-efi
    Additional repair would be performed: unhide-bootmenu-10s   fix-windows-boot
    
    
    =================== Blockers in case of suggested repair
    GPT detected. Please create a BIOS-Boot partition (>1MB, unformatted filesystem, bios_grub flag). This can be performed via tools such as Gparted. Then try again.
    Alternatively, you can retry after activating the [Separate /boot/efi partition:] option.
    
    
    =================== Advice in case of suggested repair
    EFI detected. You may want to retry after activating the [Separate /boot/efi partition:] option.
    Do you want to continue?
    
    
    =================== Final advice in case of suggested repair
    Please do not forget to make your BIOS boot on nvme0n1 (WDS500G2X0C-00L350) disk!
    
    
    =================== User settings
    The settings chosen by the user will not act on the boot.
    
    • WinEunuuchs2Unix
      WinEunuuchs2Unix almost 5 years
      Install and run boot-repair: askubuntu.com/questions/1104855/…
    • Larnu
      Larnu almost 5 years
      Will that have an adverse effects on the Ubuntu install? What does the above actually do?
    • oldfred
      oldfred almost 5 years
      We want the report, not any fixes. Just post link to the Summary report it gives. Boot-Repair may suggest fixes, but until reviewed do not run any. Almost all fixes are for Ubuntu as most Windows fixes need your Windows repair flash drive.
    • WinEunuuchs2Unix
      WinEunuuchs2Unix almost 5 years
      As @oldfred alludes you can run boot-repair to do a report only with no fixes. Run this option. I'm hoping the report will tell us why Windows 10 is not being added to grub menu. The report will also list the fixes it would perform if the option to fix grub (and other issues) was chosen.
    • Larnu
      Larnu almost 5 years
      Thanks both. @oldfred , you can find the logs on PasteBin
    • WinEunuuchs2Unix
      WinEunuuchs2Unix almost 5 years
      I've updated your question with the relevant boot-repair recommendations. CC: @oldfred (a little above my paygrade :))
    • oldfred
      oldfred almost 5 years
      Report does not show NVMe drives yet, as completely as SATA drives. You show no Windows UEFI boot entry and sda looks like it was converted from gpt to MBR. Windows only boots from MBR with BIOS, and boot partition is on sda. But it looks like install is on sdb. Cannot tell what is on NVMe drive., possibly UEFI, but no UEFI entry.You booted Boot-Repair in BIOS mode, not UEFI mode. From Windows does it say if UEFI or BIOS (not sure how to ask in Windows). Perhaps: rodsbooks.com/refind/bootmode.html#windows
    • Larnu
      Larnu almost 5 years
      I'm afraid I really don't follow what you're saying there, @oldfred .
    • oldfred
      oldfred almost 5 years
      I think you have Windows in BIOS boot mode & Ubuntu in UEFI boot mode. They are not compatible. Once you start booting in one mode you cannot change, or grub can only boot other installs in same boot mode. Wanted to confirm if Windows is installed in the now 35 year old BIOS/MBR configuration, even though Microsoft has required vendors to install in UEFI/gpt since Windows 8 released in 2012. Ability to allow BIOS installs was for large users, who wanted all systems the same.
    • Larnu
      Larnu almost 5 years
      Windows installed however it wanted to install, @oldfred . I'm afraid this type of thing is miles away from my expertise, and why I'm asking how to get things working here.
    • oldfred
      oldfred almost 5 years
      If Windows is BIOS & Ubuntu UEFI, then you can only dual boot from UEFI boot menu. If you really want the old BIOS you can convert Ubuntu to BIOS by reinstalling grub-pc. But if on gpt drive must have a 1 or 2MB unformatted partition with bios_grub flag for grub to install correctly. Or you can reinstall Windows in UEFI boot mode. Both Windows & Ubuntu install in the mode UEFI or BIOS that you use to boot install media.
  • Larnu
    Larnu almost 5 years
    Reinstalling Windows is something i heavily want to avoid. Unfortunately internet speeds are terrible here, so to redown updates would mean i'd lose the best of a day to get things back to where they were. I have, however, managed a "work around".
  • Larnu
    Larnu almost 5 years
    From my question "os-prober doesn't detect Windows 10 (yes, both the partitions are mounted in ubuntu when I run it) and update-grub doesn't detect it either."