* Forcing an immediate reboot
@ 2005-10-15 1:46 Marc Perkel
2005-10-15 1:50 ` Lee Revell
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Marc Perkel @ 2005-10-15 1:46 UTC (permalink / raw)
To: linux-kernel
Is there any way to force an immediate reboot as if to push the reset
button in software? Got a remote server that i need to reboot and
shutdown isn't working.
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: Forcing an immediate reboot 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel @ 2005-10-15 1:50 ` Lee Revell 2005-10-15 6:47 ` Coywolf Qi Hunt 2005-10-15 7:48 ` Anton Altaparmakov 2005-10-15 1:55 ` Randy.Dunlap ` (3 subsequent siblings) 4 siblings, 2 replies; 20+ messages in thread From: Lee Revell @ 2005-10-15 1:50 UTC (permalink / raw) To: Marc Perkel; +Cc: linux-kernel On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: > Is there any way to force an immediate reboot as if to push the reset > button in software? Got a remote server that i need to reboot and > shutdown isn't working. If it has Oopsed, and the "reboot" command does not work, then all bets are off - kernel memory has probably been corrupted. Get one of those powerstrips that you can telnet into and power cycle things remotely. Lee ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:50 ` Lee Revell @ 2005-10-15 6:47 ` Coywolf Qi Hunt 2005-10-15 6:51 ` Marc Perkel 2005-10-15 7:48 ` Anton Altaparmakov 1 sibling, 1 reply; 20+ messages in thread From: Coywolf Qi Hunt @ 2005-10-15 6:47 UTC (permalink / raw) To: Lee Revell; +Cc: Marc Perkel, linux-kernel On 10/15/05, Lee Revell <rlrevell@joe-job.com> wrote: > On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: > > Is there any way to force an immediate reboot as if to push the reset > > button in software? Got a remote server that i need to reboot and > > shutdown isn't working. > > If it has Oopsed, and the "reboot" command does not work, then all bets > are off - kernel memory has probably been corrupted. > > Get one of those powerstrips that you can telnet into and power cycle > things remotely. > use reboot on panic. -- Coywolf Qi Hunt http://sosdg.org/~coywolf/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 6:47 ` Coywolf Qi Hunt @ 2005-10-15 6:51 ` Marc Perkel 0 siblings, 0 replies; 20+ messages in thread From: Marc Perkel @ 2005-10-15 6:51 UTC (permalink / raw) To: Coywolf Qi Hunt; +Cc: Lee Revell, linux-kernel Coywolf Qi Hunt wrote: >On 10/15/05, Lee Revell <rlrevell@joe-job.com> wrote: > > >>On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: >> >> >>>Is there any way to force an immediate reboot as if to push the reset >>>button in software? Got a remote server that i need to reboot and >>>shutdown isn't working. >>> >>> >>If it has Oopsed, and the "reboot" command does not work, then all bets >>are off - kernel memory has probably been corrupted. >> >>Get one of those powerstrips that you can telnet into and power cycle >>things remotely. >> >> >> > >use reboot on panic. > > But it didn't panic. It was still running - filtering spam. But reboot wouldn't work and I couldn't kill anything that was running. So it never paniced. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:50 ` Lee Revell 2005-10-15 6:47 ` Coywolf Qi Hunt @ 2005-10-15 7:48 ` Anton Altaparmakov 2005-10-15 7:56 ` Coywolf Qi Hunt ` (2 more replies) 1 sibling, 3 replies; 20+ messages in thread From: Anton Altaparmakov @ 2005-10-15 7:48 UTC (permalink / raw) To: Lee Revell; +Cc: Marc Perkel, linux-kernel On Fri, 14 Oct 2005, Lee Revell wrote: > On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: > > Is there any way to force an immediate reboot as if to push the reset > > button in software? Got a remote server that i need to reboot and > > shutdown isn't working. > > If it has Oopsed, and the "reboot" command does not work, then all bets > are off - kernel memory has probably been corrupted. > > Get one of those powerstrips that you can telnet into and power cycle > things remotely. If it has sysrq compiled in as root just do: echo s > /proc/sysrq-trigger echo u > /proc/sysre-trigger echo s > /proc/sysrq-trigger echo b > /proc/sysrq-trigger This will "sync", "umount/remount read-only", "sync", "immediate hardware reboot". Should always work... Best regards, Anton -- Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 7:48 ` Anton Altaparmakov @ 2005-10-15 7:56 ` Coywolf Qi Hunt 2005-10-15 8:16 ` Anton Altaparmakov 2005-10-15 13:23 ` documentation? (i learned something today ;-) ) Damir Perisa 2005-10-15 14:29 ` Forcing an immediate reboot Marc Perkel 2 siblings, 1 reply; 20+ messages in thread From: Coywolf Qi Hunt @ 2005-10-15 7:56 UTC (permalink / raw) To: Anton Altaparmakov; +Cc: Lee Revell, Marc Perkel, linux-kernel On 10/15/05, Anton Altaparmakov <aia21@cam.ac.uk> wrote: > On Fri, 14 Oct 2005, Lee Revell wrote: > > On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: > > > Is there any way to force an immediate reboot as if to push the reset > > > button in software? Got a remote server that i need to reboot and > > > shutdown isn't working. > > > > If it has Oopsed, and the "reboot" command does not work, then all bets > > are off - kernel memory has probably been corrupted. > > > > Get one of those powerstrips that you can telnet into and power cycle > > things remotely. > > If it has sysrq compiled in as root just do: > > echo s > /proc/sysrq-trigger > echo u > /proc/sysre-trigger > echo s > /proc/sysrq-trigger What the purpose of the second sync? > echo b > /proc/sysrq-trigger > > This will "sync", "umount/remount read-only", "sync", "immediate hardware > reboot". Should always work... -- Coywolf Qi Hunt http://sosdg.org/~coywolf/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 7:56 ` Coywolf Qi Hunt @ 2005-10-15 8:16 ` Anton Altaparmakov 2005-10-16 0:10 ` Petr Vandrovec 0 siblings, 1 reply; 20+ messages in thread From: Anton Altaparmakov @ 2005-10-15 8:16 UTC (permalink / raw) To: Coywolf Qi Hunt; +Cc: Lee Revell, Marc Perkel, linux-kernel On Sat, 15 Oct 2005, Coywolf Qi Hunt wrote: > On 10/15/05, Anton Altaparmakov <aia21@cam.ac.uk> wrote: > > On Fri, 14 Oct 2005, Lee Revell wrote: > > > On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: > > > > Is there any way to force an immediate reboot as if to push the reset > > > > button in software? Got a remote server that i need to reboot and > > > > shutdown isn't working. > > > > > > If it has Oopsed, and the "reboot" command does not work, then all bets > > > are off - kernel memory has probably been corrupted. > > > > > > Get one of those powerstrips that you can telnet into and power cycle > > > things remotely. > > > > If it has sysrq compiled in as root just do: > > > > echo s > /proc/sysrq-trigger > > echo u > /proc/sysre-trigger > > echo s > /proc/sysrq-trigger > > What the purpose of the second sync? Allows any i/o initiated between the first sync and the remount r/o to complete. Remember that r/o mounting doesn't stop i/o. It only stops you from writing to the fs at the vfs layer. Once a write/modification has entered the fs driver it will get written no matter what, unless the "reboot" sysrq is triggered in which case the kernel just reboots immediately. Maybe it is just paranoia on my part but I have gotten used to hitting Alt+PrtScr+S, +U, +S, +B so I do it automatically. Best regards, Anton -- Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 8:16 ` Anton Altaparmakov @ 2005-10-16 0:10 ` Petr Vandrovec 0 siblings, 0 replies; 20+ messages in thread From: Petr Vandrovec @ 2005-10-16 0:10 UTC (permalink / raw) To: Anton Altaparmakov; +Cc: Coywolf Qi Hunt, Lee Revell, Marc Perkel, linux-kernel Anton Altaparmakov wrote: > On Sat, 15 Oct 2005, Coywolf Qi Hunt wrote: > >>On 10/15/05, Anton Altaparmakov <aia21@cam.ac.uk> wrote: >> >>>echo s > /proc/sysrq-trigger >>>echo u > /proc/sysre-trigger >>>echo s > /proc/sysrq-trigger >> >>What the purpose of the second sync? > > > Allows any i/o initiated between the first sync and the remount r/o to > complete. Remember that r/o mounting doesn't stop i/o. It only stops you > from writing to the fs at the vfs layer. Once a write/modification has > entered the fs driver it will get written no matter what, unless the > "reboot" sysrq is triggered in which case the kernel just reboots > immediately. > > Maybe it is just paranoia on my part but I have gotten used to hitting > Alt+PrtScr+S, +U, +S, +B so I do it automatically. Second sync is a must, otherwise remounting read-only is not written to the filesystem (at least in my case) so no fsck is saved. But you can save first sync (before remount), and then you get nice sequence which even admins comming from Windows can remember - they have to use USB to safely reboot their Linux systems ;-) (alt-sysrq-U, S, B) Petr ^ permalink raw reply [flat|nested] 20+ messages in thread
* documentation? (i learned something today ;-) ) 2005-10-15 7:48 ` Anton Altaparmakov 2005-10-15 7:56 ` Coywolf Qi Hunt @ 2005-10-15 13:23 ` Damir Perisa 2005-10-15 13:40 ` Benoit Boissinot 2005-10-15 14:29 ` Forcing an immediate reboot Marc Perkel 2 siblings, 1 reply; 20+ messages in thread From: Damir Perisa @ 2005-10-15 13:23 UTC (permalink / raw) To: Anton Altaparmakov; +Cc: Lee Revell, Marc Perkel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1171 bytes --] hi all, Le Saturday 15 October 2005 09:48, Anton Altaparmakov a écrit : | If it has sysrq compiled in as root just do: | | echo s > /proc/sysrq-trigger | echo u > /proc/sysre-trigger | echo s > /proc/sysrq-trigger | echo b > /proc/sysrq-trigger | | This will "sync", "umount/remount read-only", "sync", "immediate | hardware reboot". Should always work... i'm impressed that i see that sysrq also works from procfs.... the "PrintScreen/SysRq" button on my keyboard from time to time does not work (old keyboard) and then it's pain hitting this key if you have to. great news that you can also pass sysrq requests using proc - i've learned something today... is this documented somewhere? maybe i'm bad in reading/finding docs but i think i'm not the only one here. can somebody point me to the links of docs where all this magic is specified? if not, i will try to start my own docs on how to use the linux kernel magic. mainly a collection of tricks like this and similar ones. thank you in advance + greetings, Damir -- Customer: (angrily) "You said I would get 98 windows with this computer. Where are they?" [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: documentation? (i learned something today ;-) ) 2005-10-15 13:23 ` documentation? (i learned something today ;-) ) Damir Perisa @ 2005-10-15 13:40 ` Benoit Boissinot 2005-10-15 14:52 ` Documentation/files somewhere online? Damir Perisa 0 siblings, 1 reply; 20+ messages in thread From: Benoit Boissinot @ 2005-10-15 13:40 UTC (permalink / raw) To: Damir Perisa; +Cc: linux-kernel On 10/15/05, Damir Perisa <damir.perisa@solnet.ch> wrote: > hi all, > > Le Saturday 15 October 2005 09:48, Anton Altaparmakov a écrit: > | If it has sysrq compiled in as root just do: > | > | echo s > /proc/sysrq-trigger > | echo u > /proc/sysre-trigger > | echo s > /proc/sysrq-trigger > | echo b > /proc/sysrq-trigger > | > | This will "sync", "umount/remount read-only", "sync", "immediate > | hardware reboot". Should always work... > > i'm impressed that i see that sysrq also works from procfs.... the > "PrintScreen/SysRq" button on my keyboard from time to time does not work > (old keyboard) and then it's pain hitting this key if you have to. > > great news that you can also pass sysrq requests using proc - i've learned > something today... is this documented somewhere? maybe i'm bad in > reading/finding docs but i think i'm not the only one here. can somebody > point me to the links of docs where all this magic is specified? if not, > i will try to start my own docs on how to use the linux kernel magic. > mainly a collection of tricks like this and similar ones. > > thank you in advance + greetings, > Damir it is mentionned in Documentation/sysrq.txt On all - write a character to /proc/sysrq-trigger. eg: echo t > /proc/sysrq-trigger regards, Benoit ^ permalink raw reply [flat|nested] 20+ messages in thread
* Documentation/files somewhere online? 2005-10-15 13:40 ` Benoit Boissinot @ 2005-10-15 14:52 ` Damir Perisa 2005-10-15 15:02 ` Denis Vlasenko 0 siblings, 1 reply; 20+ messages in thread From: Damir Perisa @ 2005-10-15 14:52 UTC (permalink / raw) To: Benoit Boissinot; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 1191 bytes --] thank you for the quick reply, Benoit, Le Saturday 15 October 2005 15:40, Benoit Boissinot a écrit : | On 10/15/05, Damir Perisa <damir.perisa@solnet.ch> wrote: | > Le Saturday 15 October 2005 09:48, Anton Altaparmakov a écrit: | > | echo s > /proc/sysrq-trigger | > i'm impressed that i see that sysrq also works from procfs.... | | it is mentionned in Documentation/sysrq.txt oh ... i definitely have to read the Documentation/files more often for updates... last time i did, i didn't remember seeing proc magic in this one. is somebody keeping a online version of the kernel source docs (i mean the Documentation/* files) somewhere for surfing? i want to point people to pages with links without forcing them to download the sources to read what i tell them to. often i'm asked questions about linux in general. an updated docs pages on the net would be helpful. of course if it does not exist, i can create one, but why re-inventing the wheel if it is easier to give credits to the first person who invented it and use it? ;-) thanx + greetings, Damir -- The bureaucracy is expanding to meet the needs of an expanding bureaucracy. [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Documentation/files somewhere online? 2005-10-15 14:52 ` Documentation/files somewhere online? Damir Perisa @ 2005-10-15 15:02 ` Denis Vlasenko 2005-10-15 15:13 ` Michael Krufky 0 siblings, 1 reply; 20+ messages in thread From: Denis Vlasenko @ 2005-10-15 15:02 UTC (permalink / raw) To: Damir Perisa; +Cc: Benoit Boissinot, linux-kernel On Saturday 15 October 2005 17:52, Damir Perisa wrote: > thank you for the quick reply, Benoit, > > Le Saturday 15 October 2005 15:40, Benoit Boissinot a écrit : > | On 10/15/05, Damir Perisa <damir.perisa@solnet.ch> wrote: > | > Le Saturday 15 October 2005 09:48, Anton Altaparmakov a écrit: > | > | echo s > /proc/sysrq-trigger > | > i'm impressed that i see that sysrq also works from procfs.... > | > | it is mentionned in Documentation/sysrq.txt > > oh ... i definitely have to read the Documentation/files more often for > updates... last time i did, i didn't remember seeing proc magic in this > one. > > is somebody keeping a online version of the kernel source docs (i mean the > Documentation/* files) somewhere for surfing? i want to point people to > pages with links without forcing them to download the sources to read > what i tell them to. http://lxr.linux.no/source/Documentation/ > often i'm asked questions about linux in general. an updated docs pages on > the net would be helpful. of course if it does not exist, i can create > one, but why re-inventing the wheel if it is easier to give credits to > the first person who invented it and use it? ;-) -- vda ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Documentation/files somewhere online? 2005-10-15 15:02 ` Denis Vlasenko @ 2005-10-15 15:13 ` Michael Krufky 2005-10-15 23:18 ` Documentation/files online: available at git in webinterface Damir Perisa 0 siblings, 1 reply; 20+ messages in thread From: Michael Krufky @ 2005-10-15 15:13 UTC (permalink / raw) To: Denis Vlasenko; +Cc: Damir Perisa, Benoit Boissinot, linux-kernel Denis Vlasenko wrote: >On Saturday 15 October 2005 17:52, Damir Perisa wrote: > > >>is somebody keeping a online version of the kernel source docs (i mean the >>Documentation/* files) somewhere for surfing? i want to point people to >>pages with links without forcing them to download the sources to read >>what i tell them to. >> >> >http://lxr.linux.no/source/Documentation/ > > I think that using the -git web interface to Linus' tree on kernel.org is even better. The following is a link to the top-level of the kernel source tree: http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree You will notice a Documentation tree link (3rd file object link from the top). This will get you the most current Documentation at the moment from Linus' tree, and it also gives you the ability to see the history of changes. Hope this helps. -- Michael Krufky ^ permalink raw reply [flat|nested] 20+ messages in thread
* Documentation/files online: available at git in webinterface 2005-10-15 15:13 ` Michael Krufky @ 2005-10-15 23:18 ` Damir Perisa 0 siblings, 0 replies; 20+ messages in thread From: Damir Perisa @ 2005-10-15 23:18 UTC (permalink / raw) To: mkrufky; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 550 bytes --] Le Saturday 15 October 2005 17:13, Michael Krufky a écrit : | I think that using the -git web interface to Linus' tree on kernel.org | is even better. great idea... | The following is a link to the top-level of the kernel source tree: | | http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree i totally forgot that git has a webinterface. how very useful! :D | Hope this helps. it is even better: it's the solution. thank you! greetings, Damir -- Everything bows to success, even grammar. [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 7:48 ` Anton Altaparmakov 2005-10-15 7:56 ` Coywolf Qi Hunt 2005-10-15 13:23 ` documentation? (i learned something today ;-) ) Damir Perisa @ 2005-10-15 14:29 ` Marc Perkel 2 siblings, 0 replies; 20+ messages in thread From: Marc Perkel @ 2005-10-15 14:29 UTC (permalink / raw) To: Anton Altaparmakov; +Cc: Lee Revell, linux-kernel Anton Altaparmakov wrote: >On Fri, 14 Oct 2005, Lee Revell wrote: > > >>On Fri, 2005-10-14 at 18:46 -0700, Marc Perkel wrote: >> >> >>>Is there any way to force an immediate reboot as if to push the reset >>>button in software? Got a remote server that i need to reboot and >>>shutdown isn't working. >>> >>> >>If it has Oopsed, and the "reboot" command does not work, then all bets >>are off - kernel memory has probably been corrupted. >> >>Get one of those powerstrips that you can telnet into and power cycle >>things remotely. >> >> > >If it has sysrq compiled in as root just do: > >echo s > /proc/sysrq-trigger >echo u > /proc/sysre-trigger >echo s > /proc/sysrq-trigger >echo b > /proc/sysrq-trigger > >This will "sync", "umount/remount read-only", "sync", "immediate hardware >reboot". Should always work... > > > > This worked great. If I had this last night it would probably have saved me a trip to San Jose. I especially like that it does the file system syncs. I've put it in a script I call "coldboot" and it is now one of my tools. Very useful. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel 2005-10-15 1:50 ` Lee Revell @ 2005-10-15 1:55 ` Randy.Dunlap 2005-10-15 2:24 ` Danny ter Haar ` (2 subsequent siblings) 4 siblings, 0 replies; 20+ messages in thread From: Randy.Dunlap @ 2005-10-15 1:55 UTC (permalink / raw) To: Marc Perkel; +Cc: linux-kernel On Fri, 14 Oct 2005 18:46:46 -0700 Marc Perkel wrote: > Is there any way to force an immediate reboot as if to push the reset > button in software? Got a remote server that i need to reboot and > shutdown isn't working. What kernel version? Does it have sysrq enabled? If 2.6.x and Yes, then you should be able to do: echo b > /proc/sysrq-trigger to cause a reboot. --- ~Randy ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel 2005-10-15 1:50 ` Lee Revell 2005-10-15 1:55 ` Randy.Dunlap @ 2005-10-15 2:24 ` Danny ter Haar 2005-10-15 6:21 ` Willy Tarreau 2005-10-15 10:24 ` Denis Vlasenko 4 siblings, 0 replies; 20+ messages in thread From: Danny ter Haar @ 2005-10-15 2:24 UTC (permalink / raw) To: linux-kernel Marc Perkel <marc@perkel.com> wrote: >Is there any way to force an immediate reboot as if to push the reset >button in software? Got a remote server that i need to reboot and >shutdown isn't working. reboot -nf Doesn't sync just plain reboot Danny ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel ` (2 preceding siblings ...) 2005-10-15 2:24 ` Danny ter Haar @ 2005-10-15 6:21 ` Willy Tarreau 2005-10-15 6:50 ` Coywolf Qi Hunt 2005-10-15 10:24 ` Denis Vlasenko 4 siblings, 1 reply; 20+ messages in thread From: Willy Tarreau @ 2005-10-15 6:21 UTC (permalink / raw) To: Marc Perkel; +Cc: linux-kernel On Fri, Oct 14, 2005 at 06:46:46PM -0700, Marc Perkel wrote: > Is there any way to force an immediate reboot as if to push the reset > button in software? Got a remote server that i need to reboot and > shutdown isn't working. If you can telnet it, simply use this : # echo 1 >/proc/sys/kernel/sysrq # echo b >/proc/sysrq-trigger It's dirty and you'll have an fsck. But it will nearly always work. I use it a lot in local on distros on which the shutdown process is as long as the boot process (you know, the ones which display lots of 'OK' or wait indefinitely for some dead services to stop, when you really want them to reboot quickly). Cheers, Willy ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 6:21 ` Willy Tarreau @ 2005-10-15 6:50 ` Coywolf Qi Hunt 0 siblings, 0 replies; 20+ messages in thread From: Coywolf Qi Hunt @ 2005-10-15 6:50 UTC (permalink / raw) To: Willy Tarreau; +Cc: Marc Perkel, linux-kernel On 10/15/05, Willy Tarreau <willy@w.ods.org> wrote: > On Fri, Oct 14, 2005 at 06:46:46PM -0700, Marc Perkel wrote: > > Is there any way to force an immediate reboot as if to push the reset > > button in software? Got a remote server that i need to reboot and > > shutdown isn't working. > > If you can telnet it, simply use this : > > # echo 1 >/proc/sys/kernel/sysrq > # echo b >/proc/sysrq-trigger > > It's dirty and you'll have an fsck. But it will nearly always work. You may avoid the fsck by: # echo s >/proc/sysrq-trigger # echo u >/proc/sysrq-trigger > I use it a lot in local on distros on which the shutdown process is > as long as the boot process (you know, the ones which display lots > of 'OK' or wait indefinitely for some dead services to stop, when > you really want them to reboot quickly). -- Coywolf Qi Hunt http://sosdg.org/~coywolf/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Forcing an immediate reboot 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel ` (3 preceding siblings ...) 2005-10-15 6:21 ` Willy Tarreau @ 2005-10-15 10:24 ` Denis Vlasenko 4 siblings, 0 replies; 20+ messages in thread From: Denis Vlasenko @ 2005-10-15 10:24 UTC (permalink / raw) To: Marc Perkel; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 244 bytes --] On Saturday 15 October 2005 04:46, Marc Perkel wrote: > Is there any way to force an immediate reboot as if to push the reset > button in software? Got a remote server that i need to reboot and > shutdown isn't working. See atttached -- vda [-- Attachment #2: hardshutdown.c --] [-- Type: text/x-csrc, Size: 2608 bytes --] /* Including <unistd.h> makes sure that on a glibc system <features.h> is included, which again defines __GLIBC__ */ #include <unistd.h> #include <stdio.h> /* puts */ #include <time.h> /* nanosleep */ #include <errno.h> #include "linux_reboot.h" /* reboot magic */ #define USE_LIBC #ifdef USE_LIBC /* libc version */ #if defined __GLIBC__ && __GLIBC__ >= 2 # include <sys/reboot.h> # define REBOOT(cmd) reboot(cmd) #else extern int reboot(int, int, int); # define REBOOT(cmd) reboot(LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,(cmd)) #endif int my_reboot(int cmd) { return REBOOT(cmd); } #else /* no USE_LIBC */ /* direct syscall version */ #include <linux/unistd.h> #ifdef _syscall3 _syscall3(int, reboot, int, magic, int, magic_too, int, cmd); #else /* Let us hope we have a 3-argument reboot here */ extern int reboot(int, int, int); #endif int my_reboot(int cmd) { return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd); } #endif void do_reboot() { my_reboot(LINUX_REBOOT_CMD_RESTART); } void do_poweroff() { my_reboot(LINUX_REBOOT_CMD_POWER_OFF); } void do_halt() { my_reboot(LINUX_REBOOT_CMD_HALT); } void usage() { puts( "Usage: hardshutdown -h|-r|-p [NN]\n" " NN - seconds to sleep before requested action" ); exit(1); } enum action_t { SHUTDOWN, // do nothing HALT, POWEROFF, REBOOT }; int main(int argc, char *argv[]) { struct timespec t = {0,0}; enum action_t action = SHUTDOWN; int c, i; char *prog, *ptr; //if(*argv[0] == '-') argv[0]++; /* allow shutdown as login shell */ prog = argv[0]; if( (ptr=strrchr(prog,'/')) != 0 ) prog = ptr+1; /* All names (halt, reboot, shutdown) refer to the same program with the same options, only the defaults differ. */ if(!strcmp("hardhalt", prog)) { action = HALT; } else if(!strcmp("hardpoweroff", prog)) { action = POWEROFF; } else if(!strcmp("hardreboot", prog)) { action = REBOOT; } for(c=1; c < argc; c++) { if(argv[c][0] >= '0' && argv[c][0] <= '9') { t.tv_sec = strtol(argv[c], NULL, 10); continue; } if(argv[c][0] != '-') { usage(); return 1; } for(i=1; argv[c][i]; i++) { switch(argv[c][i]) { case 'h': action = HALT; break; case 'p': action = POWEROFF; break; case 'r': action = REBOOT; break; default: usage(); return 1; } } } if(action==SHUTDOWN) { usage(); return 1; } chdir("/"); while(nanosleep(&t,&t)<0) if(errno!=EINTR) break; switch(action) { case HALT: do_halt(); break; case POWEROFF: do_poweroff(); break; case REBOOT: do_reboot(); break; } return 1; } [-- Attachment #3: linux_reboot.h --] [-- Type: text/x-objchdr, Size: 932 bytes --] /* * Magic values required to use _reboot() system call. */ #define LINUX_REBOOT_MAGIC1 0xfee1dead #define LINUX_REBOOT_MAGIC2 672274793 #define LINUX_REBOOT_MAGIC2A 85072278 #define LINUX_REBOOT_MAGIC2B 369367448 /* * Commands accepted by the _reboot() system call. * * RESTART Restart system using default command and mode. * HALT Stop OS and give system control to ROM monitor, if any. * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. * POWER_OFF Stop OS and remove all power from system, if possible. * RESTART2 Restart system using given command string. */ #define LINUX_REBOOT_CMD_RESTART 0x01234567 #define LINUX_REBOOT_CMD_HALT 0xCDEF0123 #define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF #define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 #define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 [-- Attachment #4: mkdiet.sh --] [-- Type: application/x-shellscript, Size: 72 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2005-10-16 0:10 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-10-15 1:46 Forcing an immediate reboot Marc Perkel 2005-10-15 1:50 ` Lee Revell 2005-10-15 6:47 ` Coywolf Qi Hunt 2005-10-15 6:51 ` Marc Perkel 2005-10-15 7:48 ` Anton Altaparmakov 2005-10-15 7:56 ` Coywolf Qi Hunt 2005-10-15 8:16 ` Anton Altaparmakov 2005-10-16 0:10 ` Petr Vandrovec 2005-10-15 13:23 ` documentation? (i learned something today ;-) ) Damir Perisa 2005-10-15 13:40 ` Benoit Boissinot 2005-10-15 14:52 ` Documentation/files somewhere online? Damir Perisa 2005-10-15 15:02 ` Denis Vlasenko 2005-10-15 15:13 ` Michael Krufky 2005-10-15 23:18 ` Documentation/files online: available at git in webinterface Damir Perisa 2005-10-15 14:29 ` Forcing an immediate reboot Marc Perkel 2005-10-15 1:55 ` Randy.Dunlap 2005-10-15 2:24 ` Danny ter Haar 2005-10-15 6:21 ` Willy Tarreau 2005-10-15 6:50 ` Coywolf Qi Hunt 2005-10-15 10:24 ` Denis Vlasenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox