Ask Your Question

Revision history [back]

@hello: oopsie, my bad. I'll try to investigate later on. I just need to find one machine to explode. :P

@hello: oopsie, Disclaimer: Since my bad. I'll try to investigate later on. comment was accidentally converted to an answer, now I just feel the moral obligation to write a proper answer, which ruins my original plan of doing nothing. :) Oh well.

As mentioned in one of my comments, there was an urban legend of holding the Shift key during boot to dismiss the timeout setting. Not like an undocumented feature (actually the GRUB documentation clearly says that this statement is false); but there's an interesting way to write a fallback mode using keystatus (from the amazing documentation):

Command: keystatus [--shift] [--ctrl] [--alt]

Return true if the Shift, Control, or Alt modifier keys are held down, as requested by options. This is useful in scripting, to allow some user control over behaviour without having to wait for a keypress.

Checking key modifier status is only supported on some platforms. If invoked without any options, the keystatus command returns true if and only if checking key modifier status is supported.

The idea is to make GRUB change its timeout setting on runtime if any combination of Ctrl, Alt or Shift is pressed while the little rascal is being invoked. :) Let's see how to achieve this.

First things first, I'm on my Fedora 20, with GRUB2. I do not recommend editing /boot/grub2/grub.cfg at all simply because it will be overwritten every time on a kernel update. The best approach IMHO is to use the proper place to add our custom verification, which is /etc/grub.d/40_custom:

[root@alexandria ~]# cat /etc/grub.d/40_custom 
#!/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.

The file is pretty much self-explanatory. :) We need to find one introduce our code after the comments. So let's write it:

#!/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.

#       \\_('<  Quack!
#        \___)

# my default timeout value will be zero
set timeout=0

# so far so good, but let's add a trick to allow us to 
# have some air in case something terrible goes on

# GRUB will check if the Shift is pressed now, and
# if so, gives us more time -- you can add any key
# combination you feel like
if keystatus --shift ; then
    set timeout=20
if

And that's it. :) But that's not all, we need to update GRUB2 using:

[root@alexandria ~]# grub2-mkconfig -o /boot/grub2/grub.conf

Important: As mentioned in the last paragraph of the documentation, checking key modifier status is only supported on some platforms. I tried it on a virtual machine to explode. :P

setup and it didn't work at all (a F20 image on VirtualBox), but on a physical machine (my development laptop) everything worked fine (as expected). So you milleage might vary. :)

click to hide/show revision 3
No.3 Revision

Disclaimer: Since my comment was accidentally converted to an answer, now I feel the moral obligation to write a proper answer, which ruins my original plan of doing nothing. :) Oh well.

As mentioned in one of my comments, there was an urban legend of holding the Shift key during boot to dismiss the timeout setting. Not like an undocumented feature (actually the GRUB documentation clearly says that this statement is false); but there's an interesting way to write a fallback mode using keystatus (from the amazing documentation):

Command: keystatus [--shift] [--ctrl] [--alt]

Return true if the Shift, Control, or Alt modifier keys are held down, as requested by options. This is useful in scripting, to allow some user control over behaviour without having to wait for a keypress.

Checking key modifier status is only supported on some platforms. If invoked without any options, the keystatus command returns true if and only if checking key modifier status is supported.

The idea is to make GRUB change its timeout setting on runtime if any combination of Ctrl, Alt or Shift is pressed while the little rascal is being invoked. :) Let's see how to achieve this.

First things first, I'm on my Fedora 20, with GRUB2. I do not recommend editing /boot/grub2/grub.cfg at all simply because it will be overwritten every time on a kernel update. The best approach IMHO is to use the proper place to add our custom verification, which is /etc/grub.d/40_custom:

[root@alexandria ~]# cat /etc/grub.d/40_custom 
#!/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.

The file is pretty much self-explanatory. :) We need to introduce our code after the comments. So let's write it:

#!/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.

#       \\_('<  Quack!
#        \___)

# my default timeout value will be zero
set timeout=0

# so far so good, but let's add a trick to allow us to 
# have some air in case something terrible goes on

# GRUB will check if the Shift is pressed now, and
# if so, gives us more time -- you can add any key
# combination you feel like
if keystatus --shift ; then
    set timeout=20
if
fi

And that's it. :) But that's not all, we need to update GRUB2 using:

[root@alexandria ~]# grub2-mkconfig -o /boot/grub2/grub.conf

or if you have an EFI machine

