[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: How to reboot the system if busybox run as init
From: Woody Wu <narkewoody () gmail ! com>
Date: 2012-12-03 1:22:10
Message-ID: slrnkbnvk9.1p8.narkewoody () zuhnb712 ! local ! com
[Download RAW message or body]
On 2012-12-02, Woody Wu <narkewoody@gmail.com> wrote:
> On 2012-11-30, Laurent Bercot <ska-dietlibc@skarnet.org> wrote:
>>>> sync && sleep 1 && reboot -f
>>
>> This is the right way to do it, when your process 1 is a shell.
>> Depending on your hardware and the way you're using it, you might
>> want to manually unmount - or remount read-only - a few filesystems
>> first.
>>
>> Generally, to shut down a Unix machine, you want to do the following
>> operations, in that order:
>>
>> - Cleanly stop all long-running processes. (This can be done easily
>> with a supervision system, not so easily with SystemV-style inits.)
>> - Gently kill all processes (with a SIGTERM), and wait a few seconds.
>> - Brutally kill all processes (with a SIGKILL), to catch processes
>> that have escaped the previous step.
>> - Unmount all your filesystems. This is possible because you have
>> killed all the processes (save process 1), so you should not have any
>> remaining open files on other filesystems than /.
>> - Remount the / filesystem read-only. My opinion is that / should
>> *always* be read-only, but most systems are badly configured and can't
>> work properly with a read-only /.
>> If your process 1 is a shell, you might have trouble remounting /
>> read-only, because the shell might have some files open for writing.
>> There is no way around that, except design your system differently.
>> It also does not matter if your root filesystem lives in RAM (which
>> is a common way of working around a bad design).
>> - Perform hardware-specific operations such as saving the system
>> clock, writing various states into NVRAM, etc.
>> - Shut down the hardware.
>>
>> The SystemV-style "reboot" command does all this automatically, but
>> of course, it only works if process 1 is a SystemV-style init. Other
>> init schemes have their own way of doing it (runit uses the /etc/runit/3
>> script, s6 runs /service/.s6-svscan/finish as process 1...)
>> If your process 1 is a shell, you will have to do it by hand. Harald's
>> command is a shortcut that works if your system is simple enough and
>> you don't have to worry about a random fsck.
>>
>>
>>> But, there should be an 'init 6' around too, shouldn't it?
>>
>> Yes, but that command only sends a signal (typically via the
>> /dev/initctl fifo) to process 1. If process 1 is a SystemV-style init,
>> it will listen to it and trigger its shutdown procedure. If process 1
>> is a shell, there is no such hook and the command will simply be ignored.
>>
>
> Thanks all your helps! I will try the 'reboot -f' on my target Monday
> morning and report back here. Hope it works!
>
Hi, everone! The 'reboot -f' works! Thanks a lot.
--
woody
I can't go back to yesterday - because I was a different person then.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic