Is there a way to reboot a Linux system (Debian in particular) without rebooting the hardware?

I have a RAID controller that takes a bit to get itself running before the OS starts up, and I would like it if there was a way to quickly reboot the Linux OS without having to go through the whole reboot process of restarting the RAID controller, etc.

  • 6
    All UEFI based systems are able to switch OS whtout rebooting. You also havekexec()which is likeexec(), but for Unix kernels. – user2284570 Mar 25 '15 at 3:08

I use kexec-reboot on nearly all of my production systems.

It works incredibly well, allowing me to bypass the long POST time on HP ProLiant servers and reduce the boot cycle from 5 minutes to ~45 seconds.

See: https://github.com/error10/kexec-reboot

The only caveat is that it doesn't seem to work on RHEL/CentOS 6.x systems booting UEFI. But most sane OS/hardware combinations work.

  • 63
    I wrote that! But it still works pretty well... – Michael Hampton Mar 25 '15 at 0:27
  • 1
    Fascinating. So how does the actual process look? According to an article by Hariprasad Nellitheertha (linked to from the kexec wikipedia page), "Unlike the normal reboot process, kexec does not perform a clean shutdown of the system before rebooting. It is left to you to kill all applications and unmount file systems before attempting a kexec reboot." I notice some questionable things, for example, Wim Coekaerts says that "sync; umount -a; kexec -e" will do a very fast reboot. But you can't umount a busy filesystem. Perusing the web, it seems that many ignore the 'kill all applications' part. – Mike S Mar 25 '15 at 14:12
  • 2
    @MikeS This isn't kexec. It's the kexec-reboot utility. The Github description outlines the difference and what the utility adds to the process. – ewwhite Mar 25 '15 at 16:42
  • 4
    @MikeS After staging kexec, you simply do a shutdown -r. Your system scripts will notice that kexec has been staged and do the right thing. How does it look? Three or four or fifteen minutes shorter. I have a very horrible quality video I took off the iDRAC console, but you really don't want to suffer through that... The kexec-reboot script is meant to automate the process of getting the right command line arguments to kexec, which can be tricky. – Michael Hampton Mar 25 '15 at 16:46
  • 1
    @MichaelHampton - cool. I see that on CentOS 6.5 near the end of /etc/rc3d/rc6.d/S01reboot there is: [ -n "$kexec_command" ] && $kexec_command -e -x >& /dev/null . So, iff a kernel is loaded by kexec -l, the system will reboot into it without a complete /sbin/reboot... kexec is baked in! I didn't know that, thanks. I suppose more modern distributions have it covered as well. BTW, if kexec wasn't previously run with -l, the reboot script will say "Nothing has been loaded!" which is why the output is sent to /dev/null, and why I was never aware of this facility. – Mike S Mar 25 '15 at 18:01

Yes, it is possible. kexec will allow a Linux kernel to be booted directly from Linux without going through the BIOS boot process.

  • Also, the UEFI allow to switch the OS without rebooting. – user2284570 Mar 25 '15 at 3:09
  • 2
    @user2284570 As far as I'm aware, UEFI provides no such mechanism. – Jonathon Reinhart Mar 3 '19 at 17:43

Yes. You must use kexec-tools. To make the life easier, I use kexec-reboot.

$sudo apt-get install kexec-tools
$wget https://raw.githubusercontent.com/vadmium/kexec-reboot/master/kexec-reboot
$chmod +x kexec-reboot
$sudo mv kexec-reboot /usr/local/sbin/kexec-reboot
$sudo /usr/local/sbin/kexec-reboot
  • 13
    So that there is no confusion, I did not write this. – Michael Hampton Mar 26 '15 at 4:06
  • This is likely Ubuntu/Debian-only, right? – ewwhite Mar 26 '15 at 22:09
  • 1
    @ewwhite It would probably work on RHEL/CentOS, but on a reading of the code I found several problem spots where edge cases might cause it to fail. And the source seems to acknowledge this with a comment: # The error checking is very basic. – Michael Hampton Mar 26 '15 at 23:23

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.