[root@alexandria ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Important: As mentioned in the last paragraph of the documentation, checking key modifier status is only supported on some platforms. I tried it on a virtual machine setup and it didn't work at all (a F20 image on VirtualBox), but on a physical machine (my development laptop) everything worked fine (as expected). So you milleage might vary. :)

It has been tested by two people though (on physical hardware and it works fine.

Quack!

click to hide/show revision 4
No.4 Revision

Disclaimer: Since my comment was accidentally converted to an answer, now I feel the moral obligation to write a proper answer, which ruins my original plan of doing nothing. :) Oh well.

As mentioned in one of my comments, there was an urban legend of holding the Shift key during boot to dismiss the timeout setting. Not like an undocumented feature (actually the GRUB documentation clearly says that this statement is false); but there's an interesting way to write a fallback mode using keystatus (from the amazing documentation):

Command: keystatus [--shift] [--ctrl] [--alt]

Return true if the Shift, Control, or Alt modifier keys are held down, as requested by options. This is useful in scripting, to allow some user control over behaviour without having to wait for a keypress.

Checking key modifier status is only supported on some platforms. If invoked without any options, the keystatus command returns true if and only if checking key modifier status is supported.

The idea is to make GRUB change its timeout setting on runtime if any combination of Ctrl, Alt or Shift is pressed while the little rascal is being invoked. :) Let's see how to achieve this.

First things first, I'm on my Fedora 20, with GRUB2. I do not recommend editing /boot/grub2/grub.cfg at all simply because it will be overwritten every time on a kernel update. The best approach IMHO is to use the proper place to add our custom verification, which is /etc/grub.d/40_custom:

[root@alexandria ~]# cat /etc/grub.d/40_custom 
#!/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.

The file is pretty much self-explanatory. :) We need to introduce our code after the comments. So let's write it:

#!/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.

#       \\_('<  Quack!
#        \___)

# my default timeout value will be zero
set timeout=0

# so far so good, but let's add a trick to allow us to 
# have some air in case something terrible goes on

# GRUB will check if the Shift is pressed now, and
# if so, gives us more time -- you can add any key
# combination you feel like
if keystatus --shift ; then
    set timeout=20
fi

And that's it. :) But that's not all, we need to update GRUB2 using:

[root@alexandria ~]# grub2-mkconfig -o /boot/grub2/grub.conf

or if you have an EFI machine

[root@alexandria ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Important: As mentioned in the last paragraph of the documentation, checking key modifier status is only supported on some platforms. I tried it on a virtual machine setup and it didn't work at all (a F20 image on VirtualBox), but on a physical machine (my development laptop) everything worked fine (as expected). So you milleage might vary. :) It has been tested by two people though (on physical hardware and it works fine.

Quack!

Disclaimer: Since my comment was accidentally converted to an answer, now I feel the moral obligation to write a proper answer, which ruins my original plan of doing nothing. :) Oh well.

As mentioned in one of my comments, there was an urban legend of holding the Shift key during boot to dismiss the timeout setting. Not like an undocumented feature (actually the GRUB documentation clearly says that this statement is false); but there's an interesting way to write a fallback mode using keystatus (from the amazing documentation):

Command: keystatus [--shift] [--ctrl] [--alt]

Return true if the Shift, Control, or Alt modifier keys are held down, as requested by options. This is useful in scripting, to allow some user control over behaviour without having to wait for a keypress.

Checking key modifier status is only supported on some platforms. If invoked without any options, the keystatus command returns true if and only if checking key modifier status is supported.

The idea is to make GRUB change its timeout setting on runtime if any combination of Ctrl, Alt or Shift is pressed while the little rascal is being invoked. :) Let's see how to achieve this.

First things first, I'm on my Fedora 20, with GRUB2. I do not recommend editing /boot/grub2/grub.cfg at all simply because it will be overwritten every time on a kernel update. The best approach IMHO is to use the proper place to add our custom verification, which is /etc/grub.d/40_custom:

[root@alexandria ~]# cat /etc/grub.d/40_custom 
#!/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.

The file is pretty much self-explanatory. :) We need to introduce our code after the comments. So let's write it:

#!/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.

#       \\_('<  Quack!
#        \___)

# my default timeout value will be zero
set timeout=0

# so far so good, but let's add a trick to allow us to 
# have some air in case something terrible goes on

# GRUB will check if the Shift is pressed now, and
# if so, gives us more time -- you can add any key
# combination you feel like
if keystatus --shift ; then
    set timeout=20
fi

And that's it. :) But that's not all, we need to update GRUB2 using:

[root@alexandria ~]# grub2-mkconfig -o /boot/grub2/grub.conf

or if you have an EFI machine

[root@alexandria ~]# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Important: As mentioned in the last paragraph of the documentation, checking key modifier status is only supported on some platforms. I tried it on a virtual machine setup and it didn't work at all (a F20 image on VirtualBox), but on a physical machine (my development laptop) everything worked fine (as expected). So you milleage might vary. :)

Quack!

Update 1: as hedayat mentioned in the comments, a kernel update triggers grubby instead of grub2-mkconfig, so grub.cfg is not affected at all. As the documentation states it:

It is generally safe to directly edit /boot/grub2/grub.cfg in Fedora. grubby in Fedora patches the configuration when a kernel update is performed and will try to not make any other changes than what is necessary. (Other distributions, in particular Debian and Debian-derived distributions provide a software patch that adds an update-grub command which is neither included nor needed in Fedora.) Manual changes might however be overwritten with grub2-mkconfig next time the system is upgraded with anaconda. Some customizations can be placed in /etc/grub.d/40_custom or /boot/grub2/custom.cfg and will survive running grub2-mkconfig.

Every day I'm shuffling learning new things. :)