33

I have Ubuntu Server 11.04, but it is headless (no monitor). The only way I want to be able to access it is remotely via SSH. But, sometimes, say after a power loss, when the server restarts, it will get stuck on the Grub boot menu, and it won't count down. It will just hang there waiting for me to choose the first boot entry. This means I have to go there and plug in a monitor and keyboard.

But I can't do that remotely. How can I force it to continue booting to boot entry 1 (default) regardless of power loss or whatever?

10

The answer to this one can be found in the grub file /etc/grub.d/00_header

make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=${2}
fi
EOF
}

Setting the timeout value to -1 will stop the count down. Change the value to a value > 0 i.e. set timeout=10

this section of the file would look like

make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=10
else
  set timeout=${2}
fi
EOF
}

Then run

sudo update-grub2
| improve this answer | |
  • If I run sudo shutdown now -r, but I ping the system and notice it hasn't come back online, when I manually turn it off and on again, is there any place to check why it crashed out? – nLinked Aug 4 '11 at 23:33
  • has it got stuck at the grub again? or has it just shutdown? Do a man "shutdown" there are a couple of files where stuff is written to. – fossfreedom Aug 4 '11 at 23:39
  • Sometimes right after grub I'll get a black screen, then nothing. Takes a reset to get it working. Sometimes on sudo reboot or "sudo shutdown -r now" it will not reboot, just hang before even rebooting. I've just done an fschk and repaired broken packages which actually made it download a new kernal. Will see if this helps... – nLinked Aug 5 '11 at 15:24
  • the change to the grub will not cause or exacerbate what you are seeing. Doing a fsck is a good idea anyway after a power-cut. Broken packages reads as if you have been doing some failed installs, or an install was in-progress when you rebooted/had a power-cut. If necessary - create another question. However, sounds like you've already got a handle on this. – fossfreedom Aug 5 '11 at 15:32
  • 5
    I think this solution isn't permanent because it will be overwritten if grub packages receive updates. The "other solution" to use "GRUB_RECORDFAIL_TIMEOUT" is more appropriate. So, I have respectfully downvoted this solution and upvoted the other. – rik-shaw Sep 24 '13 at 13:11
40

As of Ubuntu 12.04, a more straightforward, but nevertheless undocumented, solution is to use /etc/default/grub to override the recordfail timeout:

GRUB_TIMEOUT=10
GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT

Then run sudo update-grub to apply the changes.


The fact that such option is completely undocumented is just too bad.

Actually, the support for GRUB_RECORDFAIL_TIMEOUT was added in the middle of the 12.04 cycle, starting from version 1.99-21ubuntu3.3:

  grub2 (1.99-21ubuntu3.3) precise-proposed; urgency=low

[ Ben Howard ]
* Parameterization of recordfail setting. This allows users to define the
  default time out of GRUB when recordfail has been set. The curren
  setting causes hangs on headless and appliances where access to the
  console is limited or prohibited.  (LP: #669481)  [1]

-- Louis Bouchard <louis.bouchard@canonical.com>  Tue, 21 Aug 2012 10:51:58 +0200

More detailed information from LaunchPad.

| improve this answer | |
  • This works but still got white on black kernel spam after 2nd reboot, after hibernation. – fleamour Dec 29 '19 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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