Is reboot -f a safe way to cold-reboot?

7,656

The point of reboot -f is to bypass all the shutdown steps performed by your init system in situations where those steps are failing or expected to fail :-). I strongly recommend against using it outside of that case.

You would be correct to assume that unmounting filesystems in an orderly manner is one such step on upstart.

(systemd would be a whole different ball of wax, and the effects may vary... Which is another reason you should be wary of poking reboot -f. It is a rather obscure detail, and clearly you did not find any documented connection between it, and the effect you observed).


AFAICT, the comment in man 2 reboot which refers to kernel 2.1.122 and the old i386 architecture remains true. At least as of kernel v4.17, and the new unified x86 architecture for both 32- and 64-bit.

Whether the kernel aims for a warm or cold reboot is determined by reboot_mode. And the only place this is set, is by the reboot= kernel option e.g. reboot=cold.

Given that you care about it and the default does not seem to be documented, the naive first step would be to try specifying that. This looks like a pure boot option, that cannot be changed on a running system.

https://elixir.bootlin.com/linux/v4.17/source/Documentation/admin-guide/kernel-parameters.txt#L3732

https://elixir.bootlin.com/linux/v4.17/source/kernel/reboot.c#L518

https://elixir.bootlin.com/linux/v4.17/source/arch/x86/kernel/reboot.c#L545


If you look at the last link, one theoretical possibility is that one of the reboot types in the fallback chain didn't work, after all the other upstart init scripts have been stopped (or vice versa??). So that invoking reboot -f manually uses a different reboot type, and it varied in how it respected reboot_mode. (On your specific system?).

If you are able to report a difference between Linux and Windows reboot behaviour, the kernel developers might well be interested. Though they would be most interested if Linux was completely failing to reboot :). I would want to confirm the above wild guess by recompiling with some printk() and sleep calls and find out what actual reboot types are being used...

There is also the possibility to flail around passing the different reboot types in the boot option. It feels like you'd be making a rather indirect guess... but it seems like passing a specific reboot option is the best hope unless this hairy piece of kernel code can gain some clever fix for your system.

Share:
7,656
PSkocik
Author by

PSkocik

Updated on September 18, 2022

Comments

  • PSkocik
    PSkocik almost 2 years

    On the machine I'm currently at, sudo reboot will only give me a warm reboot.

    Is sudo reboot -f a safe way to do a cold reboot (through BIOS)?

    I'm booting through MBR, not EFI and I'm using upstart (Linux Mint 17.3 (base off of Ubuntu 14.04)).

    It seems a little too quick, so I'm a little worried if it won't corrupt my filesystem.

    • user2948306
      user2948306 almost 6 years
      (Short answer: don't use reboot -f). There seem to be two halves of this question - safety, and cold v.s. warm. You say you've tried it. Can you please say what makes you think it did something different, w.r.t cold v.s. warm? Or if not, what are you actually trying to achieve that needs to know whether it is a cold or warm boot?
    • PSkocik
      PSkocik almost 6 years
      @sourcejedi I get my BIOS logo with reboot -f and I can choose a different boot device with reboot -f. Without the -f I can't. I can get the same effect with poweroff followed by my pressing the power key, but it'd be nicer if I could just run a command.
    • user2948306
      user2948306 almost 6 years
      (It is good to edit the question if it seemed to need clarification. So far it seems there are two people who weren't sure what it meant :). reboot command can be provided by many different packages. Please specify if you are using systemd, sysvinit, upstart, or something else. Also, e.g. there is a specific option under EFI, to boot into some sort of EFI interactive thing instead. And you already mentioned the BIOS. It would be good to specify whether you are using EFI boot or MBR boot.
    • user2948306
      user2948306 almost 6 years
      (Some people would say "through BIOS", even when they use EFI boot, so I can't tell based on that phrase).