six demon bag

Boot a kernel just once

If you want to test a new kernel without having access to the console you need to make sure that the system comes back up with the old kernel if the new one panics. Add a setting panic=2 to the kernel commandline in /etc/default/grub to have the system automatically reboot in case of a kernel panic, and tell grub to boot a saved kernel by default:

GRUB_DEFAULT="saved"
GRUB_CMDLINE_LINUX="panic=2"

Then tell grub which kernel to boot by default, and which kernel to boot on the next startup:

The commands just change the boot configuration, they don't actually reboot the system.

To be able to view the kernel list without having to reboot and dig through submenus you may want to add the following setting to /etc/default/grub and run update-grub:

GRUB_DISABLE_SUBMENU="y"

Note: The value must be "y". GRUB_DISABLE_SUBMENU="true" does not work.

Now you can list the boot menu entries with something like

grep -oP "^menuentry '\K[^']*" /boot/grub/grub.cfg

or

awk -F"'" '/^menuentry/ {print $2}' /boot/grub/grub.cfg

The first listed entry has index 0, the second has index 1, and so on.

If you don't want the automatically generated recovery boot options you can suppress them by adding GRUB_DISABLE_RECOVERY="true".

Console resolution

The console resolution can be changed with the following settings in /etc/default/grub

GRUB_GFXMODE=1024x768x24
GRUB_GFXPAYLOAD_LINUX=keep

A list of available resolutions can be obtained by running vbeinfo (or videoinfo on EFI systems) from the grub console (press C at the boot menu/prompt). An alternative that can be run from a terminal without a reboot is

hwinfo --framebuffer

If the kernel doesn't preserve the resolution you may need to add the parameter nomodeset to the kernel commandline so that the kernel keeps using BIOS modes until the X Server is started:

GRUB_CMDLINE_LINUX="nomodeset panic=2"

I frequently need this parameter for VirtualBox VMs.

Systemd shenanigans

To get rid of the so-called "predictable network interface names" that were introduced in Debian 9 and Ubuntu 16 add net.ifnames=0 and biosdevname=0 to the kernel commandline:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 nomodeset panic=2"

Seriously, the only thing predictable about these new names is that the network interfaces will have different names on the next system you're sitting at. Yet another thing systemd fucks up for everyone else. Thanks a lot!

To prevent update-grub from creating systemd boot menu entries (despite systemd being uninstalled) remove systemd:/lib/systemd/systemd from the list of supported inits in /etc/grub.d/10_linux: