Fedora GRUB2 Configuration20 Jun 2016 tags: config_recipe
I've never been a fan of GRUB2, I much prefer the simplicity of GRUB Legacy, and as a result I never spent much time learning how to configure it; I simply hacked away at the configuration and asked Google for help when needed. However, while debugging a kernel problem last week I finally reached my breaking point and decided it was time for me to develop a proper GRUB2 configuration that met my needs better than the Fedora Rawhide defaults. The resulting /etc/default/grub file is shown below:
Before I explain the lines above I want to make a quick comment about grubby, the tool used by Fedora (perhaps others?) to update the GRUB2 configuration when new kernels are installed. It appears, at least at the time of writing, that grubby does not honor the /etc/default/grub configuration file and may not generate a GRUB2 boot loader file that is consistent with the desired configuration. My workaround is to simply run the following command after a new kernel has been installed, it will regenerate the GRUB2 boot loader file based on the configuration in /etc/default/grub :
Now let's cover the GRUB2 configuration above, line by line. The first line disables the submenu and places all boot loader choices in the top level menu.
The line below sets the timeout before the default boot option is chosen.
The line below is a Fedora default that I've largely ignored as it doesn't have any impact on what I'm trying to do with my systems.
The line below is a list of parameters to pass to the kernel at boot. Most of these are, or were, Fedora defaults at some point with the exception of "nomodeset", which disables the kernel graphics modesetting, and "console=ttyS0", which sets the console to the first serial port.
These two lines tell GRUB2 to use the serial console, with the specified configuration, instead of the graphics console.
The line below disables the creation of a recovery kernel image and associated boot loader option. Although be warned that even though this will prevent GRUB2 from creating a new recovery kernel image, you may need to manually remove any previously created recovery kernel images in order to remove the recovery kernel from the boot loader option list.
The line below instructs GRUB2 to reference partitions by their device name/path and not their UUID, e.g. use root=/dev/sda1 instead of root=UUID=<xxx> .
That's my GRUB2 configuration. There are plenty of other good references online, Google is your friend of course, but if you like a simple boot loader configuration with a serial console, I encourage you to check out the config above, it works pretty well.
UPDATE: In order to completely remove the recovery/rescue kernel you also need to instruct Dracut not to generate a rescue kernel and initrd. This can be done by creating the /etc/dracut.conf.d/02-rescue.conf file with the following contents:
This will prevent Dracut from creating rescue images when new kernels are installed on the system.