(I'm adapting this answer from https://unix.stackexchange.com/a/11431/73, because it happens to work the same even though the question is different)
First you need to do some prep work in /boot/grub/grub.conf
. Change default
to saved
. In every OS block, add savedefault 0
, where 0 is the index of whichever kernel you want it to default to unless told otherwise. Write the value 0
to the file /boot/grub/default
, so GRUB will know which default to use on your next reboot (before any of those savedefault
directives have executed).
Now at any time before you reboot, you can change the value in /boot/grub/default
to change what the default will be on the next boot. If you set it to 1
, the second entry in the GRUB list will be the default. As soon as it starts booting, GRUB will execute the savedefault 0
directive and change the default back to 0
, so on the subsequent boot you'll switch back to defaulting to 0.
To change the default, you can use grub-set-default
, which takes the index number and writes it to that file. So, make an alias/script that does:
grub-set-default 1
shutdown -hr now
And when you run it, GRUB will reboot into the second entry in the list. The next time you reboot, it'll switch back to the first (or whichever you specified)
/boot/grub/
gets overwritten by Grub scripts running over the user configuration files in/etc/grub
and/etc/default/grub
. This is triggered often on updates and would make changes non-persistent. – gertvdijk Dec 06 '12 at 23:14