[info] Adding 2 convenient options in GRUB that most people don't have

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
1,083
Reaction score
921
Credits
8,303
Have you ever rebooted your system but missed the window of opportunity to enter BIOS/UEFI? In that case you'll have wait for the distro to start and then reboot again. Well, I'm here to give you a simple solution for that: "Reboot" & "Shut down".

1. Open grub.cfg with your favorite text editor:
Code:
sudo pluma /boot/grub/grub.cfg

2. CTRL+F to search for a word "menuentry". Scroll down after the last word "menuentry" - right where the commented lines begin.
3. Right after the bracket (this bracket: } ) for the last menuentry, add these two entries:

Code:
menuentry "Restart" --class restart {
    echo "System rebooting..."
    reboot
}

menuentry "Shut down" --class shutdown {
    echo "System shutting down..."
    halt
}

and reboot. Wait for GRUB to appear and you'll notice that now you have "Reboot" & "Shut down" entries. Thus you won't have to wait for your distro to start in order to reboot and finally be able to enter BIOS/UEFI.

GRUB_01.jpg
 


Have you ever rebooted your system but missed the window of opportunity to enter BIOS/UEFI?


For modern UEFI systems.

Code:
menuentry 'UEFI Firmware Settings' {
    fwsetup
}

You could also simply increase the time out, as I think most might do. Rather than adding an entry; since it's a built in function anyway.

Code:
sudo nano /etc/default/grub
add
Code:
GRUB_TIMEOUT=300
 
GRUB_TIMEOUT=4
All it takes is a tap on the down arrow to stop the process continuing
 
GRUB_TIMEOUT=4
All it takes is a tap on the down arrow to stop the process continuing
True. But still increasing the time out sometimes works better for some people like myself. easily distracted.

More often then not while booting up my kennel of pups my mind goes: "Uhhm, what was I about to do?". And poof, it boots the first Pup in line after seconds. Increasing time out is very handy in that situation.

The great thing about Linux is there are MANY solutions for the same problem. Gotta love that.
 
Limine might have this built-in, but its great that there are options
 
Have you ever rebooted your system but missed the window of opportunity to enter BIOS/UEFI? In that case you'll have wait for the distro to start and then reboot again. Well, I'm here to give you a simple solution for that: "Reboot" & "Shut down".

1. Open grub.cfg with your favorite text editor:
Code:
sudo pluma /boot/grub/grub.cfg
It's not going to work. grub.cfg is being re-created each time you do update-grub or install a new kernel. Your modification will be deleted. You can read in the file itself:

Code:
 /boot/grub/grub.cfg                                              
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
 
It's not going to work. grub.cfg is being re-created each time you do update-grub or install a new kernel. Your modification will be deleted. You can read in the file itself:

Code:
 /boot/grub/grub.cfg                                             
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
Good to know.
 
Solution: add it to /etc/grub.d/40_custom instead.

