리눅스의 부팅과정

1. 컴퓨터에 전원이 들어오면 POST 과정에 의한 시스템 초기화
2. Boot Record나 하드인 경우 MBR(Master Boot Record)를 읽어들인다.
3. LILO(Linux Loader)가 실행된다. 만일, 디폴트인 리눅스가 로딩되기 전에 Ctrl,Shift,Alt 중 하나를 누르고 있으면, LILO는 부팅할 운영체제를 물어 본다.
4. Kernel이 메모리로 로딩되며, 만일 커널이 압축되었다면 압축을 해제한다.
5. 커널은 하드, 플로피, 네트웍 어댑터 등을 검사하며, 디바이스 드라이버를 설정한다.
6. 리눅스는 프로세서를 보호모드로 전환시키다. 화면상의 변화는 나타나지 않는다.
7. root 파일 시스템을 마운트 시킨다. root 파일 시스템은 'rdev' 나 LILO 에 의해 설정되어 있으며, 파일 시스템의 형태는 자동적으로 검출된다.
8. 커널은 /etc/init 을 백그라운드로 실행한다. 'init' 는 'inittab' 파일의 내용에 따라 실행된다.
9. init 는 /etc/rc 를 실행한다.
10. 'rc' 는 /etc/rc.local 이나 /etc/rc[0-9] 등을 실행시킨다.
11. 'init' 프로그램은 가상 콘솔을 위해 /etc/gettytabs 에 의해 설정된 직렬 라인으로 getty 를 실행한다.
12. ID 와 패스워드를 입력한다.
13. shell 이 작동하고 bash shell 이면 .bashrc 를, tcsh shell 이면 .profile 을 불러들인다.
14. 프롬프트가 표시된다.

위 부팅과정의 8번에서 있는 것처럼 리눅스는 처음 부팅을 하면서 init 프로세스가 /etc/inittab 이라는 파일을 불러들이게 되는데, 이 파일에는 부팅시 불러올 런레벨을 결정하는 부분이 있는데, 이 파일의 내용은 아래와 같다.


[root@hostname /etc]# vi /etc/inittab

#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS 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:
#이 부분이 부팅 시의 런레벨을 결정해 주는 부분이며, 5 이므로 부팅시 X윈도우로 시작한다는 의미

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE
#(Ctrl_Atl_Del 을 눌렸을 때 실행되는 명령 : shutdown 명령으로 재부팅함)
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left.  Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon

이와 같이 특정 런레벨로 실행이 된 후에 다른 런레벨로 바꾸고 싶은 경우 telinit 명령을 사용한다. 예로 런레벨 5로 부팅된 상태에서 런레벨 3으로 바꾸고자 한다면

[root@hostname /etc]# telinit 3


[root@hostname /etc]# telinit
Usage: telinit 0123456SsQqAaBbCcUu



*Run level 에 새로운 서비스 추가하기

특정 런레벨에 새로운 서비스를 추가하는 방법에는

1. 수동적으로 링크를 만들어 주는 방법
2. 런레벨 에디터를 사용하는 방법

우선 에디터에는 콘솔화면용 런레벨 에디터와 X용 런레벨 에디터가 있다.
콘솔용은 ntsysv 이며 아래와 같이 실행한다.

추가하고 싶은 데몬은 별표(*)로 체크해 주고, 선택된 데몬을 제거하고자 한다면 별표를 제거해 주면 된다.

X용 런레벨 에디터
 KDE 환경의 ksysv
 레드햇 리눅스의 기본 런레벨 에디터인 tksysv

수동으로 링크파일을 만들어서 편집하는 방법은 아래와 같다.
ex) 런레벨 5 에 데몬번호 86 번으로 gated 를 추가하는 경우

[root@hostname /etc]# cd /etc/rc.d/rc5.d

[root@hostname /etc]# ln -s ../init.d/gated S86gated
  (/etc/init.d 는 데몬들이 있는 디렉토리임.)

