1. Home
  2. Linux
  3. Improve linux boot speed grub tweak

How to improve Linux boot speed with a Grub tweak

Linux is pretty fast, but thanks to the Grub boot loader, it can take quite a lot of time for everything to start up and become usable. Therefore, if you want to speed up the boot of your Linux system, it is critical that you modify the default startup setting in the Grub bootloader so that your Linux boot speed isn’t too slow.

Before we begin

Making changes to the Grub configuration file, however small, is dangerous. Any mistake could seriously break your system and potentially mess it up. So, before showing you how to speed up your boot time on Linux, it is critical that we go over how to make a backup of your Grub configuration file.  To do this, launch a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Gain Root access in the shell by typing in su. Alternatively, if you can’t log in as root, try the sudo -s command.

su -

Or

sudo -s

Once you’ve got access to a Root shell, use the CP command to make a complete copy of the Grub bootloader config file.

Note: be sure to replace username in the command below with the username you use on your Linux PC.

cp /etc/default/grub /home/username/grub.bak

Speed up Grub’s boot time

The Grub bootloader has a setting called “GRUB_TIMEOUT.” This setting is how long your computer will sit and idle before choosing to load up the default operating system. By default, it’s set to 5 seconds, and for most people, that’s enough time to wait. However, if you’re looking to speed up your boot time, changing this number is the most effective way to do it.

To change the boot speed in the Grub bootloader, you’ll need to modify the configuration file. Editing Grub’s configuration file is best done through the Nano text editor, as it’s one of the easiest to navigate. To start the editing process, launch a terminal window and gain Root or sudo access.

su –

Or

sudo -s

Next, open up the Grub configuration file in the Nano text editor.

nano -w /etc/default/grub

Look through the text file for the “GRUB_TIMEOUT” entry. Then, erase the number 5 and change it to a smaller number. Keep in mind that the lower this number is, the faster your PC will boot. For the absolute fastest results, change it to:

GRUB_TIMEOUT=0

Alternatively, if you’re interested in speeding up Grub, but still want to be able to read the menu, set it to 2 seconds.

GRUB_TIMEOUT=2

After you’re satisfied with the changes made to the GRUB_TIMEOUT flag, save your edits to the file by pressing Ctrl + O on the keyboard. Then, close the Nano text editor out by pressing Ctrl +X.

Apply the changes

With the changes are made to the Grub configuration file, it’s time to apply them. The only way to implement configuration changes to Grub is to update the Bootloader. To do that, you’ll need to use your Linux distribution’s bootloader updating mechanism.

To start, launch a terminal window. Once it’s open, gain a root shell using su or sudo -s.

su -

Or

sudo -s

Now that the terminal shell has root access follow the instructions to update the Grub bootloader that match the Linux distribution you use.

Ubuntu/Debian

On Ubuntu Linux and Debian there’s no need to fill out a long command if you want to finalize changes to the Grub bootloader. Just run the update-grub command!

update-grub

Fedora/OpenSUSE

On Fedora and OpenSUSE, there isn’t a simple update-grub command like on Ubuntu. Instead, to apply the changes to your bootloader, you’ll need to run the grub2-mkconfig command.

grub2-mkconfig -o /boot/grub2/grub.cfg

Arch Linux

To update Grub settings on Arch Linux, you’ll need to call the grub-mkconfig command.

grub-mkconfig -o /boot/grub/grub.cfg

When the update Grub command finishes running, the changes should be in effect!

Undo changes to Grub

Decided you don’t like the changes made to Grub? If so, you’ll want to restore the backup made earlier. To do it, launch a terminal window and gain a root shell.

su -

Or

sudo -s

After gaining a root shell, navigate the Linux terminal session from where it opened (/) to the home folder on your Linux PC. Though, keep in mind that you’ll need to change the username portion of the command below.

cd /home/username/

Next, delete the existing Grub configuration file on your Linux system using the RM command.

rm /etc/default/grub

With the old Grub configuration file removed from the system, it’s time to restore the backup. Using the MV command, put the grub.bak file into place.

mv grub.bak /etc/default/grub

Finally, update Grub to finalize the changes made.

Debian/Ubuntu

update-grub

Arch Linux

grub-mkconfig -o /boot/grub/grub.cfg

OpenSUSE/Fedora

grub2-mkconfig -o /boot/grub2/grub.cfg

Comments are closed.