JustAnswer.com

Friday, November 23, 2007

Linux boots

Linux boots



When system shutdown time finally arrives, shutdown tells init to switch to
runlevel 0 for a halt and runlevel 6 for a reboot. When init enters runlevel 0
or 6, all of the following takes place, which you can verify by looking at the scripts inside rc0.d and rc6.d:

1. init kills every process that it can (as it would when switching to any other runlevel).

# The initial rc0.d/rc6.d commands run, locking system files into place and making
other preparations for shutdown. # The next rc0.d/rc6.d commands unmount all
filesystems other than the root. # Further rc0.d/rc6.d commands remount the root
filesystem read-only. # Still more rc0.d/rc6.d commands write all buffered data
out to the filesystem with the sync program. # The final rc0.d/rc6.d commands tell
the kernel to reboot or stop with the reboot, halt, or poweroff program.

The reboot and halt programs behave differently for each runlevel, potentially
causing confusion. By default, these programs call shutdown with the -r or -h options,
but if the system is already at the halt or reboot runlevel, the programs tell the
kernel to shut itself off immediately. If you really want to shut your machine down
in a hurry (disregarding any possible damage from a disorderly shutdown), use the -f option.