Skip to content

Instantly share code, notes, and snippets.

@latusikl
Last active May 13, 2024 20:05
Show Gist options
  • Save latusikl/a4368f0695c77bad31571b8f91ff6e66 to your computer and use it in GitHub Desktop.
Save latusikl/a4368f0695c77bad31571b8f91ff6e66 to your computer and use it in GitHub Desktop.
How to hide GRUB menu while dual booting?

Hide GRUB menu while dual booting

Tested on Ubuntu 18.04 / 20.04 / 24.04

After that change during boot chosen default system will be opened without going through GRUB menu.\

Note

You can still open GRUB menu by pressing Shift key while booting.

How to?

You need to make changes in /etc/default/grub file. However after updating GRUB settings the changes won't be visible because of the script that is used by the system to generate final version of the file. That's why you need to make additonal changes, as described below.

Important

Remember to backup your files in case something went wrong

Here are the steps you need to do:

  1. Edit grub file.
sudo nano /etc/default/grub

You need to edit these two parameters:

GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0

You can choose a system that will be used as default by adding changing parameter:

GRUB_DEFAULT=<number>

Where the <number> corresponds to number of the option in GRUB menu.

  1. Edit script 30_os-prober. While running with dual boot and executing update-grub this script takes values from /etc/default/grub and overwrites changes introduced in previous steps. Therefore we need to modify it.
sudo nano /etc/grub.d/30_os-prober

Inside this script file (around line 30) you will find definiton of the following function:

adjust_timeout () {
if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then

In order to aviod overriding timeout settings you need to comment the following lines: (comment character for shell script is #)

#set timeout_style=
#if [ "\${timeout}" = 0 ]; then
#set timeout=10
#fi*

Remember to save changed file.

  1. Run GRUB update command to generate new grub.cfg file.
sudo update-grub
  1. You can verify if the changes worked by checking the content of the new grub.cfd
cat /boot/grub/grub.cfg
  1. Now you can reboot and check if everthing works as expected
@latusikl
Copy link
Author

Hi,
Unfortunately, currently, I do not have a PC with Linux available, so I cannot check if it still works. As far as I remember, for some PC (I guess the difference here was in BIOS/UEFI), it was the Esc button.
Please let me know if you find something to improve in the gist.

@d-saravanan
Copy link

Hi,
This worked fine with ubuntu os 20.04. I had a grub that showed ubuntu os and windows, not it default loads the ubuntu os

@mahmoud-mohsen-dev
Copy link

Thanks latusikl,
Your solution worked for me. I am using Ubuntu 24.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment