0
  • Ubuntu server 14.04 efi-gpt disk with three partitions, 1=boot, 2=main, 3=recovery
  • I want: default boot on gpt2, grub fallback to gpt3, and grub-reboot to reboot into recovery from main.

  • What I get is no boot at all, just an instant reboot loop.

I am a bit confused by the GNU docs. And I need to be able to do all changes from the 40_custom file and /etc/default/grub to be repeatable and robust.

heres some links: http://www.gnu.org/software/grub/manual/grub.html#Simple-configuration https://www.gnu.org/software/grub/manual/legacy/Booting-fallback-systems.html "wiki.ubuntuusers.de/ GRUB_2/ Skripte/#Fallback-Skript"

here is /etc/default/grub:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=""
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

# fallback addition
export GRUB_FALLBACK="1 2"
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true



# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1

"

here is the relevant part of grub.cfg:

## BEGIN /etc/grub.d/40_custom ###
# 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 'ITH Robot Base Main (on /dev/sda2)' {
        recordfail
        load_video
        gfxmode $linux_gfx_mode
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  208a7546-da6b-4d07-82ab-0f04e8db6fd0
        else
          search --no-floppy --fs-uuid --set=root 208a7546-da6b-4d07-82ab-0f04e8db6fd0
        fi
        linux   /boot/vmlinuz  
        initrd  /boot/initrd.img
        savedefault fallback
}



menuentry 'ITH Robot Base Recovery(on /dev/sda3)' {
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  89ad84a4-3fe5-4409-a702-96ae698872d2
        else
          search --no-floppy --fs-uuid --set=root 89ad84a4-3fe5-4409-a702-96ae698872d2
        fi
        linux /boot/vmlinuz
        initrd /boot/initrd.img
        savedefault fallback
}
### END /etc/grub.d/40_custom ###
  • Did you run sudo update-grub after making the changes? It needs to be executed every time you want to apply the grub changes. – E.F. Nijboer Feb 9 '16 at 23:50
  • yes I did run it each time – John Fisher Feb 10 '16 at 0:09
  • Under EFI, partitions are not bootable. Thus, your claim that you want "default boot on gpt2, grub fallback to gpt3" makes no sense from an EFI perspective. Please re-state your requirements in terms of what you want to boot -- different OSes, distributions, or kernels, for instance. The context of your configuration (Boot Info Script output, or at least sudo parted -l output) would be helpful, too. – Rod Smith Feb 10 '16 at 15:28
  • I am going back to see about the EFI/gpt setup; I may have thought I knew something and been wrong, though the initial setup did boot EFI and only refused to boot after I changed Grub settings. Anyway back to the start and double-check. – John Fisher Feb 10 '16 at 17:41
  • this page is very helpful .. askubuntu.com/questions/500359/… ... for one thing I had no idea you could mix and match mbr|gpt vs efi|legacy. I just want a dual-boot with efi-gpt and it looks like I need to experiment a little, then get back to the Grub problem. – John Fisher Feb 10 '16 at 19:33
0

I solved the issues by making sure that my disk was setup EFI/GPT ( not necessary, but not getting this right made it impossible to follow the instructions when I was already confused), using gparted (or parted) to create the boot EFI partition, and editing the proper files. Here is a guide that might be helpful:

  • To get the disk right use gparted to create a GPT disk table, then create a smallish Fat32 partition with the flag set to "boot" and a mount point /boot/efi. (the mount point is conventional, but I advise following convention).
  • Add your other partitions as required, but root partitions won't have the boot flag as they normally do.
  • After installing Ubuntu, you'll find that Grub has set up all partitions it could find for its boot menu. You may not want this, or you may have customizations.
  • Check /etc/fstab to make sure the /boot/efi mount command is there and the filesystem to make sure there is a /boot/efi mount point.
  • Advice: before you run update-grub make backups of /boot/grub, /etc/default/grub, /etc/grub.d and have a bootable flashdrive or some method of mounting your new partitions so you can fix them when your changes fail to boot.
  • There are only a few things you need to change in /etc/default/grub, the majority of your changes should be in /etc/grub.d/40_custom plus chmodding the 10* 20* 30* scripts as needed to prevent them from doing their thing.
  • You can cut&paste the menu stanza(s) from /boot/grub/grub.cfg into 40_custom
  • Beware Grub( maybe EFI?) counts the disks from zero ( hd0) and the partitions from one.
  • Run update-grub to create the grub.cfg file
  • You don't need to do anything with the Fat32 boot partition
  • Beware: I got a problem on a system with two bootable flashdrives and a HD where the HD used the boot EFI partition off the flashdrive instead of on itself. This is all about having extraneous drives connected- try to disconnect anything that you don't want to change.
  • Beware: if you are saving and restoring multiple drives, you'll have to reset the UUIDs using tune2fs, else you'll get a collision.
|improve this answer|||||

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.