Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Speeding up shutdown and reboot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
feystorm
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2004
Posts: 96

PostPosted: Thu Jan 04, 2007 6:10 am    Post subject: Speeding up shutdown and reboot Reply with quote

I'm impatient when it comes to waiting for the computer, and it makes me even more nuts when I'm waiting for it to do something it doesnt need to be doing in the first place (hence why I'm in linux and not windows).

Unfortunately I still need windows for some things and have to reboot to switch to it often, and imho, gentoo just takes way to long to stop all the init scripts. Many programs of said init scripts are fine having the plug pulled on them, and dont need to be shut down by a script.
So, just let them get shut down when the machine powers off/reboots.

This is not for all init scripts, some programs do need to be shut down properly. But many such as sshd, net.eth*, xinetd, etc can just get the plug pulled, and theres no harm done.



Its really simple, edit the init script in /etc/init.d of the script you think takes too long to shut down, and add as the first line inside the "stop" function
Code:
if [[ "${RUNLEVEL}" == "6" || "${RUNLEVEL}" == "0" ]]; then return 0; fi

so for sshd, the init script
Code:
stop() {
        ebegin "Stopping ${SVCNAME}"
        start-stop-daemon --stop --quiet \
            --exec ${SSHD_BINARY} --pidfile ${SSHD_PIDFILE}
        eend $?
}

becomes
Code:
stop() {
        if [[ "${RUNLEVEL}" == "6" || "${RUNLEVEL}" == "0" ]]; then return 0; fi
        ebegin "Stopping ${SVCNAME}"
        start-stop-daemon --stop --quiet \
            --exec ${SSHD_BINARY} --pidfile ${SSHD_PIDFILE}
        eend $?
}




This just says if the system is going to either runlevel 6 (reboot) or runlevel 0 (shutdown), quit the script.
You dont want to just remove the stop section because you might want to manually stop the script, or if you change to another runlevel.

Now, this trick will leave the pid files of sshd and such in place, but when your system comes back up, theyre just going to be re-written anyway.
Back to top
View user's profile Send private message
no_hope
Guru
Guru


Joined: 23 Jun 2003
Posts: 482

PostPosted: Thu Jan 04, 2007 1:55 pm    Post subject: Reply with quote

I hated slow shutdowns too, but now I run my Windows in VMWare :)

How much time do you actually save that way?

Here's a trick I picked up the speed demon inside all of us might appreciate:

  • save your data (and, if you are a pansy, stop services that need clean shutdowns)
  • Alt-SysRq-S-U-B (tells kernel to sync, unmount filesystems and reboot)


Or, if you are not hardcore, try this:
APLawrence.com wrote:
Alt+SysRq+s - sync the disk
Alt+SysRq+e - try to nicely kill processes
(wait a little bit here)
Alt+SysRq+i - no more mister nice guy
Alt+SysRq+u - unmount disks
(wait a bit here, too)
Alt+SysRq+b - reboot
I can remember that with "So Everything Is Unusual - Boot!"
Back to top
View user's profile Send private message
PsychoX
n00b
n00b


Joined: 17 Nov 2006
Posts: 70

PostPosted: Thu Jan 04, 2007 10:09 pm    Post subject: Reply with quote

no_hope wrote:
I hated slow shutdowns too, but now I run my Windows in VMWare :)

How much time do you actually save that way?

Here's a trick I picked up the speed demon inside all of us might appreciate:

  • save your data (and, if you are a pansy, stop services that need clean shutdowns)
  • Alt-SysRq-S-U-B (tells kernel to sync, unmount filesystems and reboot)


Or, if you are not hardcore, try this:
APLawrence.com wrote:
Alt+SysRq+s - sync the disk
Alt+SysRq+e - try to nicely kill processes
(wait a little bit here)
Alt+SysRq+i - no more mister nice guy
Alt+SysRq+u - unmount disks
(wait a bit here, too)
Alt+SysRq+b - reboot
I can remember that with "So Everything Is Unusual - Boot!"


