Warm greetings fellow Linux-and-FOSS lovers! πππβ¨π€
Welcome to the 9th installment of Let's Learn Linux! In this issue I want to introduce you to the GRUB and the boot menu that it can create. GRUB is a very versatile and adaptable application. It has a huge number of options to tailor itself to all manner of setups and hardware. While there are many other bootloader and boot managers for Linux, such as syslinux, systemd-boot, rEFInd, to name a few, GRUB is the default bootloader for most Linux distributions. Some bootloaders/boot managers work for the legacy BIOS/MBR boot, while others are exclusively for the newer UEFI/GPT boot. GRUB is versatile enough to work with either.
What we call GRUB today is actually GRUB2. It is a rewrite of the original GRUB code. While the original version of GRUB was simpler to use, it was far less flexible, which is in part what prompted the rewrite. The present version of GRUB is so flexible that it can be used to create a boot manu for not only multiple distributions of Linux, but also for other operating systems as well, such as Windows or MacOS. Or in my case one distribution, Arch Linux, but with boot entries for many different kernels.
The default GRUB boot menu is quite simple, and rather boring, being black-and-white text.
The GRUB boot menu for the Ubuntu live/installation media.
Very thankfully the GRUB boot menu can me modified in all manner of ways to make it more attractive and interesting. Themes and background images can be used, the font and font size and color can be changed, among other options.
This is the GRUB boot menu for all three of my Arch installations.
Once you understand the basics of GRUB, it's actually quite easy to use. If you don't understand it, things can be frustrating. I used GRUB on my old Dell for quite a while before I finally dove into actually learning it. I used to use an application called grub-customizer. In the end, however, I found that it would utterly screw up the code in the GRUB configuration files. That's when I decided to just learn to do it myself. Once I did, I found how easily I could customize it.
To do what I do with GRUB, there are only two terminal commands and two configuration files. I originally used this setup on the old BIOS/MBR Dell, then when I got the new Dell that died after one month and twenty days, I had to adapt to its quirky and rather frustrating UEFI firmware. That process took me twenty days. Once I figured it out, then I could replicate it across all three of my Arch installations. When I got my marvelous new ASUS, getting everything working again was incredibly simple and quick, exactly as it should be. Now that I understand how to work with UEFU/GPT systems, things are a lot less confusing and frustrating. Since all newer computers have EUFI firmware and UEFI/GPT boot, I'll use the command for those systems. The first command to run is the one to register GRUB with the UEFI firmware, and create a EUFI boot entry.
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub --recheck
Once that command runs without errors, then running the next command (if os-prober is installed and enabled) will add boot-menu entries for all kernels and operating systems.
grub-mkconfig -o /boot/grub/grub.cfg
That's the quick and easy way that will give you a basic black-and-white GRUB boot menu. For many people that is fine. I am not one of those people, however. I need to make my systems beautiful and elegant, and that requires customization. The first step of that process is to add various customization information to the default GRUB configuration file found in the /etc directory.
/etc/default/grub
## GRUB boot loader configuration
GRUB_DEFAULT=saved
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="splash loglevel=3 udev.log-priority=3 rd.udev.log_priority=3 vt.global_cursor_default=0 sysrq_always_enabled=1 ibt=off nvidia_drm.modeset=1 rhgb rd.driver.blacklist=nouveau nouveau.modeset=0 video=vesafb:off efifb:off"
# efifb:on
GRUB_FONT="/boot/grub/fonts/DejaVuSansMono-Bold.pf2"
# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt fat"
# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y
# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu
# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console
# Uncomment to disable graphical terminal
GRUB_TERMINAL_OUTPUT=gfxterm
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=1280x800x32,auto
# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep
# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="light-cyan/black"
# Uncomment one of them for the gfx desired, a image background or a gfxtheme
GRUB_BACKGROUND="/boot/grub/themes/Sacred-Interconnection.jpg"
#GRUB_THEME="/path/to/gfxtheme"
# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"
# Uncomment to make GRUB remember the last selection. This requires to
# set 'GRUB_DEFAULT=saved' above.
GRUB_SAVEDEFAULT=true
# Uncomment to disable submenus in boot menu
#GRUB_DISABLE_SUBMENU=y
#Disable OS Prober
GRUB_DISABLE_OS_PROBER=true
This is where themes, fonts, colors, background images, menu timeout, os-prober behavior, Linux-command-line commands, screen resolution and color depth, and lots of other useful things can be set. Anything beginning with the # symbol are commented out, which means they will not be read by GRUB.
The next step to customizing the boot menu is to create a drop-in GRUB configuration file. Lower-numbered files are read first, so I used the name 06_custom, which is placed in another location in the /etc directory.
/etc/grub.d/06_custom
The basic structure of this file can be taken from the generated grub configuration file in the /boot directory. Just a note, I would not suggest using my examples as your templates, as I have the UUIDs of my specific hard drive partitions, which would not work on hour system.
/boot/grub/grub.cfg
Once the basic structure is added to the 06_custom file, then the individual entries can be modified as desired. I don't like how the default GRUB menu structure is organized, so I redo it completely. Below is an example of the top of the 06_custom file with the very first entry. The initial #!/bin/sh in that file is not a comment, but marks the file as executable, and is necessary. Just after menuentry, where the single quotes are visible, is the first field that should be edited, as that is the name that will appear in the boot menu. Anything after echo inside single quotes can be changed as desired, as that's what appears on the screen after the boot entry is selected.
#!/bin/sh
echo 1>&2 "Adding Arch Linux"
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.
#/dev/sda1
menuentry 'Arch Linux (Arch Official Kernel)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c' {
savedefault
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod fat
set root='hd1,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 4F61-707D
else
search --no-floppy --fs-uuid --set=root 4F61-707D
fi
echo 'Loading Arch Linux Official Kernel'
linux /vmlinuz-linux root=UUID=ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c rw
echo 'Loading Initial Ramdisk...'
initrd /intel-ucode.img /initramfs-linux.img
}
If like me you have multiple kernels, then the next bits of information to change as needed are the actual names of the Linux kernels and initial ramdisks, which can be seen below after linux and initrd. The names have to match how they are in the /boot directory, or GRUB won't be able to find them, and they won't boot.
menuentry 'Arch Linux (CachyOS Kernel)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-cachyos-advanced-ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c' {
savedefault
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod fat
set root='hd1,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 4F61-707D
else
search --no-floppy --fs-uuid --set=root 4F61-707D
fi
echo 'Loading Arch Linux CachyOS Kernel'
linux /vmlinuz-linux-cachyos root=UUID=ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c rw
echo 'Loading Initial Ramdisk...'
initrd /intel-ucode.img /initramfs-linux-cachyos.img
}
Those are just two examples from that file. I have thirteen different kernels, each with their own entry in the file. There are also entries for fallback initial ramdisks for each of those thirteen kernels too, which are used in case something driver-related goes awry. I keep those in the 06_custom file, but I hide them in a submenu, to keep things cleaner and neater. Again, I give the first entry at the top of the submenu.
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c' {
menuentry 'Arch Linux (Official Kernel - Fallback)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c' {
savedefault
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod fat
set root='hd1,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 4F61-707D
else
search --no-floppy --fs-uuid --set=root 4F61-707D
fi
echo 'Loading Arch Linux Official Kernel (Fallback)'
linux /vmlinuz-linux root=UUID=ec4e85d6-ccb5-4d18-9fd1-f31fd30b304c rw
echo 'Loading Initial Ramdisk...'
initrd /intel-ucode.img /initramfs-linux-fallback.img
}
Once all the menu entries are added, and the file is saved, it must be made executable, which can be done via the command line of via graphical means. The last step whenever you modify either or both of these two configuration files, is to run the following command one more time.
grub-mkconfig -o /boot/grub/grub.cfg
Once that runs without errors (and there may be, so it's necessary to be careful adding everything), you can reboot and you should see your spify new GRUB boot menu! GRUB has so many options, and this is just working with the ones I use myself.
That brings me to the end of this 9th installment of Let's Learn Linux! I truly hope that this information is useful, and that this post was engaging, interesting, and perhaps even inspiring! Until next week! π π π β¨ π€
All images were taken with my Motorola G Power Android Phone or are screen shots from my laptop.
Thank you all so much who have helped me get to where I am today, and allowing me to share more of the beauty and magic from my life and my world with you, and for your continuous appreciation and support! I am truly deeply grateful! πππβ¨π€
If you'd like to find me on other alternative platforms where I have accounts (I spend most of my time here on Hive), click on this signature image below to go to my LinkTree page.
If you'd like to send me a BTC Lighting Tip (made possible by the fantastic work of brianoflondon on @v4vapp), just scan the QR image below. π
Sources
Signature image created by @doze, and the dividers made by @thepeakstudio, with all tweaked to their present form by me.
Banner image created by me using Polish, with the Arch Linux logo converted into ASCII art, and Tux the Linux Peguin created by Larry Ewing.
The rewards earned on this comment will go directly to the people( @tydynrain ) sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.
https://leofinance.io/threads/@sammyhive/re-leothreads-x8mru
The rewards earned on this comment will go directly to the people ( sammyhive ) sharing the post on LeoThreads,LikeTu,dBuzz.
What an upgrade from a black screen to that spectacular design! GRUB seems pretty complicated at first, but once the parameters are understood, it becomes much simplier. Seems like technology is often like that - it seems very foreign and difficult at first, but then once you're familiar with it, it's actually becomes pretty easy.
!ALIVE
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @ironshield. (4/30)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
Yes, it really is! I always have to make my system look nice as well as function well! Yep, exactly! Once you come to understand it, it's actually quite simple and logical! Bingo, exactly on technology! Everything I know about technology and Linux I learned just by doing it and figuring it out myself! I love the challenges and the satisfaction! Thank you Benjamin! π π π β¨ π€
Because of my love for learning new things, I can't thank you enough @tydynrain for your detailed explanation of LINUX: GRUB BOOT MENU. I appreciate. Best wishes.
You're so welcome @emjeak, most definitely! I love sharing and teaching about Linux! Thank you so much! I wish you a beautiful week! π π π β¨ π€
Awesome. Very informative. Your teaching skill is superb and step by step discussion with proof
Thank you so much Sammy! I deeply appreciate your kind words. I do my best! π π π β¨ π€
Very nice sharing! Have a nice day!
Thanks much @vaynard86! Have a wonderful day and new week! π π π β¨ π€
I have only used the basic Grub to install Linux. Thanks for the informative post. !ALIVE
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @mypathtofire. (9/20)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
That's the experience of many people, as most don't even know thst GRUB can be customized. Absolutely Steve, you're most welcome! Thank you! π π π β¨ π€
Awesome one bro thanks for the info
@tydynrain
As an extra reward for spotlighting on @heartbeatonhive here are some tips have a blessed and wonderful day
!ALIVE
!CTP
!PGM
!PIZZA
!MEME
!BBH
Thank you again so much Ben! It's my absolute honor, pleasure, and privilege to share! π π π β¨ π€
@tydynrain! Your Content Is Awesome so I just sent 1 $BBH (Bitcoin Backed Hive) to your account on behalf of @benthomaswwd. (1/20)
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @benthomaswwd. (1/20)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
BUY AND STAKE THE PGM TO SEND A LOT OF TOKENS!
The tokens that the command sends are: 0.1 PGM-0.1 LVL-0.1 THGAMING-0.05 DEC-15 SBT-1 STARBITS-[0.00000001 BTC (SWAP.BTC) only if you have 2500 PGM in stake or more ]
5000 PGM IN STAKE = 2x rewards!
Discord
Support the curation account @ pgm-curator with a delegation 10 HP - 50 HP - 100 HP - 500 HP - 1000 HP
Get potential votes from @ pgm-curator by paying in PGM, here is a guide
I'm a bot, if you want a hand ask @ zottone444
Credit: ieronimus
Earn Crypto for your Memes @ HiveMe.me!
Lovely, that is a good one from a great instructor. Keep it up.
!ALIVE
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @oasiskp2. (3/20)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
Thank you so much @oasiskp2, I very much appreciate that! π π π β¨ π€
A bit complicated, anyway I bookmark your post for future use if I want to play again with linux π
!ALIVE
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @chapelle. (3/20)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
It seems complicated at first, but once you start to understand it, it's actually quite simple! I hope that you find it useful! Thank you! π π π β¨ π€
Wow very informative my friend i am sure this will help many people out have the best one @tydynrain
!ALIVE
!BBH
I will be including this content on the @heartbeatonhive curation collection
Thank you so much Ben, I deeply appreciate that! That's my desire, intention, and hope! Have an excellent start to your new week brother! π π π β¨ π€
@tydynrain! Your Content Is Awesome so I just sent 1 $BBH (Bitcoin Backed Hive) to your account on behalf of @heartbeatonhive. (7/20)
@tydynrain! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @heartbeatonhive. (7/30)
The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.
$PIZZA slices delivered:
@benthomaswwd(1/10) tipped @tydynrain