1

I know that there are tons of questions referring to GRUB issues, but I have a specific problem that I'm not able to solve for quite long time.

My hard drive is laid out using GPT format (not MBR - refer listing below). I have two 64-bit OSes:

  1. Windows 10,
  2. Debian Stretch (Sid).

The problem is that after one of the system upgrades (I'm not sure if it was Debian's of Windows' upgrade fault) GRUB stopped showing up at start up making Windows start default. To boot my Debian I use GRUB command prompt using Debian's LiveCD:

grub> root=(hd0,6)
grub> linux /vmlinuz-4.3.0-1-amd64 root=/dev/sda8
grub> initrd /initrd.img-4.3.0-1-amd64
grub> boot

What I've tried so far

I tried to solve the problem in many different ways:


Diagnostic info

  • My motherboard is GIGABYTE GA-Z77-D3H with UEFI DualBIOS™, which means that (quote) 'it has a BIOS compatibility mode - the built-in boot menu shows two entries for each device, one prefixed with UEFI and one without'. Booting neither in UEFI mode nor in BIOS legacy mode doesn't work.

  • efibootmgr command result:

    root@mycomp:/home/me# efibootmgr 
    BootCurrent: 0007
    Timeout: 1 seconds
    BootOrder: 0002,0003,0004,0005,0000,0007
    Boot0000* Windows Boot Manager
    Boot0002* UEFI: ST1000DM003-9YN162
    Boot0003* Hard Drive 
    Boot0004* CD/DVD Drive 
    Boot0005* Removable Drive 
    Boot0007* UEFI: USB USB Hard Drive
    
  • parted command result:

    root@mycomp:/home/me# parted /dev/sda print
    Model: ATA ST1000DM003-9YN1 (scsi)
    Disk /dev/sda: 1000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Disk Flags: 
    
    Number  Start   End     Size    File system     Name                          Flags
     1      1049kB  316MB   315MB   ntfs            Basic data partition          hidden, diag
     2      316MB   420MB   105MB   fat32           EFI system partition          boot, esp
     3      420MB   555MB   134MB                   Microsoft reserved partition  msftres
     4      555MB   268GB   268GB   ntfs            Basic data partition          msftdata
     5      268GB   805GB   537GB   ntfs            Basic data partition          msftdata
     6      805GB   806GB   500MB   ext4                                          msftdata
     7      806GB   830GB   24,4GB  ext4                                          msftdata
     8      830GB   838GB   8000MB  ext4                                          msftdata
     9      838GB   853GB   15,0GB  ext4                                          msftdata
    10      853GB   863GB   10,0GB  linux-swap(v1)
    11      863GB   1000GB  137GB   ext4                                          msftdata
    
  • /etc/fstab content (I zeroed UUIDs below for privacy's sake):

    root@mycomp:/home/me# cat /etc/fstab
    # <file system>                           <mount point>     <type>  <options>          <dump>  <pass>
    # / was on /dev/sda8 during installation
    UUID=00000000-0000-0000-0000-000000000000 /                 ext4    errors=remount-ro   0       1
    # /boot was on /dev/sda6 during installation
    UUID=00000000-0000-0000-0000-000000000000 /boot             ext4    defaults            0       1
    # /boot/efi was on /dev/sda2 during installation
    UUID=0000-0000                            /boot/efi         vfat    defaults            0       1
    # /home was on /dev/sda11 during installation
    UUID=00000000-0000-0000-0000-000000000000 /home             ext4    defaults            0       2
    # /tmp was on /dev/sda9 during installation
    UUID=00000000-0000-0000-0000-000000000000 /tmp              ext4    defaults            0       2
    # /usr was on /dev/sda7 during installation
    UUID=00000000-0000-0000-0000-000000000000 /usr              ext4    defaults            0       2
    # swap was on /dev/sda10 during installation
    UUID=00000000-0000-0000-0000-000000000000 none              swap    sw                  0       0
    # CD-ROM
    /dev/sr0                                  /media/cdrom0     udf,iso9660 user,noauto     0       0
    # Added for Google Chrome (see: https://unix.stackexchange.com/questions/116400/google-chrome-no-space-on-rootfs-partition)
    /usr/opt                                  /opt              none   bind                 0       0
    # C: Windows partition
    UUID=0000000000000000                     /media/Windows/C  ntfs   ro                   0       0
    # D: Windows partition
    UUID=0000000000000000                     /media/Windows/D  ntfs   ro                   0       0
    
  • fdisk -l result:

    root@mycomp:/home/me# fdisk -l
       Device       Start        End    Sectors    Size Type
    /dev/sda1        2048     616447     614400    300M Windows recovery environment
    /dev/sda2      616448     821247     204800    100M EFI System
    /dev/sda3      821248    1083391     262144    128M Microsoft reserved
    /dev/sda4     1083392  524290047  523206656  249,5G Microsoft basic data
    /dev/sda5   524290048 1572866047 1048576000    500G Microsoft basic data
    /dev/sda6  1572866048 1573842943     976896    477M Microsoft basic data
    /dev/sda7  1573842944 1621499903   47656960   22,7G Microsoft basic data
    /dev/sda8  1621499904 1637124095   15624192    7,5G Microsoft basic data
    /dev/sda9  1637124096 1666420735   29296640     14G Microsoft basic data
    /dev/sda10 1666420736 1685952511   19531776    9,3G Linux swap
    /dev/sda11 1685952512 1953523711  267571200  127,6G Microsoft basic data
    
  • Referring to the msinfo32 Windows System Information, my system BIOS mode is UEFI.

If you need more information to diagnose my problem, put your request in comment.


Update

I removed grub-efi-amd64 package with all dependencies, installed grub-pc and now GRUB is loading successfully only if I boot in BIOS mode. The following command:

[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS

displays BIOS, but I still want to boot in UEFI mode!


Helpful links

Links that may be helpful:

2
  • cat /etc/fstab; fdisk -l
    – user657451
    Commented Nov 2, 2016 at 0:02
  • @user657451 Done - see update. Commented Nov 5, 2016 at 17:26

3 Answers 3

2
+25

Problem is EFI is bios-init, and you have to choose the efi image (windows or linux-grub)

If you don't set grub, it will boot default secure-boot, so go into bios and disable secure boots.

After that... Grub will update correctly. (after it boots correctly)

Knowing now that you hate ubuntus "auto magic" (fine, alright) still you could reverse engineer those settings for comprehension sake...

EFI Boot = Set in Firmware (bios)

  • Boot Type = uefi
  • 1st boot = Select EFI:Disk and EFI:boot (Windows Boot Manager) or (Debian/Ubuntu/Etc...)

Grub = should be efi [name of disk here]

or something the combination there of... Now you can install grub by Root -> kernel, ramdisk, etc... and windows should be hd0,1...2... efi/boot or something-something windows boot loaders.

Set force bios to scan for boot - or Debian.

Boot repair.

https://sourceforge.net/projects/boot-repair-cd/

  • make live disk
  • Boot live.
  • Connect to internet.
  • Press Go

... should work.

5
  • I want to understand what is screwed up. I don't trust fancy Windows/Ubuntu-like magic repair applications, thus I refuse to use them. I want you to point out what is missing in my configuration. I know that it requires deep GRUB knowledge, but that what is Linux all about. Commented Nov 1, 2016 at 18:43
  • Im just trying to help...
    – TardisGuy
    Commented Nov 1, 2016 at 22:37
  • I appreciate it! Thanks! Anyway, I'm still waiting for more precise answers. ;-) Commented Nov 1, 2016 at 22:39
  • dont worry. I dont "play" for "points" Im just trying to help solve problems. made more details.
    – TardisGuy
    Commented Nov 1, 2016 at 22:49
  • Referring to your post update: what do you mean by saying that EFI is bios-init? BTW: I've mentioned that Booting neither in UEFI mode nor in BIOS legacy mode doesn't work. Commented Nov 2, 2016 at 15:28
2

That's a whole lot of partitions!

"GRUB stopped showing up at start up making Windows start default."

Indicates that (probably) windows has changed boot flags.
from your parted output, partition 2 is booting. Is this where /boot/grub is? ...It looks as though sda6 is a /boot partition for your nix install?

Use cfdisk or similar to make sure the boot flagged partition is the one where /boot/grub is.

And I can't see it hurting to re-install grub:

grub-install /dev/sda && update-grub && shutdown -r now
5
  • Firstly: /dev/sda2 is EFI System Partition (ESP), thus it needs boot flag (see proof #1, proof #2 and proof #3). Secondly: I've mentioned that I've tried to reinstall GRUB! Read carefully my original post! Commented Nov 2, 2016 at 15:20
  • You did not provide a target drive for your "grub reinstall"
    – user657451
    Commented Nov 2, 2016 at 17:55
  • You did not provide a target drive for your "grub reinstall" If the ESP is booting (and I assume it is: to chainload windows) then the links THERE, pointing to grub are defunct.
    – user657451
    Commented Nov 2, 2016 at 18:04
  • Quote: You might note the absence of a <device_path> option (e.g.: /dev/sda) in the grub-install command. In fact any <device_path> provided will be ignored by the GRUB install script, as UEFI bootloaders do not use a MBR or partition boot sector at all. Commented Nov 2, 2016 at 18:44
  • Uefi presumably CHAINLOADS another environments boot manager. In your instance (I assume) you want it to hit grub first. For whatever reason, the link has been broken. This is why specifying it manually works. I also assume uefi still need a /boot and initrds to hand over to.
    – user657451
    Commented Nov 4, 2016 at 0:18
0

To have the grub2 menu show up on a uefi system you need to simply add a menu entry with efibootmgr:

sudo efibootmgr --create --disk /dev/xxxx --part 1 --write-signature --loader /EFI/Manjaro/grubx64.efi --label "MANJARO" --verbose
  • You should have mounted the EFI partition under /boot/efi & the files under this mount point will give you the correct path for the --loader above pointing to grubx64.efi .

  • replace --disk xxxx & the partition number in --part with your actual EFI device.

On a dual boot system this will show something like:

[stuart@manjaro ~]$ efibootmgr
BootCurrent: 0003
Timeout: 10 seconds
BootOrder: 0003,0000,0001
Boot0000* Windows Boot Manager
Boot0001  Hard Drive 
Boot0003* MANJARO
  • The Manjaro Architect ISO if written as an image to USB (i.e with dd) can boot in UEFI mode & has an option on the initial menu to search for EFI loaders. This can be used to get your system up to run the above efibootmgr command. If the menu option does not appear it means you have booted from the USB in MBR mode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .