7

After installing the Windows 10 upgrade on my laptop, it ruined the grub boot manager, and I could only boot in windows 10. I fixed the boot manager using a live cd with the boot-repair tool, but it only recognized the Ubuntu partition, and not the Windows one.

So I edited the /etc/grub.d/40_custom file and added the following contents:

menuentry "Windows 10" {
    set root='(hd0,3)'
    chainloader +1
}

After running sudo update-grub2, I got an entry in the boot menu, but the partition does not load. It gives the following error:

Error: Invalid signature.

enter image description here

Does anybody know how one can overcome this error?

My most recent boot-repair dump is here: http://paste.ubuntu.com/11965327/, and the partition I want to boot is this one:

sda4: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows 8/2012: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /bootmgr /Windows/System32/winload.exe
  • @Fabby: That's interesting. I would rather not mess up my ubuntu partition since it's the one use primarily. I am now downloading the windows 10 image from microsoft, and I will try to install it as non-UEFI if it has the option. – user000001 Jul 30 '15 at 11:26
  • Comment deleted and converted to an answer... Please leave future comments down under... ;-) – Fabby Jul 30 '15 at 11:27

3 Answers3

9

There are some peculiarities about your installation:

  • Your computer has two Windows Recovery Environment partitions, /dev/sda1 and /dev/sda5. My guess is one is from your previous Windows installation and the other is for the new installation, but I can't be positive of that. I doubt if this duplication is causing you any problems per se; I mention it simply because it's a sign of a history of changes to the machine, and such changes may be both the cause of problems and make it difficult to figure out what's wrong.
  • Your EFI System Partition (ESP) is /dev/sda4. This is perfectly legal, but is unusual; the ESP is normally /dev/sda1 or /dev/sda2. The ESP holds EFI-mode boot loaders and related files. My hunch is that the ESP was created late in the machine's history -- perhaps it was Ubuntu-only at one point and then you installed Windows, which created the ESP in this unusual location.
  • The Boot Info Script output doesn't identify any EFI boot loaders on the ESP. My suspicion is that they do exist, but the script has omitted these entries. (I've seen this happen from time to time.) OTOH, if those files are missing, then it means that Windows has failed to install its boot loader. The same may be true of Ubuntu, too; but see below....
  • Your disk uses the GUID Partition Table (GPT), which means that Windows will install to and boot from this disk only in EFI mode; but there's evidence of a BIOS-mode installation of GRUB, the standard Ubuntu boot loader. Such a mish-mash means that you'd not be able to boot Windows from a BIOS-mode GRUB on this computer. It could be you've also got an EFI-mode GRUB and had been booting that way; or maybe you had been switching between OSes by using the computer's built-in boot manager (typically accessed by hitting Esc, Enter, or a function key at start time).

At this point, your best bet is to install an EFI-mode boot loader for Linux. There are two ways to do this that are relatively safe and easy. Both work best if you first enter your firmware and completely disable any option to boot using BIOS, CSM, or legacy mode. (Those are three terms for the same thing.) Sometimes these options are phrased the other way -- you must enable EFI or UEFI support. With that done, do one of two things:

  • Method 1: Boot your Ubuntu install disk, ensure you've booted in EFI mode by looking for the /sys/firmware/efi directory (if it's present, you've booted in EFI mode), install the boot-repair package, and run it. This should repair your installation by installing an EFI version of GRUB. This usually works, but occasionally it doesn't. I realize you've already run Boot Repair, but my suspicion is that you ran it in BIOS mode, which of course means it would install the BIOS-mode GRUB, which will be useless for booting Windows.
  • Method 2: If you haven't done so already, disable Secure Boot in your firmware. You can then download and prepare a boot medium from the CD-R or USB flash drive version of my rEFInd boot manager. Boot to it; it should show you a menu with at least one option for each of Windows and Ubuntu. Test these to be sure you can boot both OSes, then boot Ubuntu. At this point, you can install the rEFInd Debian package or PPA. (Alternatively, you could install the EFI version of GRUB.) You may be able to re-enable Secure Boot at this point, but you may need to jump through some extra hoops to get it to work.

