Create a Custom Grub2 Screen that is maintenance free


This guide will work with any version of Ubuntu and other distros of Linux. It is great for dual booting with Windows as well as multi-booting. You can have a background picture, colored fonts of your choosing, a timeout before the default is selected and you choose which Operating System will be the default. No further changes will be necessary even when new kernels are installed. The only time any change will be needed is if you want to change the background picture, the font colors, the default Operating System or if you delete or add an Operating System. The only other time you might have to make a change is if one of the grub files gets updated, but that occurs rarely. When you make a change to any grub file it is imperative that you enter sudo update-grub or else the changes will not take effect. This was originally written for Legacy/MBR partitioned systems, but a section for UEFI/GPT partitioned systems is now included for the menuentry parts and the install grub commands; everything else is the same.

Thanks to Ranch Hand, Drs305 and oldfred for the help with grub.

Labeling the partitions

Labeling the partitions makes them much easier to identify and use.
Example: sudo tune2fs -L {label} {devicename}

You only need quotes if you have spaces in the name but, you will not be able to use CLI to copy files to and from that partition with a space.
You do not need to label anything other than ext4 file systems.

sudo tune2fs -L Arch-Linux /dev/sda2
sudo tune2fs -L "Focal Fossa" /dev/sda4
sudo tune2fs -L Eoan /dev/sda6
sudo tune2fs -L Bionic /dev/sda7

Or you can just label the partitions with Gparted.

Possible Grub font colors

You can use black/black and it will produce a black color with a transparent background.
However you only want to use this on a very light picture or it will appear invisible.


For All Ubuntu versions.

You can use sudo nano <file-name> ; or whichever editor you feel most comfortable with.
In these examples I use sudo nano <file-name> because it is the easiest way I know. You can paste into the file pressing Cntl+Shft+v.

Setting up a Grub background picture

You need to move 1 picture that is the same size as your screen resolution to /boot/grub/ e.g. sudo cp xxxx.png /boot/grub/xxxx.png.
The manual says accepted picture types are *.jpg, *.jpeg, *.png and *.tga pictures.
However, I suggest you use png pictures because they always seem to work.
If you change the picture be sure and remove the previous one because it looks for the first one it finds.
To remove the picture you would enter sudo rm /boot/grub/xxxx.png.

It is because of the existence of the picture that grub uses the font colors in /etc/grub.d/05_debian_theme.

Editing /etc/grub.d/05_debian_theme

You can have 3 font colors: a menu color, menu highlight color and a normal color. The normal color will appear above and below the box. The menu color will appear as the box and the regular line color, while the menu highlight line will appear where the cursor is as the selected line.
Enter sudo nano /etc/grub.d/05_debian_theme

At line 122 where you see this line:
echo "if background_image make_system_path_relative_to_its_root "${1}"; then"
add these three lines below with your color choices after line 122 and save the file:

echo " set color_normal=cyan/black"
echo " set menu_color_normal=yellow/black"
echo " set menu_color_highlight=red/black"

Back to top

Making the custom Grub2 Menu entries for Legacy/MBR partitioned systems

In Terminal enter sudo blkid to get the partitions to work with.

/dev/sda1: LABEL="C:" UUID="1CFC7A8DFC7A60C6" TYPE="ntfs" PARTUUID="a55f55ec-01"
/dev/sda2: UUID="97ce09d6-b701-499e-b838-93762e3b005c" TYPE="ext4" PARTUUID="a55f55ec-02"
/dev/sda4: UUID="09320a63-c5e5-4e47-afab-dfa5f9a5d8dc" TYPE="ext4" PTTYPE="dos" PARTUUID="a55f55ec-04"
/dev/sda5: UUID="3e98ebb1-3a5e-46d2-9302-6e4a811e644b" TYPE="swap" PARTUUID="a55f55ec-05"
/dev/sda6: UUID="c1549566-ed28-48f2-a546-b8a5b39729d6" TYPE="ext4" PARTUUID="a55f55ec-06"
/dev/sda7: UUID="1426326a-e0a8-4e19-86a2-0019148b3ac9" TYPE="ext4" PARTUUID="a55f55ec-07"

