5 ms·
Systemctl –Force –Force Reboot
Yesterday I learned that is a thing:
systemctl --force --force reboot
- 0xfedbee 3y agoWhat does it do?
- Sayrus 3y agoIt does an immediate shutdown, this may result in data-loss. > If --force is specified twice, the operation is immediately executed without terminating any processes or unmounting any file systems. This may result in data loss. Note that when --force is specified twice the halt operation is executed by systemctl itself, and the system manager is not contacted. This means the command should succeed even when the system manager has crashed.
- retrocryptid 3y agoso it's like `kill -HUP 1` then?
- rbanffy 3y agoWouldn’t HUP require PID 1 to be able to process signals?
- retrocryptid 3y agoI think init still can receive signals. The only kernel ju-ju linux adds is it only delivers the signal if init has installed a handler (SIG_DFL behavior isn't triggered.)
- toast0 3y agoI don't know what systemd does with HUP, but traditional inits respond to HUP by reparsing their configs, not rebooting.
- retrocryptid 3y agoIn the old days, init would respond to a HUP by restarting... sort of a "warm boot." Pretty sure SunOS 4.1 did this, but ultrix certainly did. SVR 4 and Solaris changed the behaviour to just reading /etc/inittab.
- fredoralive 3y agoI mean, using --force twice to get different behaviour to just one --force is a bit funky, but having a way to force an ungraceful reboot from the terminal might be useful if the system is wedged in some way and you can't do a graceful reboot. (Although in many cases you could just hold the power button on the box / use ILO / use the cloud providers admin panel to similar ends).
- mike_hock 3y agoSome tools do the same with --verbose, so it's not without precedent. Of course, it's a measure of last resort, but there's not reason not to let root do it (i.e. expose an interface to the syscalls that already exist).
- lolidk 3y agoThis is the same as `reboot -f` without systemd.
- balou23 3y agoIf you don't want to rely on any specific init system, and not even any external commands (with most shells): echo b > /proc/sysrq-trigger
- RGamma 3y agoMore options (and when you have a keyboard): https://en.wikipedia.org/wiki/Magic_SysRq_key https://en.wikipedia.org/wiki/Magic_SysRq_key
- layer8 3y agoOfficial docs: https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html https://www.kernel.org/doc/html/latest/admin-guide/sysrq.htm...
- harvie 3y agofor i in s u b; do echo "$i" > /proc/sysrq-trigger; done maybe even echo sub > /proc/sysrq-trigger
- hulitu 3y agoI think you want to wait a bit after the s.
- e40 3y agoPlease explain the loop version.
- vrotaru 3y agoThat's just a sequence of commands echo s .. # sync echo u .. # unmount echo b .. # reboot Just a guess though
- tremon 3y agoIt's not really a loop, it's the second half of the REISUB magic sequence (https://en.wikipedia.org/wiki/Reisub?skin=timeless#Uses https://en.wikipedia.org/wiki/Reisub?skin=timeless#Uses): - switch keyboard to _r_aw mode - gracefully t_e_rminate all processes - k_i_ll all remaining processes - _s_ync filesystems - _u_nmount filesystems - re_b_oot You need the "loop" to feed the characters one-by-one to /proc/sysrq-trigger.
- e40 3y agoHere I thought "for" was a loop. Thanks for the explanation what the "sub" did (and more).
- yjftsjthsd-h 3y agoSo the thing to remember is that in POSIX shell (and BASH, etc.) all for loops are for-each loops. If you wanted to loop over integers, you might write `for i in $(seq 10); do echo $i; done`, but that just turns into `for i in 1 2 3 4 5 6 7 8 9 10; do echo $i; done` when it runs. So this one just iterates over "s", "u", and "b" instead.
- nubinetwork 3y agoI've never had issues with a plain old "reboot" on systemd machines... just curious, why you would need to force it?
- dharmab 3y agoMain reason I can think of is you are a kernel developer and you have broken your own kernel in such a way that the regular reboot hangs.
- worthless-trash 3y agoSometimes, we break our tools with our tools.
- wink 3y agoCan't tell you the exact reasons but it happens to me once in a while, usually something in the network stack hanging. Laptops usually, so I just long-press the power button to "fix" it.
- rbanffy 3y agoNot for laptops, but, there are machines that don’t have power buttons. Or where the power buttons are somewhere in a warehouse you are not even supposed to know where it is.
- dikei 3y ago
- blueflow 3y agoHow about pressing Ctrl+Alt+Delete 7 times in quick succession? This is an actual thing. Systemd was a mistake.
- dikei 3y agoAFAIK, C-A-D doesn't work over ssh.
- johnea 3y agoibmuserspacectl -force -force shutdown