Linux – way to create a “one-time” boot entry in grub

bootconfigurationgrublinux

I have the following issue: I have a small server (Debian based) to which I can connect remotely (VPN/SSH connection). Now I want to change some boot options (in fact I want to migrate my root file system to another partition) and therefore I have to reboot my system.

In fact I am afraid of the possibility that something goes horribly wrong and neither SSH nor VPN can start up. In this scenario, I had to go the server personally which is located quite far away. I could ask someone to restart (in case of kernel panic,…) but there is nobody qualified to repair the system. Thus my question:

Is there a possibility to make a entry in the GRUB2 configuration that makes an entry the default only for the very next boot? So if there is a problem I can just reboot and recover with the old system? If the boot runs through without problems (which I would hope for) I could alter grub such that it boots by default from the new system.

Best Answer

You can indeed use Grub to boot once only. You can also specify a fallback boot. Essentially, you use default saved at the start of your grub.conf, to indicate that you want to boot a saved entry by default. Then at the end of your experimental boot, use savedefault # to set the older boot options as the new saved value. So that every time you boot the new kernel, grub saves the older one as the next boot.

Lastly, you can always do your test as a manual boot, if you can access the Grub loader. That way, a reboot will always use your original default.

Related Topic