[ale] sometimes you just need to reboot NOW!

Michael Trausch mike at trausch.us
Wed Jul 30 10:41:45 EDT 2014


On 7/29/2014 11:09 PM, Jim Kinney wrote:
> So you're working away and suddenly you get a console error message:
> Kernel: BUG: <fill in your fav thing to break here>
> and that console pukes and locks.
> You're loged in remote over and ssh session and screen. You can't reattach
> to that screen session and then, WHAM, another one pops in and informs you
> also that cpu core #19 has timed out for the past 67 seconds.
Something I have had to do many times in the past, as many environments 
have no sysrq hooks enabled...

#include <stdio.h>
#include <unistd.h>
#include <linux/reboot.h>

int
main() {
   /*
    * Should not return; forces an un-sync'd kernel reboot.
    */
   int status = reboot(LINUX_REBOOT_CMD_RESTART);

   // If we're still here...
   fprintf(stderr, "Failed to reboot system---are you root?");
   return 1;
}

Have this handy!  32-bit and 64-bit statically-linked versions (against 
uclibc or newlib---NOT glibc) which you can easily transfer over an SSH 
session in hexdump form.

When needed, place this file in /dev and call it as /dev/reboot32 or 
/dev/reboot64.  You can use sftp/scp if the system stays up long 
enough.  If not, do the following song and dance:

  * On local system: xxd /path/to/reboot-file (or have
    /path/to/reboot-file.hex handy!), copy to clipboard
  * On remote system: paste through xxd-reverse pipe, save in /dev.
  * On remote system: chmod +x the damn thing and run it.

You can have a script on your system that automates the process. I have 
done this so rarely that I've not bothered writing one.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20140730/f1ce9e03/attachment.html>


More information about the Ale mailing list