-->
Page 37
Page 38
This chapter explains how to start the Red Hat Linux system and how to properly shut it down. It also covers system crashes and what to do if your system won't boot.
Also, this chapter presents some tips on how to customize your system and how to avoid problems with system crashes.
In Chapter 2, "Installation of Your Red Hat System," you learned how to install Linux, and in Chapter 3, "LILO," you found out how to install and use different loaders for different computers. There are a number of ways to start Linux with different computers, and a number of different ways to load in the Linux kernel. Intel Linux users will most likely use LILO, LOADLIN, SYSLINUX, or the commercial alternative, System Commander. SPARC users will use SILO, and Alpha users will probably use MILO. You'll find the basic steps outlined in your Red Hat Linux Users Guide, or through Red Hat at http://www.redhat.com/linux-info.
I'm assuming most readers will install Red Hat Linux/Intel, so here's a little background on how the Red Hat Linux startup process is different from that of other UNIX operating systems, such as BSD.
PCs start by looking at the first sector of the first cylinder of the boot drive, and then trying to load and execute code found there (which is how LILO works, as you found out in Chapter 3). This is also the case with other (but not all) hardware systems and versions of UNIX. You should be able to set the order in which your PC looks for the boot drive. This is usually done through a BIOS change in a setup menu you can invoke when you first turn on your machine. This can be handy if you never use a boot floppy. For example, laptop users with an external floppy can speed up the boot process by directing the computer to first look to the internal hard drive or CD-ROM.
You can also start Linux over a network and run a diskless Linux box. For more information on how to do this, see Robert Nemkin's "Diskless Linux Mini HOWTO," under /usr/doc/HOWTO/mini. Although Linux shares many similar traits with both System V and BSD UNIX, in the case of booting and starting the system, Linux is closer to the former. This means that Linux uses the init command and a similar directory structure of associated scripts to start running the system and loading processes.
According to the Red Hat folks, this approach is becoming the standard in the "Linux world" because it is "easier to use and more powerful and flexible." And you'll see why it is even easier for Red Hat Linux users when you learn about the tksysv client later in this chapter in the section "tksysv and Managing Your Services."
This section describes how Linux starts and details the functions of the different startup scripts used to prepare your system for use. An important concept to first note is the use of various runlevels or system states of Linux.
Page 39
System states grew out of early versions of UNIX from the need to separate how the system
ran according to the different forms of maintenance being performed on a system. This is
similar to performing a software or hardware upgrade on older PCs, which generally requires a
reboot or shutdown and restart of the computer. These days, however, this practice is partially
obviated through new software and hardware technologies: "hot-swappable" hardware and
software. This means you can change hard drives, PC cards, or associated software
on-the-flywhile the system is running.
You'll find a description of these different runlevels in the /etc/inittab file, or initialization table. Although Linux differs from other versions of UNIX in several of the levels, Red Hat Intel/Linux mainly uses the following (as listed in /etc/inittab):
# The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this)
The next section describes these runlevels, including the first startup script in the initialization table, /etc/rc.d/rc.sysinit, or the system initialization script, which is run once at boot time by the init command. The /etc/rc.d directory structure and what some of these scripts do are also covered.
The init man page states, "init is the father of
all processes." Its primary role is to create
processes from a script stored in /etc/inittab. Much of how Linux starts its processes
after loading the kernel comes from another UNIX, System V. In fact, the Linux
init command is compatible with the System V init command, and the startup scripts model that
approach. Although init starts as "the last step of the kernel booting," it is the first command that
initializes and configures your system for use.
init works by parsing /etc/inittab and running
scripts in /etc/rc.d according to either a default or desired runlevel. Each script can start or stop
a service, such as a networking, mail, news, or Web service.
Here's a listing of the /etc/rc.d directory:
init.d/ rc* rc.local* rc.news* rc.sysinit* rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/
Page 40
Under the init.d directory, you'll find a number of scripts used to start and stop services. I won't go into the details about each, but you should be able to guess at the function of some of them by their names. Here's a list:
amd.init* cron.init* functions* gpm* halt* httpd.init* inet* keytable* killall* lpd.init* mars_nwe.init* named.init* network* news* nfs* nfsfs* pcmcia* portmap.init* random* sendmail.init* single* skeleton* smb* syslog* yppasswd.init* ypserv.init*
One of the most important scripts in /etc/inittab is rc.sysinit, the system initialization script. When init parses /etc/inittab, this is the first script found and executed. This differs slightly from other versions of UNIX, which might include the system initialization commands directly in the /etc/inittab file.
However, much like other versions of UNIX, the Red Hat Linux sysinit script performs some or all of the following functions: