본문 바로가기

리눅스/강의

[20. GRUB]

 GRUB (Grand Unified BootLoader)


설명

하드디스크 맨 앞 MBR(Master Boot Record)영역에 설치되는 부트매니저.

부팅 시에 커널 인자를 조졍하여 동적인 부팅을 지원한다.


리눅스 시스템 부팅 시에 'e' 버튼을 눌러 GRUB의 설정모드로 진입한다.

grub.conf에 등록된 부팅 목록의 모든 항목을 직접 편집할 수 있다.

여기서 메뉴를 편집한다고 해서 grub.conf 파일의 내용이 바뀌는 것이 아닌 현재 부팅 시에만 일시적으로 적용.


부팅 파티션 확인

[root@localhost module]# fdisk -l 


Disk /dev/sda: 21.5 GB, 21474836480 bytes

- 생략 -


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2089    16776192   83  Linux

/dev/sda2            2089        2350     2097152   83  Linux

/dev/sda3            2350        2611     2097152   82  Linux swap / Solaris


/dev/sda1 파티션이 부팅디스크인 것을 확인할 수 있다.


grub 환경 설정 파일
[root@localhost module]# vim /boot/grub/grub.conf 
# grub.conf generated by anaconda
- 생략 -
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.el6.i686)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-431.el6.i686 ro root=UUID=f87c927f-bf89-4183-99c3-2ea53d07a0d5 rd_NO_LUKS LANG=ko_KR.UTF-rd_NO_MD crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=ko rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.el6.i686.img


grub 재설치 및 복구


grub-install

- 부트 로더에 문제가 생겨 정상 부팅이 안될 경우 grub 부트매니저를 재설치 하는 명령어.


grub-install [option] 장치명

grub-install /dev/sda


/sbin/grub

- 수동으로 부트로더를 복구하는 명령어.

- /boot/grub/grub.conf 파일을 참조해서 부팅 파티션을 확인해야 된다.   


title CentOS (2.6.32-431.el6.i686)

root (hd0,0)
- 부팅 파티션은 (hd0,0)

grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83

(hd0,0) 파티션을 선택한다.
해당 파티션은 ext2fs 타입의 파티션이며 0x83 리눅스 시스템이다.

grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  27 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
grub> quit

setup 명령으로 (hd0) 하드디스크를 복구한다.



'리눅스 > 강의' 카테고리의 다른 글

[19. 하드디스크 간단정리]  (0) 2017.11.09
[18. 커널]  (0) 2017.11.09
[17. 모듈]  (0) 2017.11.09
[16. RPM]  (0) 2017.11.08
[15. 프로세스]  (0) 2017.11.05