Talk:GRUB/Tips and tricks

From ArchWiki
Jump to navigation Jump to search

Password protection of non local system boot options

Added this note, which was deleted as it won't survive package upgrades:

To have this applied automatically with grub-mkconfig add --unrestricted to the following lines:

/etc/grub.d/10_linux
[...]
echo "menuentry '$(echo "$title" | grub_quote)' --unrestricted ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
else
echo "menuentry '$(echo "$os" | grub_quote)' --unrestricted ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
[...]

Any suggestions on how to make that work? I.e. is it best to write a custom hook? Lahwaacz?

—This unsigned comment is by Drew33 (talk) 16:09, 8 August 2017‎. Please sign your posts with ~~~~!

I have no idea... -- Lahwaacz (talk) 16:14, 8 August 2017 (UTC)

I'm using this successfully:

/etc/pacman.d/hooks/grub.hook
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = grub
[Action]
Description = Unrestricting GRUB's linux boot entries...
Depends = sed
When = PostTransaction
Exec = /usr/bin/sed -i -e 's/--class os/--class os --unrestricted/g' /etc/grub.d/10_linux

After this hook is added reinstall GRUB and regenerate grub.cfg:

# pacman -S grub
# grub-mkconfig -o /boot/grub/grub.cfg

Slimmer (talk) 08:02, 3 July 2019 (UTC)


I am now using this custom entry in /etc/grub.d. This works by altering the menuentry_id_option variable that is used for every OS menuentry.

/etc/grub.d/09_make_OS_entries_unrestricted
#!/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_id_option="--unrestricted $menuentry_id_option"

Beckab (talk) 14:54, 12 August 2019 (UTC)

Play a tune

I was writing the first part of Pictures at an exhibition by Mussorgsky: Promenade, but i didn't finish it.. :
these are up to number 2 on the score, i think.. (it's trumpets 1,2 as seen on imslp.org, tempo was set arbitrarily at 130 ) Tsester (talk) 08:03, 13 February 2016 (UTC)
GRUB_INIT_TUNE="260 \
392 2 349 2 466 2 523 1 698 1 588 2 524 1 698 1 588 2 466 2 524 2 392 2 349 2 0 2 \
392 2 349 2 466 2 523 1 698 1 588 2 524 1 698 1 588 2 466 2 524 2 392 2 349 2 0 2 \
349 2 392 2 294 2 349 1 392 1 262 2 392 1 440 1 349 2 698 2 588 2 524 1 466 1 349 2 0 2 \
349 2 392 2 294 2 349 1 392 1 311 2 466 1 524 1 415 2 830 2 698 2 622 1 554 1 415 2"

Hiding Boot Menu except on keypress contains hardcoded 3s timeout

I had one heck of a time hunting down a mysterious 3 second timeout that wouldn't go away after I set up (and forgot) the "hide boot menu" trick that creates the file 31_hold_shift.

31_hold_shift contains a code block

 if keystatus; then
   if keystatus --shift; then
     set timeout=-1
   else
     set timeout=0
   fi
 else
   if sleep$verbose --interruptible 3 ; then
     set timeout=0
   fi
 fi

This effectively hardcodes a 3 second timeout, regardless of the TIMEOUT setting in /etc/default/grub, unless a key is pressed on bootup. I modified it to

 if keystatus; then
   if keystatus --shift; then
     set timeout=-1
   else
     set timeout=0
   fi
 fi

Now it does what I want, a $TIMEOUT second timeout unless shift or another key is pressed. I shall leave this page here a bit and replace the gist for the script unless there is disagreement.

Cmc (talk) 20:34, 13 January 2020 (UTC)