You can see Windows is on sda1 and the rest of the labels have been removed.
Labeling the partitions is very useful at this point.
Arch Linux is on sda2 which is drive 1 (a) partition 2, which will be depicted as (hd0,2) as the disk drive numbers start with zero.
If you have Windows installed, make note of the UUID for use in the custom entry.

Enter sudo nano /etc/grub.d/40_custom in Terminal.
All you will see is 5 lines:

exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

Although it says not to, you will need to change
exec tail -n +3 $0 to
exec tail -n +4 $0
As well as adding the 2nd line below listing your Operating systems:

echo 1>&2 "Adding Bionic Beaver 18.04 LTS, Ubuntu Version name nn.nn and Windows 10"
exec tail -n +4 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

Whatever you put between the quotes is totally up to you. This is what will display when you enter sudo update-grub
What you put between the double quotes beside each menuentry line is what will display on the Grub2 screen at boot time.

Here is what the first entry will look like (copied and pasted below the 6 lines above)

menuentry 'Xubuntu (18.04) LTS' {
    set root=(hd0,3)
        linux /vmlinuz root=/dev/sda3 ro quiet splash
        initrd /initrd.img

menuentry "Xubuntu (18.04) LTS (backup kernel)" {
    set root=(hd0,3)
        linux /vmlinuz.old root=/dev/sda3 ro quiet splash
        initrd /initrd.img.old

menuentry "Xubuntu (18.04) LTS (Recovery Mode)" {
    set root=(hd0,3)
        linux /vmlinuz root=/dev/sda3 ro recovery nomodeset
        initrd /initrd.img

Add as many of the triple entries above one for regular boot, one to boot into the backup kernel and one for recovery as you have systems on your computer. It is up to you if you want to have the ability to boot into the backup kernel. If you chose not to just omit that part.

Entry for Windows - match your UUID to what is beside --set (if you have Windows): All Windows versions work the same.

menuentry "Windows 10" {
    insmod ntfs
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set 1CFC7A8DFC7A60C6
    chainloader +1

Add these if you want the ability to restart and shutdown:

menuentry "System restart" {
        echo "System rebooting..."

menuentry "System shutdown" {
        echo "System shutting down..."

Back to top

Making the custom Grub2 Menu entries for UEFI/GPT partitioned systems

In Terminal enter sudo blkid to get the partitions to work with.
You will need the UUID of the system partition and the UUID of the swap partition.

/dev/sda1: UUID="688D-126B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="15661847-bc65-401a-84b0-97a157f3949f"
/dev/sda2: PARTLABEL="Microsoft reserved partition" PARTUUID="6b26da12-6fdc-4ce5-bde3-c990cdfc081b"
/dev/sda3: LABEL="C:" UUID="C4968A52968A44C0" TYPE="ntfs" PARTLABEL="Windows_10" PARTUUID="a76c4894-4d85-457e-8bc6-9d5308bef571"
/dev/sda4: UUID="bbc771f8-ba61-4e50-aeca-d2754b112aee" TYPE="swap" PARTLABEL="swap" PARTUUID="dc354366-1300-48d4-8a60-133aa2e2ca57"
/dev/sda5: LABEL="ArchLinux" UUID="bbca28b2-503e-4dc8-9850-c54bd0492da8" TYPE="ext4" PARTLABEL="Arch_Linux" PARTUUID="ea32dc7f-6d56-4a5c-b544-008abb8026e4"
/dev/sda6: LABEL="Media" UUID="840ac879-510a-4b8d-be01-9d3a5f37dbb2" TYPE="ext4" PARTLABEL="Media" PARTUUID="7af1d6dd-bfac-4c24-90ef-8da3d218898d"
/dev/sda7: LABEL="openSUSE" UUID="2c4c249d-f188-4236-97f6-99129537a5c2" TYPE="ext4" PARTLABEL="openSUSE" PARTUUID="dcaa5edb-0510-4bab-93e4-b238b329dbf7"
/dev/sda8: LABEL="Fedora" UUID="0991ec51-8d49-4a72-a760-d3dc321f6489" TYPE="ext4" PARTLABEL="Fedora" PARTUUID="ee5e61eb-eab9-4794-aabe-a84a910fe9a0"
/dev/sda9: LABEL="Bionic" UUID="833501fb-4f83-4d51-9903-685d56cb6891" TYPE="ext4" PARTLABEL="Bionic" PARTUUID="4f579967-b025-47dc-b080-64a0865d7165"
/dev/sda10: LABEL="MX_Linux_18.1" UUID="1cb06a9e-c0dd-467a-bef5-2ad3d1b0e494" TYPE="ext4" PARTLABEL="MX_Linux" PARTUUID="72c20ec4-11ed-4a0e-ba9d-6ce390cbe549"

The UUID of Xubuntu is used twice in the menuentry and to resume the swap UUID is used too.
This will ensure your system wakes from suspend.

menuentry 'Xubuntu Bionic Beaver 18.04 LTS' {
        search --no-floppy --fs-uuid --set=root 833501fb-4f83-4d51-9903-685d56cb6891
        linux /vmlinuz root=UUID=833501fb-4f83-4d51-9903-685d56cb6891 ro quiet resume=/dev/disk/by-uuid/bbc771f8-ba61-4e50-aeca-d2754b112aee splash
        initrd /initrd.img

This entry is for recovery and only uses the system UUID.

menuentry 'Xubuntu Bionic Beaver 18.04 LTS (recovery mode)' {
        search --no-floppy --fs-uuid --set=root 833501fb-4f83-4d51-9903-685d56cb6891
        linux /vmlinuz root=UUID=833501fb-4f83-4d51-9903-685d56cb6891 ro recovery nomodeset
        initrd /initrd.img

Windows 10 uses the EFI System partition's UUID. Here is the menuentry for Windows 10:

menuentry 'Windows 10' {
        set root='hd0,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi

DO NOT CLICK SAVE! Click file, save as and save it as 06_custom and not 40_custom.
This way the custom entries will be display at the top which is the goal.

Find where it is saved. If it is saved in /etc/grub.d/ you are good to go.
If it is in the home directory, enter this in Terminal sudo cp ~/06_custom /etc/grub.d/ and enter your password if asked.

Enter sudo chmod +x /etc/grub.d/06_custom to make it executable.

Then always remember to enter sudo update-grub or sudo update-grub2 and reboot to view the changes.
If you forget to enter sudo update-grub your changes will not "stick" and you will see that when you reboot.

In the 06_custom file there are no blanks between the lines.

Back to top

Editing /etc/default/grub

Now change the default line number, the timeout and the timeout style.

To determine which number to put in GRUB_DEFAULT= You can enter this command in terminal and use the number you want:

grep -e "menuentry " -e "submenu" /boot/grub/grub.cfg | sed 's/^[ \t]*//' | cut -d "{" -f1 | nl --starting-line-number=0

This will list all menu entries that grub will see.
Then enter this in terminal sudo nano /etc/default/grub
GRUB_DEFAULT=0 means to default on the 1st line at the top. The numbering starts with 0.
If you only have one Ubuntu installation, this should already be set to 0.
If you dual boot, or multi-boot set the number to which ever line you want to be default.
The default will never change unless you change it.

If you see this:
GRUB_TIMEOUT_STYLE=hidden "hidden" needs be changed to "menu" like this.

GRUB_TIMEOUT=60 means Grub2 screen displays for 60 seconds before defaulting. Set this to whatever number you want.

Back to top

Example pictures

Picture of Xenial Xerus 16.04 LTS and Windows 10:


Picture of Zesty Zapus 17.04, Xenial Xerus 16.04 LTS, Arch Linux and Windows 10:


Picture of Artful Aardvark 17.10, Zesty Zapus 17.04, Xenial Xerus 16.04 LTS, Arch Linux and Windows 10:


Back to top

Final changes

Once you are confident that all of the custom entries work as they should. You can eliminate the other menu entries below these custom entries.
sudo chmod -x /etc/grub.d/20_memtest86+ will make memtest unexecutable and will not show in the menu.
sudo chmod -x /etc/grub.d/10_linux will make the list of kernels not display.
sudo chmod -x /etc/grub.d/30_os-prober will make any other Linux systems and Windows entries not display.
Then always enter sudo update-grub when finished making changes.
Only having the custom menu displayed (as displayed in the example picture above), this is the output of sudo update-grub:

Generating grub configuration file ...
Found background image: blueeyedcat.png
Adding Arch Linux, Xubuntu Xenial Xerus 16.04 LTS, Xubuntu Zesty Zapus 17.04, Artful Aardvark 17.10 and Windows 10

Back to top

Installing or re-installing more than one Ubuntu system on either Legacy/MBR or UEFI/GPT

Legacy/MBR systems grub is installed in the following way:

You should first make sure that Grub2 is not installed on the system that you are removing or re-installing as you may be looking at grub rescue if so.

I recommend installing Grub2 on another system if you have one by booting into that system and entering
sudo grub-install /dev/sdx where x is the hard drive (e.g. sda).

If you install a 2nd or 3rd system etc. or if you re-install one you may need to edit fstab for that system.

Boot into the new or re-installed Ubuntu and enter sudo blkid and then cat /etc/fsab.
What appears in fstab should match the output of sudo blkid.
If it does not enter sudo nano /etc/fstab make any changes to UUID and delete any extra lines then save the file.

UEFI/GPT systems grub is installed in the following way:

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi/EFI/ubuntu --bootloader-id=ubuntu

If you multiboot mutiple Linux installs and want one Grub to control all of your OSs

The MBR (Master Boot Record) is where your system boots from. Each partition has what is called a PBR (Partition Boot Record)
When you add a 2nd or 3rd Linux system you can opt to install the grub to the PBR instead of the MBR.
This way your grub will not move from one partition to another each time any grub is updated on other partitions.

Select manual partitioning to install grub to the PBR (e.g. sda2) instead of the MBR (e.g. sda).

If you have already installed each grub on the MBR you can fix it as above with these commands:
For non efi systems:

sudo dpkg-reconfigure grub-pc

Or on efi systems use this command:

sudo dpkg-reconfigure grub-efi-amd64

Enter thru first pages, spacebar to choose/unchoose drive, enter to accept.

Just make sure you remember which install (MBR) your grub is installed on.

If you ever change your mind, get on that system and enter:
sudo grub-install /dev/sdx where x is the drive (e.g. sda,sdb,sdc,).

Back to top

Undo the changes made by this tutorial

Enter the following commands in terminal:
sudo chmod +x /etc/grub.d/20_memtest86+
sudo chmod +x /etc/grub.d/30_os-prober
sudo chmod +x /etc/grub.d/10_linux

Then you can either make the custom file unexecutable if you think you will use it in the future:
Enter in terminal sudo chmod -x /etc/grub.d/06_custom
Or you can simply delete the file: sudo rm /etc/grub.d/06_custom
Delete any picture(s) in /boot/grub/. sudo rm /boot/grub/blue-sea.jpg
Enter sudo nano /etc/default/grub in terminal and change the GRUB_DEFAULT= to 0.
Then enter sudo update-grub in terminal, reboot and you are back to normal.

Where to post questions, problems, etc

How to have a custom Grub2 menu that is maintenance free


Original post The Ubuntu Forums (


1. Grub2

2. GNU GRUB2 Manual

MaintenanceFreeCustomGrub2Screen (last edited 2020-08-09 19:49:21 by cavsfan)