Friday 14 November 2014

Changing the default Grub2 entry on the fly

Just another one of those seldom needed bits of info that I'll have to google the next time I need it unless I write it down here.

Yesterday I realised that my network shares weren't being mounted as usual, and I haven't changed the configuration for a month.  The culprit seems to be the new 3.7-2-200 (or there abouts) kernel that I installed.  I don't have time to fully explore the reasons (deadlines, deadlines, deadlines,...) so I'm dropping back to the previous kernel for now. 

Grub2 has the ability to set the default entry to the last menu item selected, but this isn't the default, at least not in Fedora 20.  My original grub defaults (/etc/default/grub) were something like:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
#GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.md=0 rd.dm=0 rd.lvm.lv=fedora_odin/root $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) rd.luks=0 vconsole.font=latarcyrheb-sun16 vconsole.keymap=uk rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
#GRUB_THEME="/boot/grub2/themes/system/theme.txt"
GRUB_THEME="/boot/grub2/themes/hitman/theme.txt"
#GRUB_GFXMODE=1024x768
GRUB_GFXMODE=1280x1024


So although the default is set to saved, to activate the saving feature you need to add the following:

GRUB_SAVEDEFAULT=true

After a quick run of grub2-mkconfig to update the grub.cfg it's all good and my default kernel is non-borked one until a fix comes in, or I have time to read the documentation to see what 'new feature' broke my configuration ;-)