⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0037-0040.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:System Startup and Shutdown</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=04 //-->

<!-- PAGES=0037-0052 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="../ch03/0031-0036.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0041-0043.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-37"><P>Page 37</P></A>









<H3><A NAME="ch04_ 1">

CHAPTER 4

</A></H3>









<H2>



System Startup and Shutdown



</H2>









<B>by Bill Ball

</B>











<H3><A NAME="ch04_ 2">

IN THIS CHAPTER

</A></H3>









<UL>

<LI>     The Boot Process 38

<LI>     The Initialization Process and Startup

         Scripts 38

<LI>     tksysv and Managing Your Services 43

<LI>     Shutting Down the Linux System 44

<LI>     When the System Crashes 46

</UL>



<A NAME="PAGENUM-38"><P>Page 38</P></A>















<P>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.

</P>









<P>Also, this chapter presents some tips on how to customize your system and how to avoid

problems with system crashes.

</P>









<H3><A NAME="ch04_ 3">

The Boot Process

</A></H3>









<P>In Chapter 2, &quot;Installation of Your Red Hat System,&quot; you learned

how to install Linux, and in Chapter 3, &quot;LILO,&quot; 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

<a href="http://www.redhat.com/linux-info.">http://www.redhat.com/linux-info.</A>

</P>









<P>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.

</P>









<P>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.

</P>









<P>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 &quot;Diskless Linux Mini HOWTO,&quot; 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.

</P>









<P>According to the Red Hat folks, this approach is becoming the standard in the &quot;Linux

world&quot; because it is &quot;easier to use and more powerful and flexible.&quot; 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

&quot;tksysv and Managing Your Services.&quot;

</P>









<H3><A NAME="ch04_ 4">

The Initialization Process and Startup Scripts

</A></H3>









<P>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.

</P>



<A NAME="PAGENUM-39"><P>Page 39</P></A>











<P>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: &quot;hot-swappable&quot; hardware and <BR>

software. This means you can change hard drives, PC cards, or associated software

on-the-fly&#151;while the system is running.

</P>









<P>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):

</P>





<!-- CODE //-->

<PRE>

#   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)

</PRE>

<!-- END CODE //-->











<P>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.

</P>









<H4><A NAME="ch04_ 5">

init and /etc/inittab

</A></H4>









<P>The init man page states, &quot;init is the father of

all processes.&quot; Its primary role is to create <BR>

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 &quot;the last step of the kernel booting,&quot; 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.

</P>









<P>Here's a listing of the /etc/rc.d directory:

</P>





<!-- CODE //-->

<PRE>

init.d/

rc*

rc.local*

rc.news*

rc.sysinit*

rc0.d/

rc1.d/

rc2.d/

rc3.d/

rc4.d/

rc5.d/

rc6.d/

</PRE>

<!-- END CODE //-->





<A NAME="PAGENUM-40"><P>Page 40</P></A>











<P>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:

</P>





<!-- CODE //-->

<PRE>

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*

</PRE>

<!-- END CODE //-->











<H4><A NAME="ch04_ 6">

/etc/inittab and System States

</A></H4>









<P>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.

</P>









<P>However, much like other versions of UNIX, the Red Hat Linux

sysinit script performs some or all of the following functions:

</P>









<UL>

<LI>         Sets some initial

$PATH variables

<LI>         Configures networking

<LI>         Starts up swapping for virtual memory

<LI>         Sets the system hostname

<LI>         Checks root filesystems for possible repairs

<LI>         Checks root filesystem quotas

<LI>         Turns on user and group quotas for root filesystem

<LI>         Remounts the root filesystem read/write

</UL>



<P><CENTER>

<a href="../ch03/0031-0036.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0041-0043.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -