Technology Blog

Grub Reboot to New Kernel Once

by on Sep.09, 2009, under Linux

Grub Booting

Grub Booting

The servers I work on are almost never in front of me. Instead they are in dark rooms humming away gracefully. When I need to do a kernel upgrade or recompile I need to reconfigure grub to reboot into the new kernel. So normally you would just edit /etc/grub.conf and change –save-default=X to be the correct number.

Well what happens if you change that and your new kernel doesn’t boot? Your left black screened with no one looking at the server to tell you what’s wrong with it. This leaves you calling the data center (or your host) asking for a technician to take a look at the server, at the very least reboot login to single user mode, edit the config, and then restart into the old kernel. Sounds time consuming huh?

Yup, and then you still have to figure out what you did wrong, reboot, and pray again. With more and more host offering instant reboots in their control panels, you could do this whole operation without ever bothering anyone at the data center.

Instead of changing /etc/grub.conf just type in the following at the command line:

savedefault --default=X --once

X of course being the number kernel you would like to boot into.

Now if your server doesn’t boot properly into the new kernel you only need to power cycle it to get it to boot into the old working kernel. Host doesn’t offer power cycling? At the very least the data center staff will appreciate the joy of not having to log into your server and fix things. They are usually much quicker at handling simple reboot request than configuration changes. If they are busy they can at least have the janitor go over and power cycle the server, instead of someone who is a grub expert! Point taken?

Be Sociable, Share!

1 Comment for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...