GRUB is a boot loader that allows users to boot multiple operating systems and kernel configurations. After reading this tutorial, you’ll know how to define a different OS or kernel to boot by default and how to customize some boot options.
In the image below, you can see a grub menu with 3 items: Debian GNU/Linux, Advanced options for Debian GNU/Linux, and Windows 10. Because the counting starts from zero, the first item (Debian) is 0, the second item (Advanced options) is 1, and the third item (Windows) is 2.
By default, grub will boot item 0. Thus to change the boot order, you need to define the number of items you want to boot by default in the grub configuration file /etc/default/grub.
Change grub boot order
To change the boot order, prioritize a different OS or kernel configuration edit the file /etc/default/grub using any text editor you want. You can edit it using nano, as shown in the example below. Remember, you need superuser privileges to edit the grub configuration file.
Find the following line
Edit the line replacing 0 by the item number you want to boot by default. In my case, I want to change the default boot to Windows. Thus I set the third item, 2 (because the count starts from 0).
If you are editing the file using nano, exit saving the change by pressing CTRL+X and Y.
Then update grub by executing sudo update-grub as shown below.
As you can see now, Windows will boot by default.
Additional settings you can edit from /etc/default/grub
You can edit additional settings defined in the /etc/default/grub configuration file.
As you can see in the following image, below the line GRUB_DEFAULT=0, there is the line GRUB_TIMEOUT=5. This line defines the time grub will wait until booting automatically. Replace the 5 for the number of seconds you want grub to wait. For example, for grub to wait 10 seconds to boot the GRUB_DEFAULT=0, replace that line with the following line.
The line GRUB_CMDLINE_LINUX_DEFAULT=”quiet” is used to pass kernel boot options. In the screenshot above, the option is “quiet”, which means the boot process will be shown in text mode as in the screenshot below.
The quiet option provides additional transparency to the boot process allowing the user to see steps and succeed or fail.
Another option you can pass to the line GRUB_CMDLINE_LINUX_DEFAULT= is the option “splash”. If you replace “quiet” with “splash” like in the line below, the boot process won’t be displayed in text mode; you will see a logo loading instead, as shown in the following image.
Even if some people consider this option a better format (you can customize it), this option doesn’t give users a live view of the boot process.
The line GRUB_CMDLINE_LINUX_DEFAULT= can also be used to boot the system in text mode. To boot in text mode, instead of quiet or splash, you need to use the option text as shown in the screenshot below.
Exit saving the change and run:
Disable the display manager using systemctl. In my case, my display manager is LightDM. Replace lightdm with your current display manager and run the command below.
Reboot in text mode.
Now you can log in in text mode. If you want to launch a graphical session, run:
Where <DIsplayManager> must be replaced by your display manager name (e.g., gdm3).
Conclusion
As you can see, dealing with grub is very easy, and you can control the way your system boots in a few steps any Linux user level can learn. When dealing with it, the most common mistake is not remembering to run update-grub every time the file is edited. Remember, when selecting the boot order, the counting starts from zero; if you type a wrong order number, your system will not boot as expected.
The quiet option at line GRUB_CMDLINE_LINUX_DEFAULT= may be better than splash because it allows the user to see the boot process transparently.
The last section of this tutorial showing how to boot from a terminal or console is useful if your graphical environment fails to prevent you from booting the system. Also, there are associated security bugs to the graphical boot process; that’s why some users prefer to boot their systems in text mode. This would be the proper configuration for servers or devices which need to save or optimize resources. Once logged in text mode, users can start X manually with commands startx or systemctl.
I hope this tutorial was useful. Keep following Linux Hint for more Linux tips and tutorials.
from Linux Hint https://ift.tt/3whe63h
0 Comments