cua? auto_irq skip_test autoconfig ## setserial 说穿了也没什么 , 这个指令可以让你对 serial port 做设定及回报 ## 的动作 , 像 IRQ , I/O port 啦等等的事情 . 一般的情况下 , 大家的电脑中 ## 通常只有 COM1-COM4 , 但假如你想增加新的 port , 那 setserial 就派上用 ## 场了 .
# These are the standard COM1 through COM4 devices # # If you have an internal modeme with a Rockwell Chipset, add a "skip_test" # to the /dev/cua3 line below. (It''''s not added by default because it will # screw up people with 8514 displays). # ${SETSERIAL} /dev/cua0 ${AUTO_IRQ} skip_test autoconfig ${SETSERIAL} /dev/cua1 ${AUTO_IRQ} skip_test autoconfig ${SETSERIAL} /dev/cua2 ${AUTO_IRQ} skip_test autoconfig ${SETSERIAL} /dev/cua3 ${AUTO_IRQ} autoconfig
# These are for the first AST Fourport board (base address 0x1A0) # ${SETSERIAL} /dev/cua4 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua5 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua6 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua7 ${AUTO_IRQ} autoconfig
# These are for the second AST Fourport board (base address 0x2A0) # ${SETSERIAL} /dev/cua8 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua9 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua10 ${AUTO_IRQ} autoconfig ${SETSERIAL} /dev/cua11 ${AUTO_IRQ} autoconfig ?
## 从这里以下 , 我省略了一大段 , 因为这一大段都是支持特殊的卡
# These are the 3rd and 4th ports on the Accent Async board. # #${SETSERIAL} /dev/cua12 ${AUTO_IRQ} autoconfig #${SETSERIAL} /dev/cua13 ${AUTO_IRQ} autoconfig # ?
. . . . . . . ?
## 好了 , 我们跳掉了一大段 , 直到这里 . 各位看到下面的注解了 . ## 假如你想用手动的方法指定 IRQ , I/O port , 及指定 chip 的型号 ## 那你可以拿掉下面对应那行前面的 ''''#'''' 并作适当的修改 , 比如说 ## 你用的是比较新的 16550 或 16550A , 而不是 16450 , 那你就可以 ## 在下面用手动的方法指定 . 实际上 , 用 autoconfig 及 autoirq ## 的选项就可以了 , 没有必要用手动的方式 . 除非侦测不到 .
############################################################### # # MANUAL CONFIGURATION # # If you want to do manual configuration of one or more of your # serial ports, uncomment and modify the relevant lines. # ###############################################################
# These are the standard COM1 through COM4 devices # #${SETSERIAL} /dev/cua0 uart 16450 port 0x3F8 irq 4 #${SETSERIAL} /dev/cua1 uart 16450 port 0x2F8 irq 3 #${SETSERIAL} /dev/cua2 uart 16450 port 0x3E8 irq 4 #${SETSERIAL} /dev/cua3 uart 16450 port 0x2E8 irq 3
. . . . . . . .
## Ok , 到此 , rc.S 及 rc.serial 已经结束 , 因为截稿时间的关系 , rc.M ## rc.inet1 , rc.inet2 , rc.font , rc.local 将在以后为各位介绍 .
echo "done." ${SETSERIAL} -bg ${PORTS}
echo '''' ====================== rc.serial is complete !!! ==================='''' ? ?
* 关于 Shell Programming 的书单 :
Title: The Unix C Shell Field Guide Authors: Gail Anderson and Paul Anderson Publisher: Prentice Hall Edition: 1986 ISBN: 0-13-937468-X
这本是 C-Shell 的 Bible , 想学 C-Shell 的人 , 可以去看这本书 . ?
Title: Unix Shell Programming Authors: Stephen Kochan and Patrick Wood Publisher: Hayden Edition: 1990 ISBN: 0-672-48448-X
喔 ! 这本书以 Bourne Shell 为主 , 内容深入浅出 , 读者很容易就可以了解 这本书的内容 , 进而掌握 Bourne Shell 的精髓 . 此外 , 这本书也有提到 Korn Shell , 大体上来说 , 是一本值得看的好书 . ?
*如何联系作者 :
E-Mail Address : jhhsu@csie.nctu.edu.tw u8217017@cc.nctu.edu.tw
Dormitory : 交通大学十舍 317R
.. ? ?
Linux 开机程序之研讨 CCCA 资工86 许景华
在上次的介绍中 , 我们已经看完了 rc.S 及 rc.serial 这两个 shell script . 现在 , 我们将把剩下的 shell script 再作一个介绍 . 首先还是看看全部的流程 : ?
init[1] rc.S begin rc.serial begin rc.serial end rc.S end <-- 上一次我们说明到这里 init[1] enter runlevel 5 rc.M begin rc.inet1 begin rc.inet1 end rc.inet2 begin rc.inet2 end rc.font begin rc.font end rc.local begin rc.local end rc.M end login ?
这次主要的部份可分为两项 : 因为 init 将会去读取 inittab , 所以 inittab 将被列为第一部份的重点 , 而第二部份就是 rc.M , rc.font , rc.local 这几个 shell script 的说明 . ( rc.inet1 , rc.inet2 这两个关于网络的 shell script 将在以后单独说明 ) 好了 , 我们先从 inittab 看起吧 ! 看看上面的流程 , 在第一行 : init[1] 也就是 init 这个 process 被启动之后 , 它会去读取 /etc/inittab 这个文件 以完成系统的启动 . 从这里 , 我们看到了 LINUX 的确融合了 SVR4 及 SunOS 的一些特性 , inittab 这个文件 , 在 SunOS 系统中是不存在的 , 但是它却是 SVR4 典型的文件 . init 这个 process 会依据 /etc/inittab 中所记载的内容 进入不同的 run-level 并启动不同的 process . 所以 inittab 的重要性 可见一斑 . 那什么叫 run-level 呢 ? 所谓 run-level 就是系统中定义了许多 不同的 level , 而系统会随著 level 的不同而去启动不同的资源 . 现在就让我们来看一下 /etc/inittab 中的内容 : 在 /etc/inittab 这个文件中 , 每一列是一个进入点 , 假如我们仔细观察每一列 的话 , 那我们就会很容易的发现 , /etc/inittab 的每一列可以被 " : " 这个 字符分成好几个栏位 . 这几个栏位的格式如下 :
id:runlevels:action:process
而它们代表的意义分别如下 :
id : 由两个独特的字符所组成的辨示符号 , 在比较新的 UNIX 系统中 , 已不 受只能有两个字符的限制 .
runlevels : 指出下面一个栏位中的 action 以及 下下个栏位中的 process 会在那些 runlevel 中被执行 . 这一栏的合法值有 0,1,2...6 s 以及 S . 而在正常的启动程序之后 , Superuser 可以使用 telinit 这个指令来改变系统的 runlevel . 又因为在 LINUX 中 , runlevel 的预设值是 5 ( 等一下就会看到 ) 所以 , 只有 那些每一列中 runlevel 那栏有 5 这个值的 , 后面的 process 才会被启动 . 所以 , 我们就可以想像的到 : " 由于系统的 runlevel 不同 , 所起动的 process 也不尽相同 , 所以系统 起动的资源在每个不同的 runlevel 就会有差异存在 .
action : 这个栏位有一点复杂 , 在这个栏位中记录着 init 在启动相对应的 process 时 , 对 process 所采取的动作 , 而合法的动作有下面几项:
initdefault : 指出系统在启动时 , 预设进入的 run-level 值 , 比如说 , 我们可以在 /etc/inittab 中找到下面这 一列 : id:3:initdefault: 很明显的 , 系统将在启动时 , 进入 runlevel 为 3 的模式 . 当然 , 你可以把 3 改成 4 试试看 , 如 果你改成了 4 , 那将会执行 /etc/rc.d/rc.4 , 也 就是 run xdm . xdm 在以后有机会的话 , 将为各 位介绍 ......
sysinit : 在系统起动时 , 这个 process 会被执行 . 而所有 process 前的 action 中有 boot 及 bootwait 的 process , 必 须等到这些 action 为 sysinit 的 process 执行完之后 它们才能够执行 .
wait : 在起动一个 process 之后 , 若要再起动另一个 process , 则 必需等到这个 process 结束之后才能继续 .
respawn : 代表这个 process 即使在结束之后 , 也会重新被启动 , 最典型的例子就是 getty ( 在 LINUX 中为 agetty ) . 看看下面的循环 :
-- getty --> login --> shell --> logout -- ^ |??????????????????????????????????????? | ? |<---------------------------------------|
即使在 getty 结束之后 , 它也会重新被启动 .
ctrlaltdel : 想必有人会以键盘上的 Ctrl , Alt , 及 Del 这三个 键来达到使系统 shutdown 的目的 , 现在我们果然在 /etc/inittab 中看到了这一列 :
ca::ctrlaltdel:/sbin/shutdown -t3 -rf now
所以说 , 当我们按下这三个键的时候 , init 会收到 SIGINT 这个 signal , 接着就执行 shutdown 的动作 不过 , 我们最好不要养成按 Ctrl-Alt-Del 来使系统 shutdown 的习惯 , 尤其在单用户多任务的操作系统 , 像 OS/2 , 甚至 Windows 95 , shutdown 几乎都是标准 的关机程序了 , 更何况是多用户多任务的 LINUX , 所以 , shutdown 这个指令是一定要熟悉的 .
除了上面的几个 action 之外 , 另外还有一些合法的 action , 但这 些 action 并不需要太注意 , 要用的时候再利用 man init 去查询就 可以了 .
process : 这一栏中可以是 shell script 或是可执行的程序 .
好了 , 当我们了解 /etc/inittab 中每一栏的意义之后 , 要看懂 /etc/inittab 就是一件轻松愉快的工作了 . 在 /etc/inittab 档中 , 我们可以看到下面这一段
c1:12345:respawn:/sbin/agetty 38400 tty1 c2:12345:respawn:/sbin/agetty 38400 tty2 c3:45:respawn:/sbin/agetty 38400 tty3 c4:45:respawn:/sbin/agetty 38400 tty4 c5:45:respawn:/sbin/agetty 38400 tty5 c6:456:respawn:/sbin/agetty 38400 tty6
简单来说 , 系统在起动之后会制造出六个虚拟的 console . 我想大家应该有试过 用 Ctrl-Alt + F1 - F6 可在这六个 console 之间切换 ; 若你使用 XWindows 时 想暂时回到 console 下时 , 可用 Ctrl-Alt + F1 - F6 这三个键来选择 , 若想 回到 XWindows 下时 , 只要以 Ctrl-Alt-F7 就可以回到 XWindows 下了 . 基本 上 , 对於 memory 比较少的人 , 可以不要开那么多的虚拟 console , 那么就可 以去掉上面的几列 . 还有 , 在前面我们也提过 , 可以把预设的 runlevel 从 5 改成 6 , 对於 beginner 来说 , 系统一启动完就直接进入 XWindows 也许是一个 不错的设定方法 ......
介绍完 /etc/inittab 之后 , 我们接着看 rc.M ! 由前面的流程当中 , 我们看到 rc.M 中又包含了四个 shell script , 其中 rc.inet1 及 rc.inet2 是有关于网络 的设定 ; rc.font 是作字体的设定 , 而 rc.local 中可以放一些想要起动的 daemon .
我们现在就来看看 rc.M , 依照往例 , 前面有两个 "#" 的为加上去的注释 . 只有一个 "#" 的为原来的注释 :
#!/bin/sh # # rc.M This file is executed by init(8) when the system is being # initialized for one of the "multi user" run levels (i.e. # levels 1 through 6). It usually does mounting of file # systems et al. # # Version: @(#)/etc/rc.d/rc.M 2.02 02/26/93 # # Author: Fred N. van Kempen, # Heavily modified by Patrick Volkerding #
## 显示进入多用户模式
echo "Going multiuser..." ?
## 下面一列的意思是 : 假如你在文字模式的 console 下 , 在15分钟内都没有动作 ## 的话 , 屏幕就会自动暗下来 , 简单的说 , 就是 screen saver 的功能 .
/bin/setterm -blank 15 ?
## 执行 crond 这个 daemon . 不用说 , crond 在系统中扮演了很重要的角色 , ## 它负责每过一段时间后 , 就去看看 /var/spool/cron/crontabs 中有那些 file ## 要运行 , 这些 file 往往有一个固定的时间 , 比如说 : 每个月的 1 号 , 每 ## 天凌晨等 ...... 我们可以用平常的编辑器编好一个文件 , 里面的格式如下 : ## ## 分 时 日 月 星期 命令 ## ## 举例来说 , 59 23 31 12 * /etc/wall happy_new_year ## 在每年的 12 月 31 号晚上 11 点 59 分 会对每个系统上的 user 送出 ## happy_new_year 中的内容 ## ## 接着我们可以利用 crontab <文件名> 这个指令来把此文件放到 ## /var/spool/cron/crontabs中. 我们可以看看 /var/spool/cron/crontab 下 ## 有一个 root 的文件 , 看看里面的内容 : ## ## 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/lib/atrun ## ## 所以各位看到了 , 在前两期提到的 at 命令是五分钟才被 run 一次的 ## ## 再举一个简单的例子好了 : 我们先用一般的文本编辑器造出一个名为 crontest ## 的档案 , 内容如下 : ## ## 5 * * * * ls -la ~/ >> ~/hehehaha ## ## 接着 , 我们键入下面的命令 : crontab crontest ## 此时 , 从内容得知 , 每五分钟 crond 就会执行 ls -la , 把你 home directory ## 的内容加入 hehehaha 这个文件中 . ## ## 当然啦 ! 这个例子简直是毫无意义可言 :) 但是 , 大家既然知道了基本原理 , ## 利用 crontab , at 这些指令 , 就可以简化一些系统管理的动作 , 同时在执行 ## 一些工作时 , 也会比较有弹性 .
/usr/sbin/crond -l10 >>/var/adm/cron 2>&1 ?
## 假如 /etc/HOSTNAME 不能读取的话 , 就把 darkst
上一页 [1] [2] [3] 下一页 没有相关教程
|