The Debian Maintenance HOWTO
Chapter 7 - Booting and Runlevel
The regular boot process of a Debian system does not use an initial ramdisk. This is only required if you plan to boot off of LVM or if you use a hardware RAID system that requires a special kernel module which is neither provided by the regular kernel nor provided as source so you can compile it into the kernel.. If you need an initial ramdisk you will need to set it up on your own.
By default a Debian system boots into runlevel 2. By default runlevel 2, 3, 4
and 5 are equivalent. You are free to change this to whatever you like. I
have heard people who want to have runlevel 2 being multiuser without net, 3
being multiuser with net and 4 being multiuser with net and X11. There are no
restrictions. Though, when installing new Debian packages, they will install
itself into runlevel 2, 3, 4 and 5 equivalently. If you don't want to have
them run in one of these levels, you have to remove them from thes levels
manually. If you want your system to boot into a runlevel different from 2,
you have to edit the line id:2:initdefault: in
/etc/inittab.
There are two ways to tell the system which programs are to be started in which
runlevel. For each such program a start/stop script exists in
/etc/init.d/. The SysV method uses symbolic links in
/etc/rc?.d. The second method uses a plain text file
/etc/runlevel.conf. Debian supports both methods by providing a
unified interface for it: update-rc.d. When installing a new
system SysV style is default. If you want to use the second method (which is
much more userfriendly when it comes to editing runlevels) you will have to
install the package file-rc.
7.1 Reloading/Restarting a service
All services that get started during system boot have a script in
/etc/init.d referenced to it. These scripts understand at least
five arguments (some of them understand more). These are:
-
start - starts the service if it wasn't started already. It will result in an error message if it is already running.
-
stop - stops the service if it is running. It may result in an error message if the service is not running already.
-
reload - will tell the service to reload its configuration files if there are any and the service has support for reloading.
-
restart - will restart the service, i.e. stop it and then start it again.
-
force-reload - will make the service to reload its configuration files. If there is proper support this is just an alias for reload. If support for reloading is missing it's an alias for restart.
7.2 Adding a new service
You can only add a new service to the boot sequence if a script in
/etc/init.d exists. In that case the following command will
install it with default settings (foo being the name of a script in
/etc/init.d). For details please refer to the manpage of that
program.
update-rc.d foo defaults
7.3 Removing a service
A service may only be removed after the script in /etc/init.d as
deleted already. If so, the following command will remove its references (foo
being the name of a script in /etc/init.d).
update-rc.d foo remove
If you want to remove a service without removing the start/stop script as well,
you may consider using the file-rc package and editing the
runlevel configuration file /etc/runlevel.conf. When using the
SysV method you should rename the start/stop script, then call
update-rc.d and then rename the start/stop script back to its old
name.
The Debian Maintenance HOWTO
November 23rd, 2014Joey Schulze, joey@infodrom.org
