How to poweroff when there's no systemd/init (e.g. using init=/bin/bash)?
up vote
8
down vote
favorite
poweroff
complains that it can't connect to systemd via DBus (of course, it's not alive). I did sync
followed by kill $$
, thinking that pid 1 dying would cue the kernel to poweroff, but that caused a kernel panic. I then held the power button to force the poweroff.
What's the most proper way to power-off in this scenario?
linux systemd power-management
add a comment |
up vote
8
down vote
favorite
poweroff
complains that it can't connect to systemd via DBus (of course, it's not alive). I did sync
followed by kill $$
, thinking that pid 1 dying would cue the kernel to poweroff, but that caused a kernel panic. I then held the power button to force the poweroff.
What's the most proper way to power-off in this scenario?
linux systemd power-management
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
@JdeBP You're right that, reading only the title and ignoring theinit=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.
– JoL
Dec 12 at 16:16
add a comment |
up vote
8
down vote
favorite
up vote
8
down vote
favorite
poweroff
complains that it can't connect to systemd via DBus (of course, it's not alive). I did sync
followed by kill $$
, thinking that pid 1 dying would cue the kernel to poweroff, but that caused a kernel panic. I then held the power button to force the poweroff.
What's the most proper way to power-off in this scenario?
linux systemd power-management
poweroff
complains that it can't connect to systemd via DBus (of course, it's not alive). I did sync
followed by kill $$
, thinking that pid 1 dying would cue the kernel to poweroff, but that caused a kernel panic. I then held the power button to force the poweroff.
What's the most proper way to power-off in this scenario?
linux systemd power-management
linux systemd power-management
asked Dec 11 at 0:06
JoL
987310
987310
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
@JdeBP You're right that, reading only the title and ignoring theinit=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.
– JoL
Dec 12 at 16:16
add a comment |
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
@JdeBP You're right that, reading only the title and ignoring theinit=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.
– JoL
Dec 12 at 16:16
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
@JdeBP You're right that, reading only the title and ignoring the
init=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.– JoL
Dec 12 at 16:16
@JdeBP You're right that, reading only the title and ignoring the
init=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.– JoL
Dec 12 at 16:16
add a comment |
5 Answers
5
active
oldest
votes
up vote
11
down vote
accepted
Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro
. On Linux, umount /
also happens to work, because it is effectively converted to the former command.
That said, you don't need to worry about unmounting too much, unless
- You have mounted an old filesystem like FAT - as used by the EFI system partition - or ext2, which does not implement journalling or equivalent. With a modern filesystem,
sync
is supposed to be enough, and the filesystem will repair itself very quickly on the next boot. - You might have left a running process that writes to the filesystem, and you had intended to shut it down cleanly. In that case it's useful to attempt to umount the filesystems, because umount would fail and show a busy error to remind you about the remaining writer.
The above is the important part. After that, you can also conveniently power off the hardware using poweroff -f
. Or reboot with reboot -f
.
There is a systemd
-specific equivalent of poweroff -f
: systemctl poweroff -f -f
. However poweroff -f
does the same thing, and systemd
supports this command even if it has been built without SysV compatibility.
Technically, I remember my USB hard drive was documented as requiring Windows "safe remove" or equivalent. But this requirement is not powerfail safe, and Linux does not do this during a normal shutdown anyway. It's better interpreted as meaning that you shouldn't jog the hard drive while it is spinning - including by trying to unplug it. A full power off should stop the drive spinning. You can probably hear, feel, or see if it does not stop :-).
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.
– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know aboutfsck.mode=skip
right?
– Joshua
Dec 11 at 16:48
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't usefsck.mode=skip
to boot normally after an unclean unmount!
– sourcejedi
Dec 11 at 16:50
add a comment |
up vote
4
down vote
I will simply execute below two commands:
echo s > /proc/sysrq-trigger <= For sync
echo o > /proc/sysrq-trigger <= For shutdown the system
Assuming magic key is enabled in kernel
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.
– dsstorefile1
Dec 11 at 10:05
add a comment |
up vote
3
down vote
Ok, so it just occurred to me that I had the option to exec init
. From there, I would probably be able to later poweroff
. I wonder if there are better alternatives, though.
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
@muru You could doexec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.
– Austin Hemmelgarn
Dec 11 at 14:36
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
add a comment |
up vote
3
down vote
Effectively, tou want to call reboot(2) syscall.
Two ways you can do this:
Run
reboot -f
orpoweroff -f
, this should callreboot(2)
directly.If you're on the real Linux virtual terminal (not the GUI terminal emulator), by pressing Ctrl+Alt+Delete.
Note that the keyboard shortcut can be disabled by some user space program (usually init), when disabled the shortcut will send a signal to init instead.
All of the above commands should be done after umount-ing all disks or remounting as read only, and running sync, otherwise you may lose unwritten data. If your shell is the only process running, sync may be enough.
add a comment |
up vote
1
down vote
You could use the Magic SysRq keys (https://en.wikipedia.org/wiki/Magic_SysRq_key) to power off your computer.
To shut down properly, you can use the following (quote form Wikipedia):
A common use of the magic SysRq key is to perform a safe reboot of a
Linux computer which has otherwise locked up (abbr. REISUB). This can
prevent afsck
being required on reboot and gives some programs a
chance to save emergency backups of unsaved work.[5]
The QWERTY (or AZERTY) mnemonics:
"Raising Elephants Is So Utterly Boring",
"Reboot Even If System Utterly Broken"
or simply the word "BUSIER" read backwards,
are often used to remember the following SysRq-keys sequence:
- unRaw (take control of keyboard back from X),
- tErminate (send SIGTERM to all processes,
allowing them to terminate gracefully),
- kIll (send SIGKILL to all processes,
forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
- reBoot.
But substituting the last B with O (for azerty/qwerty) for "power Off"
New contributor
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487238%2fhow-to-poweroff-when-theres-no-systemd-init-e-g-using-init-bin-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro
. On Linux, umount /
also happens to work, because it is effectively converted to the former command.
That said, you don't need to worry about unmounting too much, unless
- You have mounted an old filesystem like FAT - as used by the EFI system partition - or ext2, which does not implement journalling or equivalent. With a modern filesystem,
sync
is supposed to be enough, and the filesystem will repair itself very quickly on the next boot. - You might have left a running process that writes to the filesystem, and you had intended to shut it down cleanly. In that case it's useful to attempt to umount the filesystems, because umount would fail and show a busy error to remind you about the remaining writer.
The above is the important part. After that, you can also conveniently power off the hardware using poweroff -f
. Or reboot with reboot -f
.
There is a systemd
-specific equivalent of poweroff -f
: systemctl poweroff -f -f
. However poweroff -f
does the same thing, and systemd
supports this command even if it has been built without SysV compatibility.
Technically, I remember my USB hard drive was documented as requiring Windows "safe remove" or equivalent. But this requirement is not powerfail safe, and Linux does not do this during a normal shutdown anyway. It's better interpreted as meaning that you shouldn't jog the hard drive while it is spinning - including by trying to unplug it. A full power off should stop the drive spinning. You can probably hear, feel, or see if it does not stop :-).
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.
– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know aboutfsck.mode=skip
right?
– Joshua
Dec 11 at 16:48
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't usefsck.mode=skip
to boot normally after an unclean unmount!
– sourcejedi
Dec 11 at 16:50
add a comment |
up vote
11
down vote
accepted
Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro
. On Linux, umount /
also happens to work, because it is effectively converted to the former command.
That said, you don't need to worry about unmounting too much, unless
- You have mounted an old filesystem like FAT - as used by the EFI system partition - or ext2, which does not implement journalling or equivalent. With a modern filesystem,
sync
is supposed to be enough, and the filesystem will repair itself very quickly on the next boot. - You might have left a running process that writes to the filesystem, and you had intended to shut it down cleanly. In that case it's useful to attempt to umount the filesystems, because umount would fail and show a busy error to remind you about the remaining writer.
The above is the important part. After that, you can also conveniently power off the hardware using poweroff -f
. Or reboot with reboot -f
.
There is a systemd
-specific equivalent of poweroff -f
: systemctl poweroff -f -f
. However poweroff -f
does the same thing, and systemd
supports this command even if it has been built without SysV compatibility.
Technically, I remember my USB hard drive was documented as requiring Windows "safe remove" or equivalent. But this requirement is not powerfail safe, and Linux does not do this during a normal shutdown anyway. It's better interpreted as meaning that you shouldn't jog the hard drive while it is spinning - including by trying to unplug it. A full power off should stop the drive spinning. You can probably hear, feel, or see if it does not stop :-).
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.
– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know aboutfsck.mode=skip
right?
– Joshua
Dec 11 at 16:48
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't usefsck.mode=skip
to boot normally after an unclean unmount!
– sourcejedi
Dec 11 at 16:50
add a comment |
up vote
11
down vote
accepted
up vote
11
down vote
accepted
Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro
. On Linux, umount /
also happens to work, because it is effectively converted to the former command.
That said, you don't need to worry about unmounting too much, unless
- You have mounted an old filesystem like FAT - as used by the EFI system partition - or ext2, which does not implement journalling or equivalent. With a modern filesystem,
sync
is supposed to be enough, and the filesystem will repair itself very quickly on the next boot. - You might have left a running process that writes to the filesystem, and you had intended to shut it down cleanly. In that case it's useful to attempt to umount the filesystems, because umount would fail and show a busy error to remind you about the remaining writer.
The above is the important part. After that, you can also conveniently power off the hardware using poweroff -f
. Or reboot with reboot -f
.
There is a systemd
-specific equivalent of poweroff -f
: systemctl poweroff -f -f
. However poweroff -f
does the same thing, and systemd
supports this command even if it has been built without SysV compatibility.
Technically, I remember my USB hard drive was documented as requiring Windows "safe remove" or equivalent. But this requirement is not powerfail safe, and Linux does not do this during a normal shutdown anyway. It's better interpreted as meaning that you shouldn't jog the hard drive while it is spinning - including by trying to unplug it. A full power off should stop the drive spinning. You can probably hear, feel, or see if it does not stop :-).
Unmount the filesystems that you had mounted. The root filesystem is a special case; for this you can use mount / -o remount,ro
. On Linux, umount /
also happens to work, because it is effectively converted to the former command.
That said, you don't need to worry about unmounting too much, unless
- You have mounted an old filesystem like FAT - as used by the EFI system partition - or ext2, which does not implement journalling or equivalent. With a modern filesystem,
sync
is supposed to be enough, and the filesystem will repair itself very quickly on the next boot. - You might have left a running process that writes to the filesystem, and you had intended to shut it down cleanly. In that case it's useful to attempt to umount the filesystems, because umount would fail and show a busy error to remind you about the remaining writer.
The above is the important part. After that, you can also conveniently power off the hardware using poweroff -f
. Or reboot with reboot -f
.
There is a systemd
-specific equivalent of poweroff -f
: systemctl poweroff -f -f
. However poweroff -f
does the same thing, and systemd
supports this command even if it has been built without SysV compatibility.
Technically, I remember my USB hard drive was documented as requiring Windows "safe remove" or equivalent. But this requirement is not powerfail safe, and Linux does not do this during a normal shutdown anyway. It's better interpreted as meaning that you shouldn't jog the hard drive while it is spinning - including by trying to unplug it. A full power off should stop the drive spinning. You can probably hear, feel, or see if it does not stop :-).
edited Dec 11 at 17:11
answered Dec 11 at 0:20
sourcejedi
22.5k43499
22.5k43499
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.
– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know aboutfsck.mode=skip
right?
– Joshua
Dec 11 at 16:48
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't usefsck.mode=skip
to boot normally after an unclean unmount!
– sourcejedi
Dec 11 at 16:50
add a comment |
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.
– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know aboutfsck.mode=skip
right?
– Joshua
Dec 11 at 16:48
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't usefsck.mode=skip
to boot normally after an unclean unmount!
– sourcejedi
Dec 11 at 16:50
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
Just so you know, I'm not forgetting to accept. It's just that I've seen the advice to wait some time before accepting an answer to let others (maybe in different timezones) see the question and have the chance to provide their own answers.
– JoL
Dec 11 at 0:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.– Joshua
Dec 11 at 16:42
sync()
suffices for ext2. It will complain about being dirty but won't have actually been corrupted except for the summary information. I generally consider init=/bin/bash or any local equivalent to be an emergency situation.– Joshua
Dec 11 at 16:42
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
@Joshua ext2 fsck is amazing. But fsck performance on large filesystems is much worse than journal replay. In an emergency situation, you don't want to be delayed because of an unclean unmount.
– sourcejedi
Dec 11 at 16:46
You know about
fsck.mode=skip
right?– Joshua
Dec 11 at 16:48
You know about
fsck.mode=skip
right?– Joshua
Dec 11 at 16:48
1
1
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't use
fsck.mode=skip
to boot normally after an unclean unmount!– sourcejedi
Dec 11 at 16:50
@Joshua which is relevant why? If you do an unclean unmount, you will eventually need to repair the FS. Don't use
fsck.mode=skip
to boot normally after an unclean unmount!– sourcejedi
Dec 11 at 16:50
add a comment |
up vote
4
down vote
I will simply execute below two commands:
echo s > /proc/sysrq-trigger <= For sync
echo o > /proc/sysrq-trigger <= For shutdown the system
Assuming magic key is enabled in kernel
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.
– dsstorefile1
Dec 11 at 10:05
add a comment |
up vote
4
down vote
I will simply execute below two commands:
echo s > /proc/sysrq-trigger <= For sync
echo o > /proc/sysrq-trigger <= For shutdown the system
Assuming magic key is enabled in kernel
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.
– dsstorefile1
Dec 11 at 10:05
add a comment |
up vote
4
down vote
up vote
4
down vote
I will simply execute below two commands:
echo s > /proc/sysrq-trigger <= For sync
echo o > /proc/sysrq-trigger <= For shutdown the system
Assuming magic key is enabled in kernel
I will simply execute below two commands:
echo s > /proc/sysrq-trigger <= For sync
echo o > /proc/sysrq-trigger <= For shutdown the system
Assuming magic key is enabled in kernel
answered Dec 11 at 6:48
SHW
7,98633570
7,98633570
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.
– dsstorefile1
Dec 11 at 10:05
add a comment |
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.
– dsstorefile1
Dec 11 at 10:05
2
2
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.– dsstorefile1
Dec 11 at 10:05
echo u > /proc/sysrq-trigger
would probably be helpful before powering down the hardware.– dsstorefile1
Dec 11 at 10:05
add a comment |
up vote
3
down vote
Ok, so it just occurred to me that I had the option to exec init
. From there, I would probably be able to later poweroff
. I wonder if there are better alternatives, though.
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
@muru You could doexec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.
– Austin Hemmelgarn
Dec 11 at 14:36
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
add a comment |
up vote
3
down vote
Ok, so it just occurred to me that I had the option to exec init
. From there, I would probably be able to later poweroff
. I wonder if there are better alternatives, though.
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
@muru You could doexec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.
– Austin Hemmelgarn
Dec 11 at 14:36
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
add a comment |
up vote
3
down vote
up vote
3
down vote
Ok, so it just occurred to me that I had the option to exec init
. From there, I would probably be able to later poweroff
. I wonder if there are better alternatives, though.
Ok, so it just occurred to me that I had the option to exec init
. From there, I would probably be able to later poweroff
. I wonder if there are better alternatives, though.
answered Dec 11 at 0:20
JoL
987310
987310
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
@muru You could doexec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.
– Austin Hemmelgarn
Dec 11 at 14:36
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
add a comment |
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
@muru You could doexec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.
– Austin Hemmelgarn
Dec 11 at 14:36
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
@G-Man won't it start the normal boot process and give you your normal shell eventually?
– muru
Dec 11 at 2:21
2
2
@muru You could do
exec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.– Austin Hemmelgarn
Dec 11 at 14:36
@muru You could do
exec init 0
. That won't work with all init systems, but the same ones will go through a shutdown sequence.– Austin Hemmelgarn
Dec 11 at 14:36
1
1
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
I think this is a really good answer for other reasons; particularly because most cases powering off isn't desired so much as rebooting and this avoids the reboot once having fixed the damage.
– Joshua
Dec 11 at 16:44
1
1
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
@Joshua That's convenient, but if you want to be safest, it is often a good idea to check the full boot process works :-).
– sourcejedi
Dec 11 at 17:17
add a comment |
up vote
3
down vote
Effectively, tou want to call reboot(2) syscall.
Two ways you can do this:
Run
reboot -f
orpoweroff -f
, this should callreboot(2)
directly.If you're on the real Linux virtual terminal (not the GUI terminal emulator), by pressing Ctrl+Alt+Delete.
Note that the keyboard shortcut can be disabled by some user space program (usually init), when disabled the shortcut will send a signal to init instead.
All of the above commands should be done after umount-ing all disks or remounting as read only, and running sync, otherwise you may lose unwritten data. If your shell is the only process running, sync may be enough.
add a comment |
up vote
3
down vote
Effectively, tou want to call reboot(2) syscall.
Two ways you can do this:
Run
reboot -f
orpoweroff -f
, this should callreboot(2)
directly.If you're on the real Linux virtual terminal (not the GUI terminal emulator), by pressing Ctrl+Alt+Delete.
Note that the keyboard shortcut can be disabled by some user space program (usually init), when disabled the shortcut will send a signal to init instead.
All of the above commands should be done after umount-ing all disks or remounting as read only, and running sync, otherwise you may lose unwritten data. If your shell is the only process running, sync may be enough.
add a comment |
up vote
3
down vote
up vote
3
down vote
Effectively, tou want to call reboot(2) syscall.
Two ways you can do this:
Run
reboot -f
orpoweroff -f
, this should callreboot(2)
directly.If you're on the real Linux virtual terminal (not the GUI terminal emulator), by pressing Ctrl+Alt+Delete.
Note that the keyboard shortcut can be disabled by some user space program (usually init), when disabled the shortcut will send a signal to init instead.
All of the above commands should be done after umount-ing all disks or remounting as read only, and running sync, otherwise you may lose unwritten data. If your shell is the only process running, sync may be enough.
Effectively, tou want to call reboot(2) syscall.
Two ways you can do this:
Run
reboot -f
orpoweroff -f
, this should callreboot(2)
directly.If you're on the real Linux virtual terminal (not the GUI terminal emulator), by pressing Ctrl+Alt+Delete.
Note that the keyboard shortcut can be disabled by some user space program (usually init), when disabled the shortcut will send a signal to init instead.
All of the above commands should be done after umount-ing all disks or remounting as read only, and running sync, otherwise you may lose unwritten data. If your shell is the only process running, sync may be enough.
edited 2 days ago
mature
1293
1293
answered Dec 11 at 8:10
Lie Ryan
1,02369
1,02369
add a comment |
add a comment |
up vote
1
down vote
You could use the Magic SysRq keys (https://en.wikipedia.org/wiki/Magic_SysRq_key) to power off your computer.
To shut down properly, you can use the following (quote form Wikipedia):
A common use of the magic SysRq key is to perform a safe reboot of a
Linux computer which has otherwise locked up (abbr. REISUB). This can
prevent afsck
being required on reboot and gives some programs a
chance to save emergency backups of unsaved work.[5]
The QWERTY (or AZERTY) mnemonics:
"Raising Elephants Is So Utterly Boring",
"Reboot Even If System Utterly Broken"
or simply the word "BUSIER" read backwards,
are often used to remember the following SysRq-keys sequence:
- unRaw (take control of keyboard back from X),
- tErminate (send SIGTERM to all processes,
allowing them to terminate gracefully),
- kIll (send SIGKILL to all processes,
forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
- reBoot.
But substituting the last B with O (for azerty/qwerty) for "power Off"
New contributor
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
add a comment |
up vote
1
down vote
You could use the Magic SysRq keys (https://en.wikipedia.org/wiki/Magic_SysRq_key) to power off your computer.
To shut down properly, you can use the following (quote form Wikipedia):
A common use of the magic SysRq key is to perform a safe reboot of a
Linux computer which has otherwise locked up (abbr. REISUB). This can
prevent afsck
being required on reboot and gives some programs a
chance to save emergency backups of unsaved work.[5]
The QWERTY (or AZERTY) mnemonics:
"Raising Elephants Is So Utterly Boring",
"Reboot Even If System Utterly Broken"
or simply the word "BUSIER" read backwards,
are often used to remember the following SysRq-keys sequence:
- unRaw (take control of keyboard back from X),
- tErminate (send SIGTERM to all processes,
allowing them to terminate gracefully),
- kIll (send SIGKILL to all processes,
forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
- reBoot.
But substituting the last B with O (for azerty/qwerty) for "power Off"
New contributor
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
add a comment |
up vote
1
down vote
up vote
1
down vote
You could use the Magic SysRq keys (https://en.wikipedia.org/wiki/Magic_SysRq_key) to power off your computer.
To shut down properly, you can use the following (quote form Wikipedia):
A common use of the magic SysRq key is to perform a safe reboot of a
Linux computer which has otherwise locked up (abbr. REISUB). This can
prevent afsck
being required on reboot and gives some programs a
chance to save emergency backups of unsaved work.[5]
The QWERTY (or AZERTY) mnemonics:
"Raising Elephants Is So Utterly Boring",
"Reboot Even If System Utterly Broken"
or simply the word "BUSIER" read backwards,
are often used to remember the following SysRq-keys sequence:
- unRaw (take control of keyboard back from X),
- tErminate (send SIGTERM to all processes,
allowing them to terminate gracefully),
- kIll (send SIGKILL to all processes,
forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
- reBoot.
But substituting the last B with O (for azerty/qwerty) for "power Off"
New contributor
You could use the Magic SysRq keys (https://en.wikipedia.org/wiki/Magic_SysRq_key) to power off your computer.
To shut down properly, you can use the following (quote form Wikipedia):
A common use of the magic SysRq key is to perform a safe reboot of a
Linux computer which has otherwise locked up (abbr. REISUB). This can
prevent afsck
being required on reboot and gives some programs a
chance to save emergency backups of unsaved work.[5]
The QWERTY (or AZERTY) mnemonics:
"Raising Elephants Is So Utterly Boring",
"Reboot Even If System Utterly Broken"
or simply the word "BUSIER" read backwards,
are often used to remember the following SysRq-keys sequence:
- unRaw (take control of keyboard back from X),
- tErminate (send SIGTERM to all processes,
allowing them to terminate gracefully),
- kIll (send SIGKILL to all processes,
forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
- reBoot.
But substituting the last B with O (for azerty/qwerty) for "power Off"
New contributor
edited yesterday
G-Man
12.8k93164
12.8k93164
New contributor
answered Dec 11 at 10:14
breversa
1115
1115
New contributor
New contributor
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
add a comment |
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
Similar to unix.stackexchange.com/a/487274/70524
– muru
Dec 11 at 10:17
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487238%2fhow-to-poweroff-when-theres-no-systemd-init-e-g-using-init-bin-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There's an unstated implicit premise of the question that the systemd toolset is installed. When "there's no systemd" actually means that no systemd toolset is installed, which is how the title can also be read, answers are rather different; and that's probably worth a separate question in its own right.
– JdeBP
Dec 11 at 19:24
@JdeBP You're right that, reading only the title and ignoring the
init=/bin/bash
hint/implication, it's ambiguous if systemd is installed or not. I had meant that there's no systemd running. In any case, having no running systemd, I thought the systemd toolset would be useless and that answers would use other means like those about sysrq.– JoL
Dec 12 at 16:16