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

📄 doc074.htm

📁 Reh Hat user manual. really goooood
💻 HTM
字号:
<html><body><a href="doc075.html"><img src=../icons/next.gif alt="Next"></a><a href="doc000.html"><img src=../icons/up.gif alt="Up"></a><a href="doc073.html"><img src=../icons/previous.gif alt="Previous"></a><a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a><a href="doc123.html"><img src=../icons/index.gif alt="Index"></a><hr><h2><a name="s10.5">10.5 The Boot Process, Init, and Shutdown</a></h2><title>The Boot Process, Init, and Shutdown</title><p><h3><a name="s10.5.1">10.5.1 System V Init</a></h3><title>System V Init</title>This section is a brief description of the internals ofthe boot process.  It basically covers in detail how themachine boots using SysV Init and the differences between the originalinit used in older Linux releases.<p>Init is the program that gets run by the kernel at boot time.It is in charge of starting all the normal processes that needto run at boot time.  These include the gettys that allow youto log in, NFS daemons, FTP daemons, and anything else you wantto run when your machine boots.<p>SysV Init is fast becoming the standard in the Linuxworld to control the startup of software at boot time.  This is because it is easier to use and more powerfuland flexible than the traditional BSD init.<p>SysV init also differs from BSD init in that the configfiles are in a subdirectory of <tt>/etc</tt> instead of residingdirectly in <tt>/etc</tt>.  This directory is called <tt>rc.d</tt>.  Inthere you will find <tt>rc.sysinit</tt> and the following directories:<p><blockquote><font size=-1><tt><pre>init.drc0.drc1.drc2.drc3.drc4.drc5.drc6.d</pre></tt></font></blockquote><p><tt>init.d</tt> contains a bunch of scripts.  Basically, you need one script for each service you may need to start at boot time or when entering another runlevel.  Services include thingslike networking, nfs, sendmail, httpd, etc.  Services do notinclude things like setserial that must only be run once andthen exited.  Things like that should go in <tt>rc.local</tt> or <tt>rc.serial</tt>.<p>If you want <tt>rc.local</tt>, it should be in <tt>/etc/rc.d</tt>.  Most systemsinclude one even though it doesn't do much.  You can also include an rc.serial in <tt>/etc/rc.d</tt> if you need to do serial port specific things at boot time.<p>The chain of events is as follows:<ul><li>The kernel looks in several places for <tt>init</tt> and runs the first one it finds<li><tt>init</tt> runs <tt>/etc/rc.d/rc.sysinit</tt><li><tt>rc.sysinit</tt> does a bunch of necessary things and then runs <tt>rc.serial</tt> (if it exists)<li><tt>init</tt> runs all the scripts for the default runlevel.<li><tt>init</tt> runs <tt>rc.local</tt></ul><p>The default runlevel is decided in <tt>/etc/inittab</tt>.  You shouldhave a line close to the top like:<p><blockquote><font size=-1><tt><pre>id:3:initdefault:</pre></tt></font></blockquote><p>From this, you'd look in the second column and see that thedefault runlevel is 3, as should be the case for most systems.If you want to change it, you can edit <tt>/etc/inittab</tt> by handand change the 3.  Be very careful when you are messing with theinittab.  If you do mess up, you can fix it byrebooting and doing:<a name="i243"><blockquote><font size=-1><tt><pre>LILO boot:  linux single</pre></tt></font></blockquote><p>This <em>should</em> allow you to boot into single user mode so youcan fix inittab.<p>Now, how does it run all the right scripts?  If you enter<tt>ls -l</tt> on <tt>rc3.d</tt>, you might see something like:<p><blockquote><font size=-1><tt><pre>lrwxrwxrwx 1 root root 17  13:11 S10network -&gt; ../init.d/networklrwxrwxrwx 1 root root 16  13:11 S30syslog -&gt; ../init.d/sysloglrwxrwxrwx 1 root root 14  13:32 S40cron -&gt; ../init.d/cronlrwxrwxrwx 1 root root 14  13:11 S50inet -&gt; ../init.d/inetlrwxrwxrwx 1 root root 13  13:11 S60nfs -&gt; ../init.d/nfslrwxrwxrwx 1 root root 15  13:11 S70nfsfs -&gt; ../init.d/nfsfslrwxrwxrwx 1 root root 18  13:11 S90lpd -&gt; ../init.d/lpd.initlrwxrwxrwx 1 root root 11  13:11 S99local -&gt; ../rc.local</pre></tt></font></blockquote><p>What you'll notice is that there are no real ``files'' inthe directory.  Everything there is a link to one of thescripts in the init.d directory.  The links also havean ``S'' and a number at the beginning.  The ``S'' means to start this particular script and a ``K'' would mean to stop it.  The number is there just for ordering purposes.  Init will start all the services based onthe order they appear.  You can duplicate numbers, butit will only confuse you somewhat.  You just need touse a two digit number only, along with an uppercase ``S'' or ``K'' to start or stop the services you needto.<p>How does init start and stop services?  Simple.  Each ofthe scripts is written to accept an argument whichcan be ``start'' and ``stop''.  You can execute thosescripts by hand in fact with a command like:<p><blockquote><font size=-1><tt><pre>/etc/rc.d/init.d/httpd.init stop</pre></tt></font></blockquote><p>to stop the httpd server.  Init just reads the nameand if it has a ``K'', it calls the script with the``stop'' argument.  If it has an ``S'' it calls the scriptwith a ``start'' argument.  Why all these runlevels?Some people want an easy way to set up machines to bemulti-purpose.  I could have a ``server'' runlevel thatjust runs httpd, sendmail, networking, etc.  Then Icould have a ``user'' runlevel that runs xdm, networking,etc. <p><h3><a name="s10.5.2">10.5.2 Init Runlevels</a></h3><title>Init Runlevels</title><p>Generally, Red Hat Linux runs in run level 3---full multiuser mode.The following runlevels are used in Red Hat Linux:<p><blockquote><dl><dt><b>0</b><dd>Halt.<dt><b>1</b><dd>Single user mode.<dt><b>2</b><dd>Multiuser mode, without NFS.<dt><b>3</b><dd>Full multiuser mode.<dt><b>6</b><dd>Reboot.</dl></blockquote><p>If your machine gets into a state where it will not boot due to abad <tt>/etc/inittab</tt>, or will not let you log in because you have a corrupted <tt>/etc/passwd</tt> or have simply forgotten your password, boot intosingle user mode by typing <tt>linux 1</tt> at the LILO boot prompt.A very bare system will come up and you will be given a shell from whichyou can fix things.<p><h3><a name="s10.5.3">10.5.3 Shutting Down</a></h3><title>Shutting Down</title><a name="i244">To shutdown Red Hat Linux, issue the <tt>shutdown</tt> command.You can read the shutdown man page for complete details, but thetwo most common usages are:<p><blockquote><font size=-1><tt><pre>shutdown -h nowshutdown -r now</pre></tt></font></blockquote><p>Each will cleanly shutdown the system.  After shutting everythingdown, the first will halt the machine, and the second will reboot.<a name="i245"><p>Avoid running the <tt>reboot</tt> or <tt>halt</tt> commands directly in orderto prevent damage to your filesystem.<p><p><hr><a href="doc075.html"><img src=../icons/next.gif alt="Next"></a><a href="doc000.html"><img src=../icons/up.gif alt="Up"></a><a href="doc073.html"><img src=../icons/previous.gif alt="Previous"></a><a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a><a href="doc123.html"><img src=../icons/index.gif alt="Index"></a><hr></body></html>

⌨️ 快捷键说明

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