[root@hostname  /etc/rc.d/rc5.d]# ls -l S*
lrwxrwxrwx 1 root root 23 2011-04-30 16:46 S00microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx 1 root root 22 2011-04-30 16:45 S02lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx 1 root root 17 2012-06-26 16:53 S03sysstat -> ../init.d/sysstat
lrwxrwxrwx 1 root root 25 2011-04-30 16:46 S04readahead_early -> ../init.d/readahead_early
lrwxrwxrwx 1 root root 15 2011-04-30 16:49 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx 1 root root 19 2011-04-30 16:42 S08ip6tables -> ../init.d/ip6tables
lrwxrwxrwx 1 root root 18 2011-04-30 16:45 S08mcstrans -> ../init.d/mcstrans
lrwxrwxrwx 1 root root 14 2011-04-30 16:49 S09isdn -> ../init.d/isdn
lrwxrwxrwx 1 root root 17 2011-04-30 16:45 S10network -> ../init.d/network
lrwxrwxrwx 1 root root 16 2011-04-30 16:45 S11auditd -> ../init.d/auditd
lrwxrwxrwx 1 root root 21 2011-04-30 16:47 S12restorecond -> ../init.d/restorecond
lrwxrwxrwx 1 root root 16 2011-04-30 16:45 S12syslog -> ../init.d/syslog
lrwxrwxrwx 1 root root 18 2011-04-30 16:43 S13cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx 1 root root 20 2011-04-30 16:46 S13irqbalance -> ../init.d/irqbalance
lrwxrwxrwx 1 root root 17 2011-04-30 16:45 S13portmap -> ../init.d/portmap
lrwxrwxrwx 1 root root 17 2011-04-30 16:48 S14nfslock -> ../init.d/nfslock
lrwxrwxrwx 1 root root 19 2011-04-30 16:48 S18rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx 1 root root 17 2011-04-30 16:48 S19rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx 1 root root 20 2011-04-30 16:47 S22messagebus -> ../init.d/messagebus
lrwxrwxrwx 1 root root 19 2011-04-30 16:48 S25bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 15 2011-04-30 16:45 S25netfs -> ../init.d/netfs
lrwxrwxrwx 1 root root 15 2011-04-30 16:47 S25pcscd -> ../init.d/pcscd
lrwxrwxrwx 1 root root 15 2011-04-30 16:46 S26acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 14 2011-04-30 16:49 S26apmd -> ../init.d/apmd
lrwxrwxrwx 1 root root 19 2011-04-30 16:47 S26haldaemon -> ../init.d/haldaemon
lrwxrwxrwx 1 root root 14 2011-04-30 16:48 S26hidd -> ../init.d/hidd
lrwxrwxrwx 1 root root 16 2011-04-30 16:46 S28autofs -> ../init.d/autofs
lrwxrwxrwx 1 root root 14 2011-04-30 16:48 S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 2011-04-30 16:47 S56cups -> ../init.d/cups
lrwxrwxrwx 1 root root 20 2011-04-30 16:45 S56rawdevices -> ../init.d/rawdevices
lrwxrwxrwx 1 root root 16 2011-04-30 16:46 S56xinetd -> ../init.d/xinetd
lrwxrwxrwx 1 root root 16 2011-05-04 02:42 S60vsftpd -> ../init.d/vsftpd
lrwxrwxrwx 1 root root 18 2011-05-04 02:12 S80sendmail -> ../init.d/sendmail
lrwxrwxrwx 1 root root 13 2011-04-30 16:42 S85gpm -> ../init.d/gpm
lrwxrwxrwx 1 root root 15 2011-04-30 16:45 S90crond -> ../init.d/crond
lrwxrwxrwx 1 root root 13 2011-04-30 16:48 S90xfs -> ../init.d/xfs
lrwxrwxrwx 1 root root 17 2011-04-30 16:44 S95anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 13 2011-04-30 16:44 S95atd -> ../init.d/atd
lrwxrwxrwx 1 root root 25 2011-04-30 16:46 S96readahead_later -> ../init.d/readahead_later
lrwxrwxrwx 1 root root 22 2011-04-30 16:48 S97yum-updatesd -> ../init.d/yum-updatesd
lrwxrwxrwx 1 root root 22 2011-04-30 16:47 S98avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root 19 2011-04-30 16:49 S99firstboot -> ../init.d/firstboot
lrwxrwxrwx 1 root root 11 2011-04-30 16:45 S99local -> ../rc.local
lrwxrwxrwx 1 root root 16 2011-04-30 16:46 S99smartd -> ../init.d/smartd


댓글 없음:

댓글 쓰기

깔끔 테마. Powered by Blogger.