Closed qiang-yu closed 2 years ago
What distro do you use as base? Does it have systemd?
same issue with debian 11 bullseye distro won't poweroff instead reboot if tyiping sudo poweroff systemctl shutdown -n now
I think I'm seeing the same problem using Slackware 15, which does not use systemd.
It looks like the shutdown script is calling 'reboot' or 'poweroff' without any arguments. Assuming the busybox versions work the same way as the normal ones, if the current runlevel isn't 0 or 6, it will call shutdown(8) to change the runlevel, instead of physically rebooting or powering off. The initramfs environment doesn't seem to have a utmp file (which stores the runlevel) so I think this is indeed what is happening.
Since the poweroff command fails, the script continues to a fallback command, which is to run "reboot -f"; the -f forces it to actually reboot instead of calling shutdown, so it works this time.
It seems that the fix is to call "reboot -f" or "poweroff -f" as appropriate, in the shutdown scripts.
In general, it is necessary ro run the shutdown script from initramfs at the end of your distro's shutdown procedure instead of reboot/halt.
If your distro uses systemd, then this is done automatically, like it does in debian. However if your distro does not use systemd, you need to modify your shutdown scripts to call the shutdown script in /run/initramfs/shutdown manually at the end. For an examle, you can see https://github.com/Tomas-M/linux-live/blob/master/Slax/slackware15/modules/01-core/rootcopy/etc/rc.d/rc.6 (My changes are at the bottom)
I am unfortunately not sure why it does not work for @uHash64
Hello everyone.
Debian sid. I try to poweroff by systemctl like this:
#systemctl poweroff
Live system from USB-flash does reboot the machine instead of turning it off.0 On the actual system working from HDD, this command turns off the machine.
I am not sure I understand it quite well but the shutdown script in /run/initramfs shows this result:
The script is not meant to he started directly. It has to be started during the shutdown procedure of your distro with chroot (the directory /run/initramfs is chrooted). For examle Debian does that automatically because it uses systemd, and systemd knows what to do.
Unfortunately, on Debian sid with systemd It does not work.
I've made new flash-drive with ver. 2.6 - the same system, the same list of packages, and now halting machine works fine.
Can you send me your ISO which does not work? Maybe upload it to some file sharing website.
Sure. Just, I do not do iso, I prefer Tar. It is a bit bigger than you might expect though...
https://disk.yandex.ru/d/Fm9_AyVBQMjDyw
$ md5sum livekit-sid.tar
2d4d290c4c3d7c520db63278c2a12516 livekit-sid.tar
Let me know when you get it.
2022-08-12 , make live ISO, the system can not poweroff
/sbin/poweroff
it would reboot intead of poweroff
it seems this is a bug