Entire file (it existed with lines on top, add two menu entries to the bottom of the file:
Code:
#!/bin/sh

exec tail -n +3 $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.


menuentry "Restart" --class restart {

    echo "System rebooting..."

    reboot

}


menuentry "Shut down" --class shutdown {

    echo "System shutting down..."

    halt

}

After changes are saved, do:
Code:
sudo update-grub
to apply changes.
 
In that case you'll have wait for the distro to start and then reboot again.
When you're in grub menu, distro hasn't started yet, kernel wasn't loaded.
You can press restart button on your tower to restart, or power button to shut down and this is basically the same.
And it's safe because nothing was loaded yet other than BIOS/UEFI.
 
When you're in grub menu, distro hasn't started yet, kernel wasn't loaded.
You can press restart button on your tower to restart, or power button to shut down and this is basically the same.
And it's safe because nothing was loaded yet other than BIOS/UEFI.
Laptops don't have reset button, I find this trick very useful!
 
It's not going to work. grub.cfg is being re-created each time you do update-grub or install a new kernel.
Hahahahahahahahahahaahhahahahaha, I don't know whether to laugh or to cry!

When you edit grub.cfg directly, you DON'T need to do update-grub, it works instantly. I've been doing that for 6 or 7 years already and never had a single problem. Plus, I change between different kernels as often as a schoolgirl changes her boyfriends and guess what - grub.cfg is never changed. IDK what distro or fake kernel you've been using or what you've been doing to your distro in general but nothing is what you think it is.

I guess it depends on the device behind the keyboard - whether or not it knows what it's doing.
As the old IT saying goes "Behind every broken computer there's one user who did nothing".

GRUB-CFG_EN_1800x1000.png
 
Last edited:
Hahahahahahahahahahaahhahahahaha, I don't know whether to laugh or to cry!

When you edit grub.cfg directly, you DON'T need to do update-grub, it works instantly. I've been doing that for 6 or 7 years already and never had a single problem. Plus, I change between different kernels as often as a schoolgirl changes her boyfriends and guess what - grub.cfg is never changed. IDK what distro or fake kernel you've been using or what you've been doing to your distro in general but nothing is what you think it is.

I guess it depends on the device behind the keyboard - whether or not it knows what it's doing.
As the old IT saying goes "Behind every broken computer there's one user who did nothing".
You can cry or laugh, I don't care.
The file itself says - it's being regenerated on demand, and it may lose your edits. Adding edits there is futile. If you did the opposite, and it worked for you for many years, that's fine. But it would be unwise to teach this practice to newbies who read this topic.
That's why /etc/grub.d/ directory exists - that's where user changes should go.

IDK what distro or fake kernel you've been using
All Debian-like distros declare this file as volatile and not to be edited by the user. Probably other ones too, but I am not a distro hopper to check. You can call all Debian distros to be fake, wrong, or whatever, I don't care.
 
When you edit grub.cfg directly, you DON'T need to do update-grub, it works instantly. I've been doing that for 6 or 7 years already and never had a single problem. Plus, I change between different kernels as often as a schoolgirl changes her boyfriends and guess what - grub.cfg is never changed. IDK what distro or fake kernel you've been using or what you've been doing to your distro in general but nothing is what you think it is.
That's because you use Arch Linux which only keeps one version of each installed kernel. If you use Debian or Ubuntu they keep several kernel versions so there is a previous one to boot from, so that doesn't apply there.
I guess it depends on the device behind the keyboard - whether or not it knows what it's doing.
As the old IT saying goes "Behind every broken computer there's one user who did nothing".
Keep it civil please, no need for calling anyone indirectly dumb or stupid since you are referring to PEBKAC which is not the case and even if it was then there are nicer way of saying things.
 
You can cry or laugh, I don't care.
The file itself says - it's being regenerated on demand, and it may lose your edits. Adding edits there is futile. If you did the opposite, and it worked for you for many years, that's fine. But it would be unwise to teach this practice to newbies who read this topic.
That's why /etc/grub.d/ directory exists - that's where user changes should go.


All Debian-like distros declare this file as volatile and not to be edited by the user. Probably other ones too, but I am not a distro hopper to check. You can call all Debian distros to be fake, wrong, or whatever, I don't care.
I suggest you educate yourself first, instead of repeating like a robot what someone else told you.
All Debian-based distros have post install scripts that change stuff you may not want to be changed. Mint has them included, I had to delete 90% of them on my laptop in order to prevent it from changing my settings. Thanks to that now I have the same grub and other configs on my laptop as on my computer.

More than half of the programs "installed" on the laptop are actually from the Arch repository, very little number of them actually came from the Mint repository. Technically Linux Mint on my laptop is 80% Arch and just 20% Mint. :D

Arch doesn't have such post install scripts, hence grub.cfg remains untouched after kernel update + it doesn't automatically run grub updates. These things are left to the user to decide whether or not to be done. Which makes Arch superior to all Debian-based distros. Cuz these distros tell you what your grub should look like, whereas with Arch I decide what my grub will look like.

The difference is that you obey the computer, whereas I make the computer obey ME.
 
That's because you use Arch Linux which only keeps one version of each installed kernel. If you use Debian or Ubuntu they keep several kernel versions so there is a previous one to boot from, so that doesn't apply there.
That's not true. I have two different kernels - one "rolling" and one LTS. I could install also Zen and even Hardened but for now these two are enough for me.
 
That's not true. I have two different kernels - one "rolling" and one LTS. I could install also Zen and even Hardened but for now these two are enough for me.
I am talking about kernel versions. For example 6.14.1, 6.14.2 and 6.14.3. with Debian or Ubuntu those kernel versions are all installed and then listed in Grub. With Arch Linux you have one kernel version installed whether that be linux or linux-lts(or another) and those each get updated in place and you don't see several kernel versions installed, for example 6.14.1, 6.14.2 and 6.14.3.
 
@rado84 - can you humour me, please, and
  1. provide us with the content of /etc/default/grub ?
  2. tell us if you have a file /etc/grub.d/30_uefi-firmware and if so, its contents ?

TIA

Wizard
 
@rado84 - can you humour me, please, and
  1. provide us with the content of /etc/default/grub ?
  2. tell us if you have a file /etc/grub.d/30_uefi-firmware and if so, its contents ?

TIA

Wizard
The last change of /etc/default/grub has been on 3 Sept 2024.
As for the uefi-firmware file, I don't even know why that file exists, considering my installation is MBR (it's never been uefi) and will continue to be MBR for as long as the SATA technology exists.
 

Attachments



Follow Linux.org

Members online


Top