Grub Control Script

This control script resides in /etc/default/grub file. It is responsible for instructing grub-mkconfig to generate an automated grub.cfg with main configurations, default menuentry etc. Here, we review all the main control configurations based on grub specification:


File Format

/etc/default/grub is a POSIX compliant shell script.

GRUB_TERMINAL_INPUT

This variable is responsible for setting the grub input. It can be multiple inputs like from terminal, keyboard, serial, etc., separated by spaces. This is an optional flag.

Here are a few examples:

# take input from both console and serial ports
GRUB_TERMINAL_INPUT="console serial"

# take input from USB Keyboard
GRUB_TERMINAL_INPUT="usb_keyboard"

# take input from PC AT Keyboard
GRUB_TERMINAL_INPUT="at_keyboard"

# take input from specific serial port
GRUB_TERMINAL_INPUT="serial_ttyS1"

The default is:

GRUB_TERMINAL_INPUT="console"

GRUB_TERMINAL_OUTPUT

This variable is responsible for setting the grub output. It can be multiple outputs like to terminal, serial port, Morse codes, etc, separated by spaces. This is an optional flag.

Here are a few examples:

# send to both console and serial ports
GRUB_TERMINAL_OUTPUT="console serial"

# send to specific serial port
GRUB_TERMINAL_OUTPUT="serial_ttyS1"

# send to gfxterm
GRUB_TERMINAL_OUTPUT="gfxterm"

# set to VGA and MGA text
GRUB_TERMINAL_OUTPUT="vga_text mga_text"

# send to Morse code
GRUB_TERMINAL_OUTPUT="morse"

# send to Speaker Modem (special compilation required for receiver side)
GRUB_TERMINAL_OUTPUT="spkmodem"

The default is:

GRUB_TERMINAL_INPUT="console"


Additional Note:

  1. If you use spkmodem, on receiver side, you need to compile util/spkmodem-recv.c and then execute it with the following command:
    1. parecord --channels=1 --rate=48000 --format=s16le | ./spkmodem-recv

GRUB_TERMINAL

Similar to both GRUB_TERMINAL_INPUT and GRUB_TERMINAL_OUTPUT. The only difference is that GRUB_TERMINAL sets both of them to be the same instead of setting them independently.

GRUB_DEFAULT

Sets the default selected menuentry option for boot. By the newly acceptable input specification, the sensible values would be: either numbers or the keyword: saved. The use of "id" by "title" is considered obsolete and is discouraged for usage.

The default value is: 0, the first menuentry.


NOTE

  • If the value is 'saved', then the it boots based on last saved value done by GRUB_SAVEDEFAULT or grub-set-default function.

GRUB_SAVEDDEFAULT

Set to either true or false. This instructs GRUB to remember the last selection for the next boot. It only works when:

  1. Environment block is available.
  2. GRUB_DEFAULT is set to 'saved'.

GRUB_TIMEOUT

Set waiting time before boot. This is useful for interrupting the automation for manual interaction. It accepts numbers as its value, with notable effect as the following:

  • -1 means wait indefinitely for user input
  • 0 means boot immediately
  • 1 and above means wait for 1 and above seconds


NOTE

  1. If GRUB_TIMEOUT_STYLE is set to countdown or hidden, the counting starts right before the menu is presented.

GRUB_TIMEOUT_STYLE

Set to display timeout style. There are 3 types:

  1. menu or unset - full menu with countdown timer
  2. countdown - single numerical line showing the remaining timer
  3. hidden - hide everything

The default is unset, which shows the full menu with countdown timer.

GRUB_DEFAULT_BUTTON

GRUB_TIMEOUT_BUTTON

GRUB_TIMEOUT_STYLE_BUTTON

GRUB_BUTTON_CMOS_ADDRESS

GRUB_HIDDEN_TIMEOUT_BUTTON

Hardware buttons supported by vendor-specific power buttons. Nothing much you can do.

GRUB_DISTRIBUTOR

Set title name by the grub distributor.

GRUB_CMDLINE_LINUX

GRUB_CMDLINE_LINUX_DEFAULT

GRUB_CMDLINE_XEN

GRUB_CMDLINE_XEN_DEFAULT

GRUB_CMDLINE_LINUX_XEN_REPLACE

GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT

GRUB_CMDLINE_NETBSD

GRUB_CMDLINE_NETBSD_DEFAULT

GRUB_CMDLINE_GNUMACH

The command lines for the kernel booting for different operating system types. It follows this pattern:

GRUB_CMDLINE_<OS>_<ADDITION>
  • The main command line is the one without any ADDITION. Example, GRUB_CMDLINE_LINUX, GRUB_CMDLINE_XEN, etc.
  • The DEFAULT additions are the extra arguments appends to the main command line. This is meant for recovery boot cases when the boot using the main command line fails.


NOTE

  1. LINUX_XEN_REPLACE operating system simply means the arguments usable for both LINUX and XEN. They will replace both LINUX and XEN command lines if exists.

GRUB_DISABLE_LINUX_UUID

This is to enable/disable the use of UUID, which is a very accurate partition identification mechanism. Universally-unique identifiers (UUIDs) is for identifying the root filesystem to the Linux kernel, using a ‘root=UUID=...’ kernel parameter.

It only accepts:

  • true - to disable Linux UUID mechanism
  • false, unset - to enable Linux UUID mechanism

By default, it is unset.

GRUB_DISABLE_RECOVERY

This is to enable/disable recovery menuentry. It only accepts:

  • true - to disable recovery menuentry generation
  • false, unset - to enable recovery menuentry generation

GRUB_VIDEO_BACKEND

GRUB_GFXMODE

GRUB_BACKGROUND

GRUB_THEME

GRUB_GFXPAYLOAD_LINUX

GRUB_INIT_TUNE

These are GRUB multimedia / video variables using gfxterm terminal.


GRUB_VIDEO_BACKEND

Usually automated once GRUB_GFXPAYLOAD_LINUX is set. This is responsible for loading video drivers required for the GFX loading. The values are usually listed in /boot/grub/video.lst.


GRUB_GFXMODE

Set the display resolution. It has 2 types of values:

  • auto - determine automatically
  • <width>x<height>x<depth> OR <width>x<height> - specifically load the resolution at <width> and <height>, optionally with <depth> as specified in GFX Mode specifications.


GRUB_BACKGROUND

Set GRUB background to load image. It's the filepath to the image. The filepath must ends with the extension like .png, .jpg, .jpeg, and .tga. Currently, GRUB supports the following format:

  • JPEG
  • TGA
  • PNG


GRUB_THEME

Name of the GRUB theme to use.


GRUB_GFXPAYLOAD_LINUX

Configure GRUB to load in a specified display modes. It takes the following values:

  • text, unset - GRUB will boot using text mode.
  • keep - preserves the graphic mode.


GRUB_INIT_TUNE

Play a tune upon GRUB starts. The value is using the MIDI tempo tune specified in the play specification.

GRUB_BADRAM

Perform bad RAM filtering (usually caused by hardware damage), following the specification. It accepts value as:

  • true - run badram command
  • false, unset - avoid badram command

The default is unset.

GRUB_PRELOAD_MODULES

Load the listed modules as early as GRUB starts. Each modules is separated by spaces. Example:

grub> GRUB_PRELOAD_MODULES="cryptodisk ext4"

That's all about main configuration variables controlling the grub-mkconfig.