15

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.

Christian Wolf
  • 308
  • 3
  • 9
  • 3
    Yes: http://unix.stackexchange.com/questions/43196/how-can-i-tell-grub-i-want-to-reboot-into-windows-before-i-reboot – HBruijn Jul 21 '14 at 14:10

2 Answers2

9

You can boot using a Grub fallback entry.

Add another stanza with either your new (or old) options, then choose the known-good as the fallback.

Look into adding the panic=5 option as well (resets a system following kernel crash)

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • You could even use your hardware's watchdog to reboot the machine if it becomes unresponsive (http://linux.die.net/man/8/watchdog). However if something goes wrong with the root filesystem you may find manual intervention is required no matter what solution you choose... – Anon Jul 22 '14 at 05:24
  • You link to the grub-legacy (grub1) documentation. The question is about grub2. I cannot find the same in the grub2 documentation. Is it possible, too? How? – augustin Sep 25 '14 at 18:14
9

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.

Christopher Karel
  • 6,442
  • 1
  • 26
  • 34
  • You link to the grub-legacy (grub1) documentation. The question is about grub2. I cannot find the same in the grub2 documentation. Is it possible, too? How? – augustin Sep 25 '14 at 18:13