커피향이 나는 *NIX
커피닉스
시스템/네트웍/보안을 다루는 곳
*
HanIRC의 #coffeenix 방
[
장비 및 회선 후원
]
> Forum <
IT 일정
N
e
w
!
자동화 프로젝트
HOME
>
시스템 관리 / 서버운영
>
부팅, boot / LILO / GRUB
도움말
검색 :
사이트
WHOIS
웹서버 종류
grub에서 커널 패닉 대처하는 부팅 설정
작성일 : 2010/01/21 00:08
글쓴이 : 좋은진호 (
http://coffeenix.net/
)
조회수 : 17009
[
이전화면
/
수정
] 비밀번호 :
제 목 : grub에서 커널 패닉 대처하는 부팅 설정
작성자 : 좋은진호(truefeel,
http://coffeenix.net/
)
작성일 : 2010.1.20(수)
새로운 커널을 업그레이드 한 후, 리부팅시 커널 패닉(kernel panic)이 발생할 수도 있다. 콘솔에서 직접 부팅하는 것이라면 패닉시 이전 커널로 부팅하는 것은 쉽게할 수 있다. 그러나 원격에서 리부팅시 패닉이 발생했다면 더이상의 조치는 취하기 어렵다.
하지만 패닉이 발생할 때 안전하게 이전 커널로 부팅하도록 GRUB에서 설정할 수 있다. CentOS와 Ubuntu간에 GRUB 설정에 차이가 있어서, 2가지 방법으로 설명하겠다.
다음은 /boot/grub/grub.conf의 설정 예이다. default=0 으로 설정되어 있으므로 첫번째에 있는 2.6.18-old의 커널로 부팅된다. 새로 설치한 2.6.18-new로 안전하게 부팅하려면 어떻게 해야할까?
default=0
timeout=3
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-old)
root (hd0,0)
kernel /vmlinuz-2.6.18-old ro root=LABEL=/
initrd /initrd-2.6.18-old.img
title CentOS (2.6.18-new)
root (hd0,0)
kernel /vmlinuz-2.6.18-new ro root=LABEL=/
initrd /initrd-2.6.18-new.img
1. 방법 1 (CentOS, RHEL의 경우)
grub command 쉘에서 다음과 같이 결과가 나올 경우, 이 설정법을 이용하면 된다.
grub> help savedefault
savedefault: savedefault [--stage2=STAGE2_FILE] [--default=DEFAULT] [--once]
Save DEFAULT as the default boot entry in STAGE2_FILE. If
'--once' is specified, the default is reset after the next reboot.
grub.conf에서 panic=3 설정을 추가한다. 커널 패닉시 3초 뒤에 리부팅하라는 것이다.
... 생략 ...
kernel /vmlinuz-2.6.18-new ro root=LABEL=/
panic=3
이제 명령어 한줄이면 끝난다.
#
echo "savedefault --default=1 --once" | grub --batch
또는 grub command 쉘에서 savedefault 명령을 내린다.
#
grub
grub>
savedefault --default=1 --once
grub>
quit
--default=1 : 2번째 커널(위에서는 2.6.18-new)로 부팅하라는 뜻이다. 이 때 패닉이 발생하면 grub.conf에 설정된 default=0의 커널로 자동 리부팅을 하게 된다. 즉, 문제가 발생해도 이전버전으로 부팅되니 안전하다. 3번째 커널로 하고 싶다면 --default=2라고 하면 된다.
--once : 딱 한번만 2번째 커널로 부팅하라는 뜻이다. 다음 부팅때부터는 원래대로 grub.conf설정을 따른다.
새로운 커널로 정상 부팅이 되었다면 grub.conf에서 default= 설정 등을 변경해서, 부팅할 때마다 새커널로 부팅되도록 수정해주면 될 것이다.
2. 방법 2 (우분투(Ubuntu)의 경우)
grub command 쉘에서 다음과 같이 결과가 나올 경우, 이 설정법을 이용하면 된다. 이 때 grub-set-default 실행 파일이 /usr/sbin 등에 존재할 것이다.
grub> help savedefault
savedefault: savedefault [NUM | `fallback']
Save the current entry as the default boot entry if no argument
is specified. If a number is specified, this number is saved. If
`fallback' is used, next fallback entry is saved.
grub.conf 설정을 다음과 같이 바꾼다.
default saved
timeout=3
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-old)
root (hd0,0)
kernel /vmlinuz-2.6.18-old ro root=LABEL=/
initrd /initrd-2.6.18-old.img
savedefault
title CentOS (2.6.18-new)
root (hd0,0)
kernel /vmlinuz-2.6.18-new ro root=LABEL=/ panic=3
initrd /initrd-2.6.18-new.img
savedefault 0
default saved로 설정하면 grub은 /boot/grub/default 텍스트 파일에 설정한 커널 번호(entry)를 먼저 실행한다. 이 파일내에 1이라고 되어 있다면 2.6.18-new 커널로 먼저 부팅된다. 2.6.18-new 커널 부분에는 'savedefault 0'설정이 있다. 이는 2.6.18-new로 먼저 부팅을 하고, 다음 부팅할 때는 첫번째(savedefault 0 설정에 따른 것임)에 있는 2.6.18-old로 부팅하라는 것이다.
/boot/grub/default 파일은 직접적으로 수정하지 말고, grub-set-default 명령으로 변경하는 것을 권장하고 있다. 다음과 같이 실행해주면 된다.
#
grub-set-default 1
#
cat /boot/grub/default
1
#
#
#
#
#
#
#
#
#
#
# WARNING: If you want to edit this file directly, do not remove any line
# from this file, including this warning. Using `grub-set-default\' is
# strongly recommended.
3. 커널 3개 이상일 때 fallback 설정(방법 2, 우분투(Ubuntu)의 경우)
이 부분은 좀 더 깊이 이해하기 위한 부분으로 모르고 넘어가도 상관없다. 커널이 2개 보다 많을 경우 경우 fallback 설정으로 순차적으로 새로운 커널로 부팅되도록 할 수가 있다. 다음은 GRUB 매뉴얼에 나온 예제이다.
default saved # This is important!!!
timeout 10
fallback 1 2
# This is important!!!
title A
root (hd0,0)
kernel /kernel
savedefault fallback
# This is important!!!
title B
root (hd1,0)
kernel /kernel
savedefault fallback
# This is important!!!
title C
root (hd2,0)
kernel /kernel
savedefault
fallback 1 2 설정은 /boot/grub/default 에 설정된 커널 번호로 부팅을 먼저 하고, 그 다음에는 1번, 그 다음에는 2번 커널로 부팅하라는 뜻이다. 따라서 /boot/grub/default 에 0이 들어가 있다면 A -> B -> C 커널 순으로 순차적으로 부팅을 하게 된다.
만약 첫번째 있는 A커널로 정상 부팅이 되었고, 이제 매번 A커널로 부팅을 원한다면 rc.local에 'grub-set-default 0'을 넣어주면 된다. fallback 기능에 대해서는
http://star4u.org/blog/?p=88
에 자세히 설명되어 있다.
4. 참고자료
1) lilo에서 커널 패닉 대처법
- lilo 를 이용한 부팅 실패 대처.... (글 mindline, 2003.11 )
http://coffeenix.net/board_view.php?bd_code=137
2) grub의 savedefault --default=1 --once 명령으로 설정하는 방법
- grub single boot and kernel panic reboot
http://www.linux-noob.com/forums/index.php?/topic/2928-grub-single-boot-and-kernel-panic-reboot/
- grub-set-default
http://www.centos.org/modules/newbb/viewtopic.php?viewmode=flat&topic_id=3931&forum=27
- GRUB boots의 Fallbacks
http://fedora.redhatmagazine.com/magazine/024oct06/features/kickstart/?intcmp=bcm_edmsept_007
3) grub-set-default 명령으로 설정하는 방법
- GRUB 매뉴얼의 '4.3.1 Booting once-only'과 '4.3.2 Booting fallback systems'
http://www.gnu.org/software/grub/manual/grub.html#Booting-once_002donly
- GRUB의 fallback기능으로 안전하게 커널 업그레이드 하기
http://star4u.org/blog/?p=88
커피닉스 카페 최근 글
[06/16]
[질문]SAN 스위치 브로드케이드 dcx8510-4 장비관련입니다.
[04/22]
Re: 영화속에 컴퓨터 이야기 ~스워드피쉬(2001)
[10/20]
Cross Compiler 깔
[07/14]
SSL АО
[04/26]
Re: 도스화면 원격조종 여부
[04/25]
도스화면 원격조종 여부
[10/30]
Cshell에서 난수 설정
[10/23]
공항철도주식회사 SE 구인 件
[01/26]
Re: wget으로 다른서버에있는 디렉토리를 가져오려고합니다.
[01/25]
wget으로 다른서버에있는 디렉토리를 가져오려고합니다.
[01/11]
특정 안드로이드 WebView 버전에서 SSL 문제 (WebView 버그)
[08/01]
DNS forwarder (전달자) 서버를 통해서 쿼리하면 역방향을 받아오질 못합니다.
[05/16]
(주)후이즈 시스템엔지니어 (경력자) 모집
[02/15]
[AWS] Cloudfront edge 확인하기
[01/20]
Mobile Service/eCommerce 기업에서 Server / Java / PHP 개발자 구인
N
e
w
! 최근에 등록한 페이지
KiCad EDA Suite project (Free/Libre/Open-Source EDA Suite) (CAD)
오픈캐스케이드 캐드 (OpenCASCADE CAD)
QCad for Windows --- GNU GPL (Free Software)
The Hello World Collection
IPMI를 활용한 리눅스 서버관리
DNS 설정 검사
nagiosgraph 설치 방법
Slony-I 설치 방법 (postgresql replication tool)
Qmail기반의 Anti spam 시스템 구축하기
clusterssh
[ 함께하는 사이트 ]
운영진 :
좋은진호(truefeel)
, 야수(yasu), 범냉이, sCag
2003년 8월 4일~