4

I've gone through the usual steps for adding Windows to the bootloader options by modifying 40_custom and adding the following:

menuentry "Windows 10" {
     insmod part_gpt
     insmod chain
     set root='(hd0,msdos2)'
     chainloader +1
     }

However, when I select Windows in the bootloader, it says "Error: invalid signature. Press any key to continue". I don't know why I'm getting this error. How can I fix it? EDIT: It says there are syntax errors here but I can't see any. if [ "${grub_platform}" == "pc" ]; then menuentry "Microsoft Windows Vista/7/8/8.1/10 BIOS/MBR" { insmod part_msdos insmod ntfs insmod search_fs_uuid insmod ntldr
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 XXXXXXXXXXXXXXXX ntldr /bootmgr } fi

EDIT2: Output of sudo fdisk -l

~$ sudo fdisk -l
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x71b1e4fb

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1              63     80324     80262  39.2M de Dell Utility
/dev/sda2  *    223580160 286285823  62705664  29.9G 83 Linux
/dev/sda3        30801920 223580159 192778240  91.9G  7 HPFS/NTFS/exFAT
/dev/sda4       286287870 625141759 338853890 161.6G  5 Extended
/dev/sda5       571742208 573741055   1998848   976M 82 Linux swap / Solaris
/dev/sda6       573743104 625141759  51398656  24.5G 83 Linux
/dev/sda7       286287872 345180159  58892288  28.1G 83 Linux

Partition table entries are not in disk order.


Disk /dev/sdb: 7.5 GiB, 8004829184 bytes, 15634432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x037cbc77

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     2048 15634431 15632384  7.5G  c W95 FAT32 (LBA)
9
  • Give some more information, are you using UEFI or BIOS mode? Which guide you are following ? Jul 5 '18 at 23:40
  • @ArpitAgarwal I'm honestly not sure. This is an old 32=bit computer from 2009 and there bios doesn't even let me choose between UEFI or Legacy. I was following generic guides for adding Windows to the bootloader by editing 40_custom and then rewriting using grub-mkconfig Jul 6 '18 at 21:43
  • have a look at wiki.archlinux.org/index.php/… Jul 6 '18 at 21:54
  • Dang, I followed the steps for Windows Vista/7/8/8.1/10 but I'm still getting Invalid Signature. I might have messed with a file that I shouldn't have Jul 7 '18 at 0:36
  • @ArpitAgarwal It actually says there are syntax errors. Do you see any? Check my update above Jul 7 '18 at 0:58
6

It looks like you've followed an old guide that expects Windows to use MBR partitioning.

The "invalid signature" error suggests Secure Boot is enabled. When Secure Boot is enabled, all bootloaders must be signed with a private key, and a matching public key must be included in the Secure Boot variables in the firmware NVRAM. GRUB is dutifully reading the first sector of the partition you've specified, but since it does not contain the appropriate Secure Boot signature, the firmware refuses to execute it.

Secure Boot requires native UEFI-style boot as a prerequisite. You may be able to disable Secure Boot on your system, but since GRUB already starts for you, there is probably no need to do that.

Your insmod part_gpt suggest you expect the disk to have a GPT-style partitioning which usually goes together with UEFI boot style, but on the other hand, set root=(hd0,msdos2) expects a MBR partition.

On my Debian system with GPT partitioning, the set root line reads: set root='hd0,gpt1'. If your system uses GPT partitioning, use the gptN partition identifiers instead of msdosN.

Also chainloader +1 tells GRUB to read the boot block from the first block of the partition; in UEFI native boot, there is no such thing. To boot Windows in UEFI mode, the set root line should point to the EFI System Partition that contains the Windows bootloader, and the chainloader line should be chainloader /EFI/Microsoft/Boot/bootmgfw.efi.

7
  • Finally a solution! Outdated guides were indeed leading me astray. Posted my config entry for Win 10 in a new answer. Hopefully that'll make things extra clear for anyone else who finds this.
    – Starbuck
    Mar 21 '19 at 9:38
  • This was by far the clearest answer I found. Still haven't solved the invalid signature problem yet though
    – jsaddwater
    Dec 17 '19 at 6:55
  • 1
    @jsaddwater If Secure Boot is enabled, you cannot boot a MBR-style boot block as it won't have a Secure Boot signature... it's too small for the signature to fit. And even if you could bypass that, such boot block would be legacy 16-bit code using the BIOS API: that could not execute in the native 64-bit mode of the UEFI environment. Feel free to ask your own question, including any details specific to your situation.
    – telcoM
    Dec 17 '19 at 7:22
  • I'd ask my own question but I'm afraid it's going to get downvoted. The thing is I have a system with windows 10/GPT and linux/MBR,. What's the safest/quickest way to convert the linux MBR to GPT, and will it enable GRUB to boot Windows ?
    – jsaddwater
    Jan 22 '20 at 9:39
  • 1
    @jsaddwater You most likely don't have to convert the partitioning unless you specifically wish to do that. If you want to keep both disks fully capable of booting stand-alone, you could make a small MBR partition of type 0xef, format it with FAT32, and that would be a valid ESP partition for installing an UEFI version of GRUB. Or if you don't have the stand-alone requirement, you could just mount the Windows 10 ESP to /boot/efi (or whatever is the recommended location in your distribution) and install the UEFI version of GRUB in there: Windows ESP is plenty big enough for that.
    – telcoM
    Jan 22 '20 at 11:22
5

You can add a custom entry to GRUB2 by editing /etc/grub.d/40_custom. If that file is already an entry for a working config, change 40 to another number that's not already used in /etc/grub.d/ [lower numbers are loaded first]. If you're editing an existing config file, make a backup!

I used Grub-Customizer to add the new grub config. The entry that it generated automatically didn't work, so I edited it as a custom script as per telcoM's suggestions.

Here's my 40_custom file.

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 10 (loader)"{
    insmod part_gpt
    search --no-floppy --set=root --fs-uuid 109C-D028
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

then, run ubdate-grub

You can disable any config entries you aren't using (but want to save), with chmod -x /path/to/file or +x to enable it. This leaves them where they should be, while hiding it from the GRUB2 menu.


Some relevant info about my system: Running Arch Linux (march 2019) and Windows 10, each on their own seperate drive. Each with GPT. Apparently GRUB2 will not load a BIOS partion if running in UEFI, (or a UEFI disk if started in BIOS mode).

2
  • 1
    I guess you meant update-grub.
    – Paul Praet
    Aug 12 '20 at 20:38
  • yes I did, thanks!
    – Starbuck
    May 19 at 18:46
0

You should install os-prober and run it once

sudo apt-get install os-prober
sudo os-prober

Generate grub config file

sudo grub-mkconfig -o /boot/grub/grub.cfg

Don't edit the file manually

7
  • Same error unfortunately. OS-prober didn't detect Windows 10 either. Jul 5 '18 at 23:35
  • If os-prober isn't listing then most probably the windows partition has got some issue. Reinstall is the only option left Jul 7 '18 at 2:20
  • I know you mean reinstall Windows but is there any way to reinstall Grub without an active internet connection? I think it's a problem with Grub since this is a fresh installation of Windows Jul 7 '18 at 2:28
  • Are you using ubuntu unity ? If yes, then try some other flavor like xubuntu Jul 7 '18 at 2:34
  • Also post the output of sudo fdisk -l Jul 7 '18 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.