shutdown on BSD and Linux

Oliver Fromme check+j57sbr00rs54722k at fromme.com
Thu Sep 7 03:53:32 PDT 2006


Rahul Siddharthan <rsidd at xxxxxxxxx> wrote:
 > I've long had a question on the shutdown process.  Linux systems run a
 > separate shutdown script for every process that was started at boot,
 > and can take a minute or two to shutdown.  FreeBSD and Dragonfly, as
 > far as I can tell, just kill all processes, flush buffers, unmount
 > filesystems and shutdown/poweroff, which takes about 5 seconds.

It also executes stop-scripts, depending on which kind of
applications you are using.  For example, the PostgreSQL
database installs a script in /usr/local/etc/rc.d that is
used to start or stop the service.  That's because it is
important to stop the database cleanly instead of just
blindly killing the process (although Postgres is pretty
robust in that regard and usually survives all such evil
things).

However, not all applications and services require a script
for stopping.  In particular, the daemon processes in the
base system (syslog, cron etc.) don't need any special
actions, so it's sufficient to catch them with the final
SIGTERM that init(8) broadcasts to all processes (followed
by SIGKILL for those processes that ignored it).  Also,
BSD traditionally doesn't umount file systems or takes
network interfaces down upon a shutdown, so there's no need
to run stop scripts for those, either.  All of that saves
a lot of time.

 > So what's up?  Is BSD-style shutdown dangerous, or are the Linux
 > people stupid?

Neither nor.

BSD and Linux have very different init/rc implmentations.
Linux has a SysV-style runlevel implementation (similar to
Solaris), which means that certain scripts get executed
whenever the system enters a different runlevel.  A shut-
down is a separate runlevel, too, so it executes scripts to
cleanly shutdown daemons etc.  In Linux, every little fart
has its own script with a considerable overhead, and they
are quite verbose.

The BSD world traditionally doesn't have such a system of
runlevels.  Nevertheless, when you use shutdown(8), scripts
from /usr/local/etc/rc.d/* are executed with an argument of
"stop" (DragonFly has inherited that feature from FreeBSD).

Meanwhile, FreeBSD has implemented a system called "rcNG"
which also seperates out most parts of the traditional BSD-
style /etc/rc into many small start/stop scripts in the
/etc/rc.d directory.  DF has also taken that from FreeBSD.

 > BTW - the poweroff on my laptop, with Dragonfly and FreeBSD (last I
 > checked), is also accompanied by a rather alarming and short-lived
 > whine, as if a spinning disk or fan was suddenly stopped.  I don't get
 > this sound with linux or windows.

Could that be the CD/DVD drive?

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd

Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.





More information about the Users mailing list