customizing grub2 on fedora 26

grub2 is a deafult bootloader from centos/redhat 7, grub stands for grand unified boot loader.

When booting a system there is a dull black screen which presents to choose the kernel to be booted, this can be tweaked to set a background for grub2.

Gurb2 main configuration file will be located at /boot/grub2/grub.cfg , while is not recommended to make changes to grub2 directly we need to use the file /etc/default/grub instead to make our changes.

here is a snippet of my /etc/default/grub file

#cat /etc/default/grub
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="rhgb quiet video=SVIDEO-1:d elevator=noop"
GRUB_DISABLE_RECOVERY="true"
GRUB_BACKGROUND="/boot/grub2/themes/linux.jpg"
GRUB_GFXMODE="800x600"
export GRUB_COLOR_NORMAL="white/black"
export GRUB_COLOR_HIGHLIGHT="yellow/red"

After setting the parameters in the /etc/default/grub, we need to generate a new grub2 config file from grub2-mkconfing utility.

#grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found background: /boot/grub2/themes/linux.jpg
Found linux image: /boot/vmlinuz-4.12.12-300.fc26.x86_64
Found initrd image: /boot/initramfs-4.12.12-300.fc26.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-a9ee22a02eb84257a4948e9fdc6ebe84
Found initrd image: /boot/initramfs-0-rescue-a9ee22a02eb84257a4948e9fdc6ebe84.img
done

reboot the system you should be able to see gurb2 background.

If you use computers with no display or keyboard, it can be very useful to control the machines through serial communications.

grub2 supports enabling serial console access add below lines to /etc/default/grub

GRUB_CMDLINE_LINUX=”video=SVIDEO-1:d elevator=noopi console=tty0 console=ttyS0,115200n8″
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND=”serial –speed=9600 –unit=0 –word=8 –parity=no –stop=1″

#cat  /etc/default/grub 
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="rhgb quiet video=SVIDEO-1:d elevator=noop"
GRUB_CMDLINE_LINUX="video=SVIDEO-1:d elevator=noopi console=tty0 console=ttyS0,115200n8"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"
GRUB_DISABLE_RECOVERY="true"
GRUB_BACKGROUND="/boot/grub2/themes/linux.jpg"
GRUB_GFXMODE="800x600"
export GRUB_COLOR_NORMAL="white/black"
export GRUB_COLOR_HIGHLIGHT="yellow/red"

#grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.12.12-300.fc26.x86_64
Found initrd image: /boot/initramfs-4.12.12-300.fc26.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-a9ee22a02eb84257a4948e9fdc6ebe84
Found initrd image: /boot/initramfs-0-rescue-a9ee22a02eb84257a4948e9fdc6ebe84.img
done

Then you can connect serial console in different ways.
screen linux command can be used to connect

$ screen /dev/ttyS0 115200