歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> 更多Linux

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).   #   pf::powerfail:/sbin/shutdown -f +5 "THE POWER IS FAILING"      #   # If power is back before shutdown, cancel the running shutdown.   #   pg:0123456:powerokwait:/sbin/shutdown -c "THE POWER IS BACK"      #   # If power comes back in single user mode, return to multi user mode.   #   ps:S:powerokwait:/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       如有任何建議或更正,歡迎email到[email protected]      




 



Copyright © Linux教程網 All Rights Reserved