Żarcie

GRUB - How can you improve start-up

GRUB - How can you improve start-up
Do you know what actually happens when your computer starts and how you can tune it? In this article you will see some basics regarding GRUB and what it does when you boot up. After your hardware is checked with UEFI, your machine will most likely boot into GRUB. This is the most common boot-loader for Linux. On older hardware, you have a BIOS and GRUB supports that also.

What does Grub do?

GRUB is the first thing that runs at boot. It has the responsibility to set from where your system boots, enabling mutli-boot systems. It will also pass a number of parameters to your kernel which depend on the kernel you boot into. Except for making your chosen distribution boot correctly, you can also use a theme for GRUB. That is, if you want to keep even early boot look good.

Where do you store it?

In most cases, your distribution installer will place GRUB “where appropriate”, this is not always ideal. For UEFI systems, which is almost all modern ones, you have many more options to store GRUB. Since this is the boot loader, you first choose a device, most commonly /dev/sda1, then you can choose where modules can be stored. Ordinarily, you would leave all other boot files in the /boot directory but you may need more space so there is an option to move it elsewhere. The safest way to do this is to create a partition that you mount on /boot. Because of the many features of UEFI, you will also store a lot of information in the /boot/efi directory. This will most commonly be a partition that GRUB mounts during boot. In most cases, you will simply run the grub-install script without parameters.

$ grub-install

The grub-install command is a script that looks through your disks and creates menu entries for every OS you have on your disc. This means it will create a chain-loading entry for Windows, if you have it on your disk. The 'update-grub' command does similar updates to your existing system. You can also create an ISO file where GRUB resides. You can use this to boot your machine in case you have problems with the current GRUB install.

Some basic settings

To adapt the behaviour of GRUB, you have a few standard settings. Let's go through them. The GRUBDEFAULT value, usually zero, sets which is your most common entry to boot from. To use it, you set another numerical value or you can name your entry with the 'id' tag.

menuentry 'Ubuntu' --id ubuntu-linux

GRUB_DEFAULT=ubuntu-linux

You have the option to set the latest chosen entry as the default. You do this by setting the parameter

You can also set the time it takes before GRUB boots into your default entry. Distributions put ten second for this value, you may want to set it lower when you feel that you will not tweak GRUB anymore.

GRUB_TIMEOUT=5

This entry will set the timeout to 5 seconds.

The really interesting values are for how you boot your Linux system. You will not find the values in GRUB, instead you will need to look for them in the Linux kernel documentation. Some common values are:

Name Meaning
quiet Disable all log messages
splash Shows the splash images
rfkill.defaultstate=0 Make the default rfkill state open

The list is long, you need to look for all of them in the kernel documentation.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
Some interesting features

It may seem that all the boot-loader should do is boot the system, but you can have a few special things happen to GRUB.

Themes

There are several themes available for GRUB, so you can make the menu look nice. The package is grub2-splashimages in your favourite repository (Ubuntu, at least!). You can find many more themes at Gnome Look, oddly enough!

You may want to protect your machine from intruders by protecting the GRUB install it self. NOTE: If you do not, then someone can reboot your machine and use GRUBs command line to run your OS without password. Achieving root is very easy from GRUB. Having said that, if they have their machine then they can boot from a memory stick and gain access to your files any ways.

To protect GRUB from being changed by anyone who boots your computer, you can set a password. The procedure is simple, just add the password in the GRUB config.file

password_pbkdf2 root grub.pbkdf2.sha512.10000.2CF985259F00B0E51F0226EB24E9A
DA4BFD1154D00B2F962EDFAF4EAD2297CAC0BC009F3EB0A1F15D4472985F438687A516E954A
60B977F41F383F01D33E7369.E26A847A53596996608FE4644E41DA82DA9E1CB397771816788
7C8ACA92EF1DBD95DBA13C7F111C7B753E90C3EFA1C62ED847B475B462D0A03A17419080D45F1

In the example you need a hashed password, to create it, use the below command

$ grub-mkpasswd-pbkdf2

The command asks you for a password twice and returns the HASH that corresponds to your password.

Where do you find error logs?

Now that you have started changing in GRUB, you will need to check what happened with your changes. So where does GRUB leave its logs? You have two files to examine, as shown below. They contain different details,

/var/boot/log/boot.log This file contains many other data but you can see that the boot succeeded from GRUB.

/var/log/dmesg The 'dmesg' file is renewed each day and contains all the kernel parameters that you set during last boot. Very useful to see which values are set by the system.

How do you run it manually?

If you want to try out some settings and commands while it is booting, you can do so. From the GRUB menu, you can go into command line mode and set everything up for the current boot. Nothing will be saved so you will want to take notes while trying this out. The big advantage is that you will not change what GRUB will do on the next boot, so most commands can be cleared with a new reboot.

Tweaking toolkit

You can also consider the 'grub-customizer'. This is a software package that writes to your GRUB files (/etc/grub.d/40custom). The Grub Customizer With this tool, you can change all values that you wish so be careful. Note that it does not have full documentation for GRUB so must figure out what you want to change from documentation.

Conclusion

When you dig into the documentation of GRUB, you will quickly see that choosing the correct file and partition to boot from is far from the only thing that GRUB does. If you dig deeper, you can make huge changes to your system. You can also render your system un-bootable. So always have backups and an alternative media to boot from.

Gry 5 najlepszych gier zręcznościowych dla systemu Linux
5 najlepszych gier zręcznościowych dla systemu Linux
W dzisiejszych czasach komputery to poważne maszyny używane do gier. Jeśli nie możesz uzyskać nowego wysokiego wyniku, będziesz wiedział, o co mi chod...
Gry Bitwa o Wesnoth 1.13.6 Wydanie rozwojowe
Bitwa o Wesnoth 1.13.6 Wydanie rozwojowe
Bitwa o Wesnoth 1.13.6 wydana w zeszłym miesiącu jest szóstą wersją rozwojową w 1.13.Seria x i zapewnia szereg ulepszeń, w szczególności w interfejsie...
Gry Jak zainstalować League Of Legends na Ubuntu 14.04
Jak zainstalować League Of Legends na Ubuntu 14.04
Jeśli jesteś fanem League of Legends, to jest okazja do przetestowania League of Legends. Pamiętaj, że LOL jest obsługiwany w PlayOnLinux, jeśli jeste...