Linux_부팅 과정

lil·2023년 2월 11일
0

LinuxServerAdmin

목록 보기
5/8

부팅 과정

* F/W 단계
* 부트로드 단계
* 커널 단계
* init 단계

(1) F/W 단계(EX: BIOS, UEFI)

- POST(Power On Self Test) 자기 스스로 점검
- 부팅매체(Floppy -> DISK -> CD -> NET)

(2) 부트로드 단계(EX: LILO, GRUB(커널(운영체제의 심장)실행하는놈))

- boot/grub2/grub.cfg(/etc/grub.d/*, /etc/defalut/grub)
- Kernel(/boot/vmlinuz-4.18.0-448.el8.x86_64)
- Initramfs(initramfs-4.18.0-448.el8.x86_64.img)

(3) 커널 단계

- kernel -> systemd -> 서비스 기동

(4) systemd 단계

multi-user.target:		runlevel 3
graphical.target: 		runlevel 5

(시스템 제어)
# systemctl enable|disable sshd
# systemctl start|stop|restart|status sshd

# systemctl list-unit-files //설치된 모든 유닛 파일의 상태

(장애 처리)
# systemctl --failed
# systemctl list-jobs

(패키지 의존성)
# systemctl list-dependencies sshd					//앞단
# systemctl list-dependencies sshd --reverse		//뒷단

(mask/unmask)
# systemctl mask|unmask sendmail

(5) 장애처리 방법(EX: (WIN)안전모드 )

(ㄱ) rd.break

# reboot
GRUB menu  -> 적당한 커널 -> e -> 커널라인(linux시작하는놈) 마지막에서<END><SPACE> ->
rd.break -> <CTRL + x >

# mount –o remount,rw /sysroot
# chroot /sysroot
# passwd root
(SELINUX 켜져있는 경우) touch /.autorelabel
# exit ;exit

(ㄴ) init=/bin/bash

# reboot
GRUB menu  -> 적당한 커널 -> e -> 커널라인(linux시작하는놈) 마지막에서<END><SPACE> ->
init=/bin/bash -> <CTRL + x >

# mount –o remount,rw /sysroot
# passwd root
(SELINUX 켜져있는 경우) touch /.autorelabel
# reboot

(ㄷ) systemd.unit=emergency.target

# reboot
GRUB menu  -> 적당한 커널 -> e -> 커널라인(linux시작하는놈) 마지막에서<END><SPACE> ->
systemd.unit=emergency.target -> <CTRL + x >

# mount –o remount,rw /
    장애처리 
		(ex: vi /etc/fstab)
		(systemctl daemon-reload)
# exit

(ㄹ) systemd.unit=rescue.target

# reboot
GRUB menu  -> 적당한 커널 -> e -> 커널라인(linux시작하는놈) 마지막에서<END><SPACE> ->
systemd.unit=rescue.target -> <CTRL + x >

    장애처리
		(ex: vi /etc/fstab)
		(systemctl daemon-reload)
# exit

[실습] (systemd Phase) /etc/rc.local(/etc/rc.d/rc.local) 파일을 사용한 부팅시 실행 명령 등록

# vi /etc/rc.d/rc.local
# chmod +x /etc/rc.d/rc.local    [실행권한주기]

[실습] (grub Phase) GRUB2 암호 설정하기

# grub2-setpassword
=> /boot/grub2/grub.cfg 파일이 만들어진다.

[실습] (systemd Phase)새로운 서비스 등록

# vi /usr/lib/systemd/system/new.service
# systemctl daemon-reload 
# systemctl enable new.service
# systemctl start new.service
# systemctl status new.service

[실습] (grub Phase) GRUB가 깨진 경우
CD 부팅

# df -h
# chroot /mnt/sysroot
	# lsblk --fs -p				//어디있는지 찾아야돼
	# fdisk -l /dev/sda
# grub2-install /dev/sda   없다면(# grub2-mkconfig -o /boot/grub2/grub.cfg)
# exit ; exit

[실습] (systemd Phase) etc/fstab 파일 잘못된 설정의 예
root 암호 입력

# mount -o remount,re /
# vi /etc/fstab
-> 적당한 설정

# systemctl daemon-reload
# exit

[실습] (Kernel Phase) Kernel Panic

# yum check-update | grep kernel
# yum update
# reboot
-> 커널 패닉 발생

# yum remove kernel -버전
# yum update kernel
# reboot

0개의 댓글