📄 00000002.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: NextStep (NeXT~计划中...), 信区: Linux <BR>标 题: Linux sysload <BR>发信站: BBS 水木清华站 (Wed Sep 17 09:07:45 1997) <BR> <BR>linux系统的设定 <BR> <BR> <BR> 在这□我们先了解整个linux启动的流程,首先系统核心由lilo <BR>或loadlin程式读入记忆体,在解压缩後分别载入各周边的驱动程 <BR>式。必须注意的是,有些驱动程式采自动侦测(auto-probe)的方 <BR>式,判断硬体的设定情形,如果在核心载入的过程中,发现有侦测 <BR>错误的情况,必须把确实的硬体设定参数由lilo、loadlin在载入 <BR>时传入核心。 <BR> <BR> 在核心完成载入後,linux会执行init程式,init程式会根据 <BR>/etc/inittab的设定完成系统启动的程序。由於在启动系统时,我 <BR>们可能希望进入正常的运作模式提供对外服务,或进入系统维护模 <BR>式暂时停止对外服务,所以除了特殊事件处理外,每一个项目都指 <BR>定run level,通知init这次启动本项目是否要执行。接著init监督 <BR>所有由它启动的程式及停电等系统事件,直到shutdown为止。例如 <BR>getty负责使用者签入,而一般getty的action为respawn,表示使用 <BR>者离线後,init会再重新启动getty等待下一个使用者。 <BR> <BR> <BR># <BR># inittab This file describes how the INIT process should set up <BR># the system in a certain run-level. <BR># <BR># Version: @(#)inittab 2.04 17/05/93 MvS <BR># <BR># Author: Miquel van Smoorenburg, <<A HREF="mailto:miquels@drinkel.nl.mugnet.org>">miquels@drinkel.nl.mugnet.org></A> <BR># <BR># 格式: <id> <runlevel> <action> <BR># <BR># Default runlevel. <BR># <BR>id:5:initdefault: <BR> <BR># <BR># System initialization (runs when system boots). <BR># <BR>si:S:sysinit:/etc/rc.d/rc.S <BR> <BR># <BR># Script to run when going single user. <BR># <BR>su:S:wait:/etc/rc.d/rc.K <BR> <BR># <BR># Script to run when going multi user. <BR># <BR>rc:123456:wait:/etc/rc.d/rc.M <BR> <BR># <BR># What to do at the "Three Finger Salute". <BR># <BR>ca::ctrlaltdel:/sbin/shutdown -t3 -rf now <BR> <BR># <BR># What to do when power fails (shutdown to single user). <BR># <BR>pf::powerfail:/sbin/shutdown -f +5 "THE POWER IS FAILING" <BR> <BR># <BR># If power is back before shutdown, cancel the running shutdown. <BR># <BR>pg:0123456:powerokwait:/sbin/shutdown -c "THE POWER IS BACK" <BR> <BR># <BR># If power comes back in single user mode, return to multi user mode. <BR># <BR>ps:S:powerokwait:/sbin/init 5 <BR> <BR># <BR># The getties in multi user mode on consoles an serial lines. <BR># <BR># NOTE NOTE NOTE adjust this to your getty or you will not be <BR># able to login !! <BR># <BR># Note: for 'agetty' you use linespeed, line. <BR># for 'getty_ps' you use line, linespeed and also use 'gettydefs' <BR># <BR>c1:12345:respawn:/sbin/getty tty1 38400 console <BR>c2:12345:respawn:/sbin/getty tty2 38400 console <BR>c3:45:respawn:/sbin/getty tty3 38400 console <BR>c4:45:respawn:/sbin/getty tty4 38400 vt100 <BR>#c5:45:respawn:/sbin/agetty 38400 tty5 <BR>#c6:456:respawn:/sbin/agetty 38400 tty6 <BR> <BR># <BR># Serial lines <BR># <BR>#s1:45:respawn:/sbin/agetty 19200 ttyS0 <BR>#s2:45:respawn:/sbin/agetty 19200 ttyS1 <BR> <BR># <BR># Dialup lines <BR># <BR>#d1:45:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 <BR>#d2:45:respawn:/sbin/mgetty -D -n 5 ttyS1 38400 vt100 <BR> <BR># <BR># Runlevel 6 used to be for an X-window only system, until we discovered <BR># that it throws init into a loop that keeps your load avg at least 1 all <BR># the time. Thus, there is now one getty opened on tty6. Hopefully no one <BR># will notice. ;^) <BR># It might not be bad to have one text console anyway, in case something <BR># happens to X. <BR># <BR>x1:6:wait:/etc/rc.d/rc.6 <BR> <BR># End of /etc/inittab <BR> <BR>* 上表除中文说明外,节录自slackware 2.1.0之/etc/inittab <BR> <BR> <BR> 从inittab可以看到,id:5:initdefault表示在载入核心时若没有 <BR>指定runlevel,则以5作为内定值。rc.S的action属於sysinit,会 <BR>在系统启动後首先被执行。接著id为rc那一项,指定在runlevel为 <BR>1~6时执行,属性为wait表示init会执行rc.M且等待它执行完毕。这 <BR>两个script和系统环境较密切,我们下面会作较详细的介绍。另外 <BR>id为ca那一项定义了按ctrl-alt-del时,执行shutdown并立即reboot <BR>。至於id为c1~c6、s1~s2、d1~d2者,指定在那一个runlevel下,启 <BR>动那些终端机,它们的action属於respawn表示这些程式在结束後, <BR>init会再次重新执行它们,直到shutdown为止。如果须要更详细的 <BR>资料,可用man init得到更详细的说明。 <BR> <BR> <BR>#!/bin/sh <BR># <BR># /etc/rc.d/rc.S <BR># <BR># These commands are executed at boot time by init(8). <BR># User customization should go in /etc/rc.local. <BR> <BR>PATH=/sbin:/usr/sbin:/bin:/usr/bin <BR> <BR># <BR># 启动swap系统: <BR># <BR># 1. mount所有定义在/etc/fstab内的swap partition <BR># <BR>#/sbin/swapon -av <BR># <BR># 2. 启动swap file而不是swap partition <BR># <BR>/sbin/swapon /.Swapfile <BR> <BR># <BR># Start update. <BR># <BR>/sbin/update & <BR> <BR># <BR># Test to see if the root partition is read-only, like it ought to be. <BR># <BR># 测试档案系统的完整性 <BR># <BR>READWRITE=no <BR>if echo -n >> "Testing filesystem status"; then <BR> rm -f "Testing filesystem status" <BR> READWRITE=yes <BR>fi <BR> <BR># <BR># Check the integrity of all filesystems <BR># <BR>if [ ! $READWRITE = yes ]; then <BR> /sbin/fsck -A -a <BR> # If there was a failure, drop into single-user mode. <BR> if [ $? -gt 1 ] ; then <BR> echo <BR> echo <BR> echo "**************************************" <BR> echo "fsck returned error code - REBOOT NOW!" <BR> echo "**************************************" <BR> echo <BR> echo <BR> /bin/login <BR> fi <BR> # <BR> # Remount the root filesystem in read-write mode <BR> # <BR> echo "Remounting root device with read-write enabled." <BR> /sbin/mount -w -n -o remount / <BR> if [ $? -gt 0 ] ; then <BR> echo <BR> echo "Attempt to remount root device as read-write failed! This is going to" <BR> echo "cause serious problems... " <BR> echo <BR> echo "If you're using the UMSDOS filesystem, you **MUST** mount the root <BR>partition" <BR> echo "read-write! You can make sure the root filesystem is getting mounted <BR>" <BR> echo "read-write with the 'rw' flag to Loadlin:" <BR> echo <BR> echo "loadlin vmlinuz root=/dev/hda1 rw (replace /dev/hda1 with your root <BR>device)" <BR> echo <BR> echo "Normal bootdisks can be made to mount a system read-write with the <BR>rdev command:" <BR> echo <BR> echo "rdev -R /dev/fd0 0" <BR> echo <BR> echo "You can also get into your system by using a bootkernel disk with a <BR>command" <BR> echo "like this on the LILO prompt line: (change the root partition name <BR>as needed)" <BR> echo <BR> echo "LILO: mount root=/dev/hda1 rw" <BR> echo <BR> echo "Please press ENTER to continue, then reboot and use one of the above <BR>methods to" <BR> echo -n "get into your machine and start looking for the problem. " <BR> read junk; <BR> fi <BR>else <BR> echo "Testing filesystem status: read-write filesystem" <BR> if [ -d /DOS/linux/etc -a -d /DOS/linux/dev ]; then # no warn for UMSDOS <BR> cat << EOF <BR> <BR>*** ERROR: Root partition has already been mounted read-write. Cannot check! <BR> <BR>For filesystem checking to work properly, your system must initially mount <BR>the root partition as read only. Please modify your kernel with 'rdev' so that <BR>it does this. If you're booting with LILO, add a line: <BR> <BR> read-only <BR> <BR>to the Linux section in your /etc/lilo.conf and type 'lilo' to reinstall it. <BR> <BR>If you boot from a kernel on a floppy disk, put it in the drive and type: <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -