2010년 12월 21일 화요일

[CentOS] Kernel 컴파일

<커널 컴파일 하기>

- Dell Server

- OS : CentOS 5.5 x64

- Kernel : 2.6.18 -> 2.6.36

 

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:54:40 EST 2010 i686 i686 i386 GNU/Linux

 

1. 커널 컴파일 전에 gcc, ncurses-devel 설치 및 package update

[root@localhost ~]# yum install -y gcc ncurses-devel

[root@localhost ~]# yum update

2. 최신 커널 다운로드(http://www.kernel.org/pub/linux/kernel/v2.6/)

[root@localhost ~]# cd /usr/src

[root@localhost ~]# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.tar.gz

[root@localhost ~]# tar xvfz linux-2.6.36.tar.gz

[root@localhost ~]# ln -s linux-2.6.36 linux

 

3. 커널 컴파일 설정

현재 사용하고 있는 커널 설정으로 컴파일 하기 위해 .config 설정 파일을 복사해서 진행

[root@localhost ~]# cd /usr/src/linux

[root@localhost linux]# make mrproper
[root@localhost linux]# make clean
[root@localhost linux]# cp /boot/config-`uname -r` ./.config
[root@localhost linux]# make menuconfig

  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf arch/x86/Kconfig

 

Load and Alternaate Configuration File -> .config 입력 후 OK 버튼

 

 

General sertup 선택 -> enable deprecated sysfs features to support old userspace tools (NEW) 에서 "y" 키로 선택

                             -> Local Version 선택 후 커널 뒤에 붙을 release 이름 입력(-default를 붙혔다면 2.6.36-default로 생성 됨)

 

설정이 끝났으면 .config 저장 후 Exit 로 종료

 

 

4. 커널 빌드와 설치 진행

[root@localhost linux]# make all

  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig arch/x86/Kconfig
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/genksyms/genksyms.o
  SHIPPED scripts/genksyms/lex.c
  SHIPPED scripts/genksyms/parse.h
  SHIPPED scripts/genksyms/keywords.c
/

/

/

CC [M]  drivers/parport/parport_pc.o
ld: final link failed: No space left on device
make[2]: *** [drivers/parport/parport_pc.o] Error 1
make[1]: *** [drivers/parport] Error 2
make: *** [drivers] Error 2

 

>>에러 발생하여 make menuconfig 실행하여 Device Drivers로 들어가 Parallel port support 에 "N"키로 <N> exclude 시키고 저장 후 빌드 시작

 

 

에러 다 복구 했으면...

 

[root@localhost linux]# make clean; make all

 

>> 커널 컴파일 및 설치 계속 진행

[root@localhost linux]# make modules_install

[root@localhost linux]# make install

sh /usr/src/linux-2.6.36/arch/x86/boot/install.sh 2.6.36-default arch/x86/boot/bzImage \
                System.map "/boot"

 

[root@localhost linux]#  cat /boot/grub/menu.lst
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0

timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.36-default)
        root (hd0,0)
        kernel /vmlinuz-2.6.36-default ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.36-default.img
title CentOS (2.6.27.54-default)
        root (hd0,0)
        kernel /vmlinuz-2.6.27.54-default ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.27.54-default.img
title CentOS (2.6.18-194.26.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.26.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-194.26.1.el5.img
title CentOS (2.6.18-194.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-194.el5.img


새로운 커널을 사용하기 위해 reboot

 

새로운 커널로 부팅 후 커널 버전 확인

[root@localhost ~]# uname -a

Linux localhost.localdomain 2.6.36-default #1 SMP Tue Dec 28 01:27:12 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

댓글 없음:

댓글 쓰기