Starting Software Devices


After the device driver is loaded into the kernel, it usually needs to be configured. Each device driver has it's own set of tools for doing the configuration. For example, the network uses ifconfig to configure addresses, and PCMCIA support uses cardmgr to notify the operating system when a new card is added or removed. Each driver is different. Some software drivers are only needed once to configure the system (for example, network, audio, and system clock), others are needed continually while the device is in use (for example, high resolution graphics and mouse). A few KLM drivers require no additional assistance-keyboard, hard drives, and USB fall into this category.

In addition to configuring and managing kernel drivers, some software drivers are software- only (no KLM needed). These services include virtual file systems, schedulers, and network services like SSH and the Web.

Using Init.d

As the system boots, kernel drivers are loaded into memory and the init process begins setting the run level. At each run level, different software drivers and services are started. Which ones are started and the order that they are started in is determined by /etc/init.d/ and the rc script. There are eight rc directories: /etc/rc0.d, /etc/rc1.d, … /etc/rc6.d, and /etc/rcS.d. These correspond with the different run levels (0 through 6, and S for single user mode). In each of these directories are symbolic links to files in /etc/init.d. The name of the symbolic link determines whether the script is called when starting (S) or leaving (K for kill) the run level (see Listing 3-2). Each name also has a number, used to order when the service is started. This way, dependent processes can be started in the right order. For example, S13gdm is started before S99rmnologin since the Gnome Display Manager (gdm) should be started before the user login prompt.

The directory /etc/init.d/ contains the actual control scripts (without the S/K and number). Each script has a start, stop, and restart option. So, for example, if you want to restart the network and stop the cron server, you can run:

 sudo /etc/init.d/networking restart sudo /etc/init.d/cron stop 

To make system changes happen after the next reboot, add the appropriate S or K script to the appropriate run-level directory.

Listing 3-2: Directory Contents of /etc/rc6.d

image from book
     $ ls /etc/rc6.d     K01gdm           K20NVidia-kernel  K88pcmciautils     K01usplash       K20postfix        K89klogd     K11anacron       K20powernowd      K90sysklogd     K11atd           K20rsync          K99timidity     K11cron          K20ssh            S01linux-restricted-modules-common     K15fetchmail     K20tor            S20sendsigs     K19cupsys        K20vsftpd         S30urandom     K20acpi-support  K21acpid          S31umountnfs.sh     K20apmd          K21hplip          S35networking     K20bittorrent    K25hwclock.sh     S40umountfs     K20dbus          K25mdadm          S49evms     K20festival      K50alsa-utils     S50lvm     K20hotkey-setup  K74bluez-utils    S50mdadm-raid     K20laptop-mode   K86ppp            S60umountroot     K20makedev       K88pcmcia         S90reboot 
image from book

image from book
Running Ragged

Ubuntu includes seven different run levels: 0-6 and S. Many of the run levels provide very specific services. For example, level 0 is a system halt, 6 reboots the system, and S provides the single-user mode. Under Ubuntu, level 1 provides an alternate single-user mode environment.

The remaining run levels provide different types of multi-user support. Usually the system uses level 2. This provides a graphical user interface (when available) and network support. The default level 3 provides support for accessibility devices, such as a Braille TTY display. Finally, levels 4 and 5 usually look like level 2, however, you can modify them if you need customized run-time environments.

image from book

Configuring Boot Options with services-admin

Managing services by hand can be time consuming. Ubuntu offers an easy applet for enabling and disabling some system services: services-admin. You can run this from the command line, or select it from System image from book Administration image from book Services (see Figure 3-1). Enabling or disabling services only requires changing a check box.

image from book
Figure 3-1: The Services settings applet

Tip 

Checking or unchecking a service will immediately change the service's current running status. It will also alter the service's boot status. This way, if you uncheck a service, you don't need to manually stop any running processes and it will not start at the next boot. Checking a service makes it start immediately and it will start with the next boot.

Although this tool does identify some of the better-known services, it does not list custom services and does not identify different run levels. Since Ubuntu normally runs at run-level 2, you are only modifying whether services will start during run level 2. In order to control more of the boot options, you either need to modify the files in the /etc/init.d and /etc/rc*.d directories, or you need a better tool, like sysv-rc-conf.

Configuring Boot Options with sysv-rc-conf

The services-admin applet does not list all services but is more convenient than manually editing services. The sysv-rc-conf tool offers a middle ground by allowing easy access to the boot services without requiring manual modification of the different startup files found in /etc/init.d and /etc/rc*.d/.

 sudo apt-get install sysv-rc-conf 

Running this tool (sudo sysv-rc-conf) brings up a text list of all services and run-levels (see Figure 3-2). Using this tool, you can immediately start or stop services by pressing + or -, and spacebar enables or disables the service in specific run levels. The tool also supports the mouse; clicking a check box enables or disables the service.

image from book
Figure 3-2: The sysv-rc-conf tool

Tip 

As with the services-admin application, selecting or clearing a service will immediately change the service's running status and alter the service's boot-up configuration.

The sysv-rc-conf tool has one other huge benefit over the services-admin program: it is text based. Although usually graphical applications are easier to use, most system services only need modification when the system is not working properly, and that means using the command line. Furthermore, if you installed the Ubuntu server instead of the desktop (see Chapter 1), then there is no graphical display available. The sysv-rc-conf tool works without needing the entire overhead and installation of a graphical interface.



Hacking Ubuntu
Hacking Ubuntu: Serious Hacks Mods and Customizations (ExtremeTech)
ISBN: 047010872X
EAN: 2147483647
Year: 2004
Pages: 124
Authors: Neal Krawetz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net