There should be no need to re-install Ubuntu, and probably not to re-install Windows. BIOS-mode and EFI-mode installations of Ubuntu are identical except for the boot loader (and related partitions -- but you've got the partitions to handle both modes).

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • In the meantime, the situation has deteriorated a bit... I tried re-installing windows from an image, and it deleted my former windows partition (i.e. /dev/sda4). I also switched to UEFI using the instructions from this answer. I suspect that Boot Repair doesn't find the windows partition because it's been deleted, but I will try to install a fresh copy of windows tomorrow, when I will have a second PC in case the installation screws up the MBR again. Now I am playing a bit with testdisk in case I can recover the windows installation. – user000001 Jul 30 '15 at 18:44
  • BTW I tried boot-repair again and got this warning – user000001 Jul 30 '15 at 18:46
  • /dev/sda4 was not your Windows partition; as I stated, it was your ESP -- what Boot Repair calls the "EFI partition." With it gone, so is your Windows boot loader. At this point, you can either try recovering the ESP with gdisk or parted (but do not try to create a filesystem on it or use GParted); or you can back up your personal data, delete all the partitions, and install everything from scratch. – Rod Smith Jul 30 '15 at 19:12
  • Why everything? Ubuntu is up and running just fine... I guess I'll sleep over it and see what can be done from the office tomorrow morning. I don't really mind loosing my windows installation, just used it for word, but I was hoping it would be possible to install a fresh copy without destroying my Linux setup. – user000001 Jul 30 '15 at 19:34
  • Sorry, I got confused and thought nothing was booting. If you have no ESP, though, Ubuntu cannot be booting in EFI mode, so you'll need to create an ESP and install an EFI-mode boot loader in it. If you can recover your earlier ESP, then that's the simpler solution. – Rod Smith Jul 30 '15 at 19:45
  • @user000001: If in doubt between listening to me or to Rod Smith, listen to him! He's our local guru about everything hard disks. (Rod: upvoted your A!) – Fabby Jul 30 '15 at 20:22
  • So now I installed windows 10 again, and then ran a boot-repair from a live ubuntu USB (log file here: http://paste.ubuntu.com/11972279/). The only problem at this point is the Windows Boot Manager loads by default, so I can only access Ubuntu by pressing F9 before windows loads, which gives me the option to select Ubuntu. I would prefer to have Ubuntu start by default, but c'est la vie, I guess... (cc @Fabby) – user000001 Jul 31 '15 at 10:39
  • @user000001 Looks much better! :-) Ifs the [F9] key a UEFI key? If yes, you need to go into your vendor's UEFI menu and change the default to Ubuntu there... (unfortunately, every UEFI system is different) Rod will tell you whether and existing UEFI partition is upgradeable to rEFInd, which is a universal standard, not linked to any vendor... – Fabby Jul 31 '15 at 12:50
  • 2
    In theory, typing sudo efibootmgr -o 0001,0002 should get your system to boot GRUB by default. In practice, some EFIs are broken and this won't work. Sometimes this procedure fixes the problem, but other times you need an ugly hack, as described on this page of mine. – Rod Smith Jul 31 '15 at 16:42
  • 1
    @RodSmith Yup, the solution in your first link solved it! Now both OSs are working properly, using grub as the bootloader. You are a genious :) – user000001 Aug 01 '15 at 11:02
  • +1 - I've been running a debian based distro for 1.5 years. Never had issues with the win10 dual boot setup and grub as a bootmanager. I know it has to be a linux issue as I booted linux the day before. I guess a grub-update, that switched itself from EFI to BIOS mode, so even "os-prober" did not list win10 anymore. Adding it manually resulted in "invalid signature". 3 days reading and trying forward I found this. Started boot-repair from bootable usbdrive selected EFI/ESP and installed new grub to linux partition. Reboot. Happy end. – JackLeEmmerdeur May 26 '19 at 19:56
1

As an alternative to have dual boot setup, you can try setting up Grub2Win, which is an implementation of GRUB installed from Windows and has UEFI support. Note that Grub2Win does not integrate with existing GRUB installation, it creates its own.

Once installed it would detect your UEFI boot option for Windows.

It may detect your Linux partition automatically, if it doesn't you can add the menu entry manually to C:\grub2\grub.cfg, you can grab menuentry from your existing grub.cfg in Linux (usually located at /boot/grub/grub.cfg), looks similar to this:

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os --class icon-linux {
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt6'
    search --no-floppy --fs-uuid --set=root ###################
    linux   /boot/vmlinuz-5.4.0-48-generic root=UUID=################### ro  quiet splash $vt_handoff
    initrd  /boot/initrd.img-5.4.0-48-generic
}

Note that instead of ###### above, you should use your Linux partition UUID, and should use the real boot image names installed in your /boot directory.

This enabled me to have Windows 10 + Ubuntu 20.04 dual boot setup successfully.

1

From the output of your boot-repair command, it looks like you have an UEFI system…

However, Ubuntu is installed in non-UEFI mode, and Windows is installed in UEFI mode so only one of the two is going to work at a time without changing the boot parameters…

The best you can do is: re-install Windows 10 in non-UEFI mode or reinstall Ubuntu in UEFI mode depending on which you use most.

A.B.
  • 90,397
Fabby
  • 34,259
  • I still find it a bit strange that it changed the boot method though, since it was merely an upgrade and not a fresh install... – user000001 Jul 30 '15 at 11:33
  • I did a fresh install and didn't have that problem... (and M$ questions are off-topic here anyway...) – Fabby Jul 30 '15 at 11:45