Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
3  

2 Answers 2

up vote 9 down vote accepted

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.

share|improve this answer
    
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 at 18:13

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)

share|improve this answer
    
You could even use your hardware's watchdog to reboot the machine if it becomes unresponsive (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 at 5: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 at 18:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.