or if You're really hardcore just press reboot button :)
Back to top
View user's profile Send private message
feystorm
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2004
Posts: 96

PostPosted: Fri Jan 05, 2007 12:15 am    Post subject: Reply with quote

too lazy to have to reach over and press the button
Back to top
View user's profile Send private message
.yankee
Apprentice
Apprentice


Joined: 24 Feb 2008
Posts: 194
Location: Polska

PostPosted: Mon Nov 03, 2008 7:36 pm    Post subject: Re: Speeding up shutdown and reboot Reply with quote

feystorm wrote:

This is not for all init scripts, some programs do need to be shut down properly. But many such as sshd, net.eth*, xinetd, etc can just get the plug pulled, and theres no harm done.


This could be very useful for my old machine. Could you give some hints, as to which services can be safely left to die this way? Or which surely cannot?
Back to top
View user's profile Send private message
a.b.
Apprentice
Apprentice


Joined: 23 Mar 2008
Posts: 218
Location: Anus Mundi, Germany

PostPosted: Mon Nov 03, 2008 10:23 pm    Post subject: Reply with quote

You could also use something like this:
Code:
#!/bin/sh
umount -ar
halt -f
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Thu Nov 06, 2008 1:28 pm    Post subject: Reply with quote

no_hope wrote:
I hated slow shutdowns too, but now I run my Windows in VMWare :)

How much time do you actually save that way?

Here's a trick I picked up the speed demon inside all of us might appreciate:

  • save your data (and, if you are a pansy, stop services that need clean shutdowns)
  • Alt-SysRq-S-U-B (tells kernel to sync, unmount filesystems and reboot)



I've actually shutdown/reboot'ed many many times like this, this is so quick! Best speed improvement ever! :)

Anyway, why would one want to kill processes? Is it because some of them trap the SIGINT/SIGKILL interrupt to do some stuff before quitting?
_________________
The End of the Internet!
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Thu Nov 06, 2008 4:46 pm    Post subject: Reply with quote

I see a different gist, here.

The init scripts are designed for general use, in that their normal case is that you may want to stop a service and later restart it, for instance, to make a configuration change or software update. Shutting things down the way you are may be just fine for shutdown, but would clearly not be good for the general case. So maybe what would be really neat is a new operation for init scripts, in addition to the existing start, stop, status, restart, and zap. Maybe we need a "shutdown" or "halt" option that really means, "take care of any open files that need it, otherwise do nothing and let the final 'killall' shut us down."
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
Aprz
n00b
n00b


Joined: 30 Oct 2008
Posts: 4

PostPosted: Fri Nov 07, 2008 3:08 am    Post subject: Reply with quote

Using eINIT's poweroff is really quick, but I think it's like an improper shutdown or so it seems because when I boot my computer, the filesystems aren't clean. I think it's consider unstable and the project has been abandoned for Kyuba, but Kyuba is not ready.
Back to top
View user's profile Send private message
javeree
Guru
Guru


Joined: 29 Jan 2006
Posts: 453

PostPosted: Fri Nov 07, 2008 8:55 am    Post subject: Reply with quote

I've adapted my acpi script to react to a press on the power button of the PC to just sync all discs and power off => shutdown in a matter of seconds ! If I do that with e.g. a word processor open, it just assumes that I don't care that I loose the dits since the last save, but hey, thats what knowing what you are doing is for.
Anyway, If I do 'shutdown -h now' in an XTerm, I loose an open document also.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Mon Nov 10, 2008 5:58 pm    Post subject: Reply with quote

Just a side comment. These quick poweroffs are probably well and good for laptops, but there are still risks, and laptops just have fewer than a deskside.

At the moment, I'm thinking about my main deskside machine at home, which is also my main (and only) backend for MythTV. Simply sync'ing filesystems isn't enough, there. You need to get a clean shutdown out of MySQL, and to do that you need to shut down mythbackend, first.

With those cautions though, I like the idea, especially for laptops, where things are much more scram-able.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum