next up previous contents
Next: daemon 與服務 (service) Up: 開機流程與系統服務 Previous: 開機流程與系統服務   Contents

開機流程

  1. 第一支程式 init 及設定檔 /etc/inittab 與 runlevel
    [root@dywOffice ~]# vi /etc/inittab
    # inittab is only used by upstart for the default runlevel.
    # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
    # System initialization is started by /etc/init/rcS.conf
    # Individual runlevels are started by /etc/init/rc.conf
    # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
    # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
    # with configuration in /etc/sysconfig/init.
    # For information on how to write upstart event handlers, or how
    # upstart works, see init(5), init(8), and initctl(8).
    
    # Default runlevel. The runlevels used by Mandrakelinux are:
    #   0 - halt (Do NOT set initdefault to this)
    #   1 - Single user mode
    #   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
    #   3 - Full multiuser mode
    #   4 - unused
    #   5 - X11
    #   6 - reboot (Do NOT set initdefault to this)
    #
    id:3:initdefault:
    
  2. 各開機層級啟動設定
    [root@deyu ~]# cat /etc/init/rc.conf 
    # rc - System V runlevel compatibility
    # This task runs the old sysv-rc runlevel scripts.  It
    # is usually started by the telinit compatibility wrapper.
    
    start on runlevel [0123456]
    stop on runlevel [!$RUNLEVEL]
    task
    export RUNLEVEL
    console output
    exec /etc/rc.d/rc $RUNLEVEL
    
  3. run level 3 的啟動目錄放在 /etc/rc.d/rc3.d 目錄當中:
    [root@deyu ~]# ll /etc/rc.d/rc3.d/
    total 0
    lrwxrwxrwx. 1 root root 20 Dec 11 14:01 K01certmonger -> ../init.d/certmonger
    lrwxrwxrwx. 1 root root 16 Dec 11 14:04 K01smartd -> ../init.d/smartd
    lrwxrwxrwx. 1 root root 17 Dec 11 14:01 K02oddjobd -> ../init.d/oddjobd
    lrwxrwxrwx. 1 root root 16 Dec 11 14:05 K10psacct -> ../init.d/psacct
    lrwxrwxrwx. 1 root root 19 Dec 11 14:01 K10saslauthd -> ../init.d/saslauthd
    ...........................
    lrwxrwxrwx. 1 root root 15 Dec 11 14:01 K86cgred -> ../init.d/cgred
    lrwxrwxrwx. 1 root root 21 Dec 11 14:01 K87restorecond -> ../init.d/restorecond
    lrwxrwxrwx. 1 root root 15 Dec 11 14:01 K89rdisc -> ../init.d/rdisc
    lrwxrwxrwx. 1 root root 23 Dec 11 14:05 S00microcode_ctl -> ../init.d/microcode_ctl
    lrwxrwxrwx. 1 root root 17 Dec 11 14:04 S01sysstat -> ../init.d/sysstat
    lrwxrwxrwx. 1 root root 22 Dec 11 14:01 S02lvm2-monitor -> ../init.d/lvm2-monitor
    lrwxrwxrwx. 1 root root 18 Dec 11 14:04 S05cgconfig -> ../init.d/cgconfig
    lrwxrwxrwx. 1 root root 16 Dec 11 14:01 S07iscsid -> ../init.d/iscsid
    .................
    lrwxrwxrwx. 1 root root 19 Dec 11 14:02 S99firstboot -> ../init.d/firstboot
    lrwxrwxrwx. 1 root root 11 Dec 11 14:01 S99local -> ../rc.local
    
    ## Snn:start nn:啟動順序
    ## Knn:stop  nn:關閉順序
    ## S99local 自訂開機執行程式可以放/etc/rc.d/rc.local,系統於開機最後啟動。
    
  4. 載入終端機
    [root@deyu ~]# vi /etc/init/tty.conf
    # tty - getty
    # This service maintains a getty on the sepcified device.
    
    stop on runlevel [016]
    respawn
    instance $TTY
    exec /sbin/mingetty $TTY
    
    #Mandriva 2010 直接在/etc/inittab中載入
    # Run gettys in standard runlevels
    2:2345:respawn:/sbin/mingetty tty2
    3:2345:respawn:/sbin/mingetty tty3
    4:2345:respawn:/sbin/mingetty tty4
    5:2345:respawn:/sbin/mingetty tty5
    
  5. 服務的相關設定檔 /etc/sysconfig:
    [root@deyu ~]# ls /etc/sysconfig/
    atd              grub              libvirtd         rsyslog
    auditd           httpd             libvirt-guests   samba
    authconfig       i18n              modules          sandbox
    autofs           init              named            saslauthd
    cbq              ip6tables         netconsole       selinux
    cgconfig         ip6tables-config  network          smartmontools
    cgred.conf       ip6tables.old     networking       snmpd
    clock            iptables          network-scripts  snmptrapd
    console          iptables-config   nfs              sysstat
    cpuspeed         iptables.old      nspluginwrapper  sysstat.ioconf
    crond            irqbalance        ntpd             system-config-firewall
    dhcpd            kdump             ntpdate          system-config-firewall.old
    dhcpd6           kernel            prelink          system-config-users
    dhcrelay         keyboard          raid-check       udev
    ebtables-config  ksm               readahead        wpa_supplicant
    firstboot        ldap              readonly-root    xinetd
    
    1. clock:設定 Linux 主機的時區。
    2. i18n:設定語系。
    3. network:設定主機名稱及GATEWAY 。
    4. network-scripts/:網路卡設定。



2015-04-13