📄 unx34.htm
字号:
<HTML>
<HEAD>
<TITLE>UNIX Unleashed unx34.htm</TITLE>
<LINK REL="ToC" HREF="index.htm">
<LINK REL="Next" HREF="unx35.htm">
<LINK REL="Previous" HREF="unx33.htm"></HEAD>
<BODY TEXT="#000000" LINK="#0000FF" VLINK="#800080" bgcolor=white>
<P><A HREF="unx33.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="index.htm"><IMG SRC="blutoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="unx35.htm"><IMG SRC="blunext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<A HREF="index.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Home"></A>
</P><UL>
<LI>
<A HREF="#I1">34 — Starting Up and Shutting Down</A></LI>
<UL>
<UL>
<UL>
<UL>
<LI>
<A HREF="#I3">By Chris Negus</A></LI></UL></UL>
<LI>
<A HREF="#I4">Booting the System</A></LI>
<LI>
<A HREF="#I5">Turning On the Computer</A></LI>
<LI>
<A HREF="#I6">Booting Multiple Operating Systems (Intel)</A></LI>
<LI>
<A HREF="#I7">Understanding System States</A></LI>
<LI>
<A HREF="#I8">Understanding the Initialization Table (inittab)</A></LI>
<LI>
<A HREF="#I9">Understanding Run State Directories (rc?.d)</A></LI>
<LI>
<A HREF="#I10">Understanding Startup Scripts</A></LI>
<LI>
<A HREF="#I11">Example The Mouse Startup Script</A></LI>
<LI>
<A HREF="#I12">Changing States with init or telinit</A></LI>
<LI>
<A HREF="#I13">Shutting Down the System</A></LI>
<UL>
<LI>
<A HREF="#I14">Using the Shutdown Icon</A></LI></UL>
<LI>
<A HREF="#I15">Using the shutdown Command</A></LI>
<UL>
<LI>
<A HREF="#I16">Turning Off the Computer</A></LI>
<LI>
<A HREF="#I17">Miscellaneous Startup and Shutdown Notes</A></LI></UL>
<LI>
<A HREF="#I18">Summary</A></LI></UL></UL></UL>
<H1 ALIGN="CENTER">
<CENTER><A ID="I1" NAME="I1">
<BR>
<FONT SIZE=5><A ID="I2" NAME="I2"></A><B>34 — Starting Up and Shutting Down</B>
<BR></FONT></A></CENTER></H1>
<H5 ALIGN="CENTER">
<CENTER><A ID="I3" NAME="I3">
<FONT SIZE=3><B>By Chris Negus</B>
<BR></FONT></A></CENTER></H5>
<H3 ALIGN="CENTER">
<CENTER><A ID="I4" NAME="I4">
<FONT SIZE=4><B>Booting the System</B>
<BR></FONT></A></CENTER></H3>
<P>Before you can use your computer, you must start up the operating system. Starting the operating system is referred to as booting. When the system has been booted, the devices, applications, and services on your computer are available to be used.
<BR></P>
<P>Because UNIX is a powerful multitasking and multiuser operating system, many processes are set in motion when you start it up. First, UNIX runs system initialization processes to do things such as set the system clock from hardware, configure devices,
and build a new UNIX kernel (if necessary). Then the system begins running processes associated with the particular initialization state (or init state) assigned to your system.
<BR></P>
<P>When the UnixWare version of the UNIX system is delivered, the default run state for your system is state 3. This state makes your UNIX system available for multiuser use in a networked environment (including file sharing). What this means is that all
file systems are connected (mounted) on your system, daemon processes are started to let users log in, and processes to handle incoming and outgoing networking traffic are started.
<BR></P>
<P>You can achieve different levels of activity and access to your system by setting it to boot to other states or by changing system states while your system is running. These states range from the full network/multiuser state (state 3) to
single-user/limited access states (states 1 and 2).
<BR></P>
<P>This chapter describes the processing that occurs when you start up and shut down your UNIX system. It also describes how you can change your system to different system states while it is running. Examples in this chapter are based on the UnixWare
version of UNIX, as implemented on an IBM PC or compatible (that is, Intel 386 technology).
<BR></P>
<H3 ALIGN="CENTER">
<CENTER><A ID="I5" NAME="I5">
<FONT SIZE=4><B>Turning On the Computer</B>
<BR></FONT></A></CENTER></H3>
<P>When you turn on a computer that has the UNIX system installed, starting up UNIX is managed by a process called init. The init process sets many processes in motion, based on the initialization state defined in the /etc/inittab file.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> A computer's hard disk can have several operating systems installed. The description in this system assumes that UNIX is the active operating system configured on your computer. See the description of
fdisk for information on assigning different operating systems to boot on your computer.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>This section describes what happens when you start up the UnixWare 1.1 version of the UNIX system on your personal computer, as it is delivered from Novell, Inc.
<BR></P>
<P>The init process starts up and checks the /etc/inittab file. The first thing init does is run processes that are marked in the inittab file as sysinit processes. sysinit processes are those that make sure the system is set up properly.
<BR></P>
<P>init finds the following sysinit lines in the /etc/inittab file:
<BR></P>
<PRE>cr::sysinit:/sbin/ckroot >/dev/sysmsg 2>&1
ck::sysinit:/sbin/setclk >/dev/sysmsg 2>&1
mm::sysinit:/etc/conf/bin/idmodreg >/dev/sysmsg 2>&1
ldmd::sysinit:/etc/conf/bin/idmodload >/dev/sysmsg 2>&1
ap::sysinit:/sbin/autopush f /etc/ap/chan.ap
bchk::sysinit:/sbin/bcheckrc </dev/console >/dev/sysmsg 2>&1
bu::sysinit:/etc/conf/bin/idrebuild reboot </dev/console >/dev/sysmsg 2>&1
ia::sysinit:/sbin/creatiadb </dev/console >/dev/sysmsg 2>&1</PRE>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> See the description of the inittab file later in this chapter for a complete description of the entries in the inittab file.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>Here's a quick rundown of what the system initialization (sysinit) processes do when you start the system:
<BR></P>
<UL>
<LI>ckroot—This reads the mount options for the root file system from the /etc/vfstab file. These options, including the file system type, are needed to make the root file system available (that is, to mount it). ckroot also checks the file system
(fsck command) if it determines that there are any problems in the file system. For example, if you turn off the system instead of doing a shutdown, the system sends you the message "Please wait while the system is examined" while it resolves any
inconsistencies it finds.
<BR>
<BR></LI>
<LI>setclk—This sets the UNIX system clock from the hardware clock.
<BR>
<BR></LI>
<LI>idmodreg—This registers the loadable kernel modules listed in the /etc/mod_register file.
<BR>
<BR></LI>
<LI>idmodload—This loads the loadable kernel modules listed in the /etc/loadmods file.
<BR>
<BR></LI>
<LI>autopush—This configures a list of modules to be automatically pushed on a Streams device when the device is opened. In this case, modules listed in the /etc/ap/chan.ap file are pushed on top of the console monitor device to provide line
discipline information.
<BR>
<BR></LI>
<LI>bcheckrc—This does several startup tasks, including setting your system name, mounting /proc (processes) and /dev/fd (floppy disk) devices, and checking and linking additional devices related to floppy disks.
<BR>
<BR></LI>
<LI>idrebuild—This checks whether the kernel has to be rebuilt, and if so runs the idbuild command to rebuild it. The kernel needs to be rebuilt after you add devices or change tunable parameters.
<BR>
<BR></LI>
<LI>creatiadb—This sets up security tables.
<BR>
<BR></LI></UL>
<P>Once system initialization functions are set up, init checks the initdefault entry in the inittab to determine the run level that the system is supposed to start up in. It finds the following initdefault line:
<BR></P>
<PRE>is:3:initdefault:</PRE>
<P>This tells init to start up UNIX in run level, or system state, 3. System state 3 is defined as the remote file-sharing state. With that information stored away, init proceeds to run all commands set in the /etc/inittab file that are designated as
belonging to run state 3. Here is a list:
<BR></P>
<PRE>r2:23:wait:/sbin/rc2 1> /dev/sysmsg 2>&1 </dev/console
r3:3:wait:/sbin/rc3 1> /dev/sysmsg 2>&1 </dev/console
li:23:wait:/usr/bin/ln /dev/systty /dev/syscon >/dev/null 2>&1\
[cc]sc:234:respawn:/usr/lib/saf/sac t 300
co:12345:respawn:/usr/lib/saf/ttymon g v p "Console Login: " \
[cc]d /dev/console l console
d2:23:wait:/sbin/dinit 1> /dev/sysmsg 2>&1 </dev/console
co:12345:once:/usr/bin/mapchan f /usr/lib/mapchan/88591.dk \
[cc]console</PRE>
<P>The r2 and r3 lines set the most processes in action. The r2 line runs the /etc/rc2 command, which in turn starts up all scripts contained in the /etc/rc2.d directory that begin with the letter S. These include the following:
<BR></P>
<PRE>S01MOUNTFSYS S02mse S18setuname S50merge
S75rpc S01tzsetclk S05RMTMPFILES S21perf
S55merge S02PRESERVE S11uname S27nuc
S69inet S15mkdtab S42els S73snmp</PRE>
<P>You can list these files to see what they do. On the whole, however, the scripts start networking and other addon features. For example, S27nuc starts NetWare connectivity, S69inet starts TCP/IP, and S50merge starts DOS merge features.
<BR></P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -