史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 網路疑難應用技術研討區
忘記密碼?
論壇說明 標記討論區已讀

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2004-08-06, 06:58 PM   #1
貝斯特 帥哥
長老會員
 
貝斯特 的頭像
榮譽勳章
UID - 90669
在線等級: 級別:1 | 在線時長:11小時 | 升級還需:1小時
註冊日期: 2003-08-06
住址: The Gates of Hell
文章: 1758
現金: 15064 金幣
資產: 5185909 金幣
預設 Linux 系統設定

在這□我們先瞭解整個linux啓動的流程,首先系統核心由lilo或loadlin程式讀入記憶體,在解壓縮後分別載入各周邊的驅動程式。必須注意的是,有些驅動程式采自動偵測(auto-probe)的方式,判斷硬體的設定情形,如果在核心載入的過程中,發現有偵測錯誤的情況,必須把確實的硬體設定參數由lilo、loadlin在載入時傳入核心。

 在核心完成載入後,linux會執行init程式,init程式會根據/etc/inittab的設定完成系統啓動的程式。由於在啓動系統時,我們可能希望進入正常的運作模式提供對外服務,或進入系統維護模式暫時停止對外服務,所以除了特殊事件處理外,每一個專案都指定run level,通知init這次啓動本專案是否要執行。接著init監督所有由它啓動的程式及停電等系統事件,直到shutdown爲止。例如
getty負責使用者簽入,而一般getty的action爲respawn,表示使用者離線後,init會再重新啓動getty等待下一個使用者。


#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Version: @(#)inittab 2.04 17/05/93 MvS
#
# Author: Miquel van Smoorenburg,
#
# 格式:
#
# Default runlevel.
#
id:5:initdefault:

#
# System initialization (runs when system boots).
#
si:S:sysinit:/etc/rc.d/rc.S

#
# Script to run when going single user.
#
su:S:wait:/etc/rc.d/rc.K

#
# Script to run when going multi user.
#
rc:123456:wait:/etc/rc.d/rc.M

#
# What to do at the "Three Finger Salute".
#
ca::ctrlaltdel:/sbin/shutdown -t3 -rf now

#
# What to do when power fails (shutdown to single user).
#
pfwerfail:/sbin/shutdown -f +5 "THE POWER IS FAILING"

#
# If power is back before shutdown, cancel the running shutdown.
#
pg:0123456owerokwait:/sbin/shutdown -c "THE POWER IS BACK"

#
# If power comes back in single user mode, return to multi user mode.
#
ps:Sowerokwait:/sbin/init 5

#
# The getties in multi user mode on consoles an serial lines.
#
# NOTE NOTE NOTE adjust this to your getty or you will not be
# able to login !!
#
# Note: for 'agetty' you use linespeed, line.
# for 'getty_ps' you use line, linespeed and also use 'gettydefs'
#
c1:12345:respawn:/sbin/getty tty1 38400 console
c2:12345:respawn:/sbin/getty tty2 38400 console
c3:45:respawn:/sbin/getty tty3 38400 console
c4:45:respawn:/sbin/getty tty4 38400 vt100
#c5:45:respawn:/sbin/agetty 38400 tty5
#c6:456:respawn:/sbin/agetty 38400 tty6

#
# Serial lines
#
#s1:45:respawn:/sbin/agetty 19200 ttyS0
#s2:45:respawn:/sbin/agetty 19200 ttyS1

#
# Dialup lines
#
#d1:45:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0
#d2:45:respawn:/sbin/mgetty -D -n 5 ttyS1 38400 vt100

#
# Runlevel 6 used to be for an X-window only system, until we discovered
# that it throws init into a loop that keeps your load avg at least 1 all
# the time. Thus, there is now one getty opened on tty6. Hopefully no one
# will notice. ;^)
# It might not be bad to have one text console anyway, in case something
# happens to X.
#
x1:6:wait:/etc/rc.d/rc.6

# End of /etc/inittab

* 上表除中文說明外,節錄自slackware 2.1.0之/etc/inittab


 從inittab可以看到,id:5:initdefault表示在載入核心時若沒有指定runlevel,則以5作爲內定值。rc.S的action屬於sysinit,會在系統啓動後首先被執行。接著id爲rc那一項,指定在runlevel爲1~6時執行,屬性爲wait表示init會執行rc.M且等待它執行完畢。這兩個script和系統環境較密切,我們下面會作較詳細的介紹。另外id爲ca那一項定義了按ctrl-alt-del時,執行shutdown並立即reboot。至於id爲c1~c6、s1~s2、d1~d2者,指定在那一個runlevel下,啓動那些終端機,它們的action屬於respawn表示這些程式在結束後,init會再次重新執行它們,直到shutdown爲止。如果須要更詳細的
資料,可用man init得到更詳細的說明。


#!/bin/sh
#
# /etc/rc.d/rc.S
#
# These commands are executed at boot time by init(8).
# User customization should go in /etc/rc.local.

PATH=/sbin:/usr/sbin:/bin:/usr/bin

#
# 啓動swap系統:
#
# 1. mount所有定義在/etc/fstab內的swap partition
#
#/sbin/swapon -av
#
# 2. 啓動swap file而不是swap partition
#
/sbin/swapon /.Swapfile

#
# Start update.
#
/sbin/update &

#
# Test to see if the root partition is read-only, like it ought to be.
#
# 測試檔案系統的完整性
#
READWRITE=no
if echo -n >> "Testing filesystem status"; then
rm -f "Testing filesystem status"
READWRITE=yes
fi

#
# Check the integrity of all filesystems
#
if [ ! $READWRITE = yes ]; then
/sbin/fsck -A -a
# If there was a failure, drop into single-user mode.
if [ $? -gt 1 ] ; then
echo
echo
echo "**************************************"
echo "fsck returned error code - REBOOT NOW!"
echo "**************************************"
echo
echo
/bin/login
fi
#
# Remount the root filesystem in read-write mode
#
echo "Remounting root device with read-write enabled."
/sbin/mount -w -n -o remount /
if [ $? -gt 0 ] ; then
echo
echo "Attempt to remount root device as read-write failed! This is going to"
echo "cause serious problems... "
echo
echo "If you're using the UMSDOS filesystem, you **MUST** mount the root
partition"
echo "read-write! You can make sure the root filesystem is getting mounted
"
echo "read-write with the 'rw' flag to Loadlin:"
echo
echo "loadlin vmlinuz root=/dev/hda1 rw (replace /dev/hda1 with your root
device)"
echo
echo "Normal bootdisks can be made to mount a system read-write with the
rdev command:"
echo
echo "rdev -R /dev/fd0 0"
echo
echo "You can also get into your system by using a bootkernel disk with a
command"
echo "like this on the LILO prompt line: (change the root partition name
as needed)"
echo
echo "LILO: mount root=/dev/hda1 rw"
echo
echo "Please press ENTER to continue, then reboot and use one of the above
methods to"
echo -n "get into your machine and start looking for the problem. "
read junk;
fi
else
echo "Testing filesystem status: read-write filesystem"
if [ -d /DOS/linux/etc -a -d /DOS/linux/dev ]; then # no warn for UMSDOS
cat << EOF

*** ERROR: Root partition has already been mounted read-write. Cannot check!

For filesystem checking to work properly, your system must initially mount
the root partition as read only. Please modify your kernel with 'rdev' so that
it does this. If you're booting with LILO, add a line:

read-only

to the Linux section in your /etc/lilo.conf and type 'lilo' to reinstall it.

If you boot from a kernel on a floppy disk, put it in the drive and type:
rdev -R /dev/fd0 1

If you boot from a bootkernel disk, or with Loadlin, you can add the 'ro'
flag.

This will fix the problem *AND* eliminate this annoying message. :^)

EOF
echo -n "Press ENTER to continue. "
read junk;
fi
fi

#
# remove /etc/mtab* so that mount will create it with a root entry
#
/bin/rm -f /etc/mtab* /etc/nologin /var/adm/utmp

#
# Looks like we have to create this.
#
cat /dev/null >> /var/adm/utmp

#
# mount file systems in fstab (and create an entry for /)
# but not NFS because TCP/IP is not yet configured
#
# mount所有定義在/etc/fstab內的檔案系統,但nfs除外。因爲
# tcp/ip環境的設定是在後面rc.M內完成。
#

/sbin/mount -avt nonfs

#
# Configure the system clock.
# This can be changed if your system keeps GMT.
#
if [ -x /sbin/clock ]; then
/sbin/clock -s
fi

#
# Setup the /etc/issue and /etc/motd to reflect the current kernel level:
# THESE WIPE ANY CHANGES YOU MAKE TO /ETC/ISSUE AND /ETC/MOTD WITH EACH
# BOOT. COMMENT THEM OUT IF YOU WANT TO MAKE CUSTOM VERSIONS.
#
# 這一段程式會在每次重新開機時,將/etc/motd、/etc/issue這兩
# 個檔寫入Slackware的內定值。
#
#echo > /etc/issue
#echo Welcome to Linux `/bin/uname -a | /bin/cut -d\ -f3`. >> /etc/issue
#echo >> /etc/issue
#echo "`/bin/uname -a | /bin/cut -d\ -f1,3`. (POSIX)." > /etc/motd

#
# Run serial port setup script:
# (CAREFUL! This can make some systems hang if the rc.serial script isn't
# set up correctly. If this happens, you may have to edit the file from a
# boot disk)
#
# 執行設定serial port的程式
#
/bin/sh /etc/rc.d/rc.serial

# end of /etc/rc.d/rc.S

* 上表除中文說明外,節錄自slackware 2.1.0之/etc/inittab


在內定的情形下,我們會以runlevel 5進入系統,因此接著執行
/etc/rc.d/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

#
#
# Tell the viewers what's going to happen...
#
echo "Going multiuser..."

#
# Screen blanks after 15 minutes idle time.
#
# 設定在15分鐘內沒有任何動作時,自動關閉螢幕顯示
#
/bin/setterm -blank 15

#
# Start crond (Dillon's crond):
# If you want cron to actually log activity to /var/adm/cron, then change
# -l10 to -l8 to increase the logging level.
#
# 每個user都可用crontab -e建立一張表格,指定在特定的時間
 # 執行某些程式,這是由下面的程式來監控
#
/usr/sbin/crond -l10 >>/var/adm/cron 2>&1

#
# If there's no /etc/HOSTNAME, fall back on this default:
#
# 如果沒有設定主機名稱,下面這段程式會填入內定值
#
if [ ! -r /etc/HOSTNAME ]; then
echo "darkstar.frop.org" > /etc/HOSTNAME
fi

#
# Initialize the NET subsystem.
#
# 設定網路系統,後面會再作較詳細的介紹
#
if [ -x /etc/rc.d/rc.inet1 ];
then
/bin/hostname `cat /etc/HOSTNAME | cut -f1 -d .`
/bin/sh /etc/rc.d/rc.inet1
/bin/sh /etc/rc.d/rc.inet2
else
/sbin/hostname_notcp `cat /etc/HOSTNAME | cut -f1 -d .`
/usr/sbin/syslogd
/usr/sbin/klogd
/usr/sbin/lpd
fi

#
# Remove stale locks (must be done after mount -a!)
#
/bin/rm -f /var/spool/locks/* /var/spool/uucp/LCK..* /tmp/.X*lock 1>
/dev/null 2> /dev/null

#
# Remove stale hunt sockets so the game can start.
#
if [ -r /tmp/hunt -o -r /tmp/hunt.stats ]; then
echo "Removing your stale hunt sockets from /tmp..."
/bin/rm -f /tmp/hunt*
fi

#
# Update all the shared library links automatically
#
/sbin/ldconfig

#
# Start the sendmail daemon:
#
# 啓動信件收發處理程式,每15分鐘處理一次待送信件
#
if [ -x /usr/sbin/sendmail ]; then
echo "Starting mail daemon ( sendmail -bd -q 15m )..."
/usr/sbin/sendmail -bd -q 15m
fi

#
# Load a custom screen font if the user has an rc.font script.
#
# 載入自定的螢幕字型
#
if [ -r /etc/rc.d/rc.font ]; then
/etc/rc.d/rc.font
fi

#
# Start the local setup procedure.
#
/etc/rc.d/rc.local

# end of /etc/rc.d/rc.M

* 上表除中文說明外,節錄自slackware 2.1.0之/etc/inittab


 其他系統檔案

 1. /etc/issue

   這個檔案的內容會在系統顯示login:提示之前出現在使用者的virtual console或終端機上。如果是telnet時,系統是顯示/etc/issue.net。

 2. /etc/motd

    即message of today,會在使用者進入shell之前顯示,通常是放系統的最新通知事項。

 3. /etc/mtools

slackware有一組指令包括mdir,mcopy等,可直接讀取DOS的磁片、硬碟內檔案,這檔內必須定義軟碟機、硬碟機參數。

#
# Parameters for the /usr/bin/mtools utilities
#

A /dev/fd0 12 0 0 0 # Generic autodetect
B /dev/fd1 12 0 0 0 # Generic autodetect

# end of /etc/mtools
__________________

給自己看也給所有需要這些話鼓勵的人看!

認真不一定會得到美好的結果,但是不認真就一定沒有

想要有什麼結果,就秉持你的雙手
放手去做
總比什麼都沒付出最後失敗了才嘆氣來的好吧
沒努力的人.沒有資格說放棄
努力過的人.更要有勇氣繼續努力下去
貝斯特 目前離線  
送花文章: 1, 收花文章: 38 篇, 收花: 123 次
回覆時引用此帖
發文 回覆


主題工具
顯示模式

發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用

相似的主題
主題 主題作者 討論區 回覆 最後發表
linux - 完全用Linux工作 psac 作業系統操作技術文件 10 2006-10-02 04:41 AM
100個最佳Linux站點 psac 網路疑難應用技術研討區 6 2005-03-03 08:31 AM
100個最佳Linux站點 飛鳥 網路疑難應用技術研討區 7 2004-07-03 11:43 PM
理解 GNU/Linux psac 網路疑難應用技術研討區 13 2004-04-16 12:17 PM
100個最佳Linux站  aacced 網路疑難應用技術研討區 0 2003-11-14 06:49 PM


所有時間均為台北時間。現在的時間是 09:47 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1