RHEL5, CENTOS5, Kernel2.6.x 대 커널 컴파일

발췌 : http://linuxstudy.pe.kr/bbs/board.php?bo_table=pds&wr_id=116
CentOS 54, 커널컴파일,
00 CentOS는 Fedora, RedHat 의 친구사이라, 같을줄 알았는데,
조금은 달랐다.
00 먼저 CentOS용 커널컴파일도구를 다운받는다.
# yum install gcc
# yum install ncurses-devel
# yum install rpm-build
# yum install bison
# yum install depmod
# yum install mkinitrd
현재 센토스54는 커널이 xen을 적용한것이고,
xen을 적용한 최신버젼인 2.6.18 이다.
00 커널소스를 다운받고, 압축을 푼다.
# cd /usr/src
/usr/src/ # wget http://www.kernel.org/pub/linux/kernel/v2.6/testing/linux-2.6.32-rc5.tar…
/usr/src/ # tar xvjf linux-2.6.32-rc5.tar.bz2
/usr/src/ # ln -s linux-2.6.32-rc5 linux
00 메뉴구성및 청소,
cd /usr/src/linux
/usr/src/linux/ # make clean
/usr/src/linux/ # make mrproper
/usr/src/linux/ # make menuconfig
00 컴파일실행
/usr/src/linux/ # make rpm
00 커널생성확인작업,
에러없이 잘됐다면,
/usr/src/redhat/SRPMS/ 에는
kernel-2.6.32rc5-1.src.rpm 이 생기고,
그리고, 자신의 CPU종류에 따라서, 각기다른폴더안에 만들어지는데,
뭐,, 그렇다고, 전혀 다른폴더는 아니고,
/usr/src/redhat/RMPS/ 이 안에 다양한 폴더가 있는데,
그것들이 모두 CPU종류별로 구분돼있는것이다.
지금 사용중인 나의 CPU는 32비트용 이므로,
컴파일작업한 커널이
/usr/src/redhat/RPMS/i386 안에 만들어진다.
다른타입의 CPU라면 옆에 폴더에 만들어질것이다.
만들어진 커널이미지의 이름은,
kernel-2.6.32rc5-1.i386.rpm 으로 만들어진다.
00 커널설치작업
이젠 그리로 들어가서,
# cd /usr/src/redhat/RPMS/i386
바로 여기서 커널설치명령을 내린다.
# rpm -ivh –nodeps kernel-2.6.32rc5-1.i386.rpm
여기서 –nodeps 는 의존성에러방지용이다.
00 이젠 ramdisk를 수동으로 만들어야한다.
이게없으면 부팅이 안되기 때문이다.
# cd /boot
boot/ # mkinitrd initrd-2.6.32-rc5.img 2.6.32-rc5
00 grub.conf에다 새로운커널을 적용하는 문구를 적어줘야한다.
cd /boot/grub
/boot/grub/ # vi grub.conf
/boot/grub/ # vi menu.lst
00 재부팅
# reboot
00 재부팅후에 uname -r 해줘서,
새로운 커널명이 나오면 커널작업이 성공한것이다.
수동명령(Fedora식 명령)
yum install rpm-build 를 안하고하니,
에러유발로 이렇게도 해봤다.
그러나, 이것 적용 안할 예정
make all
make modules_install
make install
그리고,
vi /etc/modprobe.conf 로 수정해줘야한다는데,
글쎄 그건 자동으로 되는것같은데,
커널을 완전히 설치한후에,
depmod 와 mkinitrd 는 /sbin/안에 있으므로,
1. 모듈들의 의존성을 만들어주기위해서,
/boot/ # /sbin/depmod 2.6.32-rc5
2./boot/ # /sbin/mkinitrd -v initrd-2.6.32-rc5.img 2.6.32-rc5
이렇게하다 에러 나오면, No module dm-mem-cache found for kernel 2.6.32-rc5, aborting.
/boot/ # mkinitrd –without-dmraid -v initrd-2.6.32-rc5.img 2.6.32-rc5
3./boot/grub/grub.conf 를 수정해야한다.
밑에 내용을 참고할것,
1 title CentOS (2.6.32-rc5)
2 root (hd0,0)
3 kernel /vmlinuz-2.6.32-rc5 ro root=/dev/VolGroup00/LogVol00
4 initrd /initrd-2.6.32-rc5.img
The file /boot/grub/grub.conf will be like this:
01 # grub.conf generated by anaconda
02 #
03 # Note that you do not have to rerun grub after making changes to this file
04 # NOTICE: You have a /boot partition. This means that
05 # all kernel and initrd paths are relative to /boot/, eg.
06 # root (hd0,0)
07 # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
08 # initrd /initrd-version.img
09 #boot=/dev/sda
10 default=0
11 timeout=5
12 splashimage=(hd0,0)/grub/splash.xpm.gz
13 hiddenmenu
14 title CentOS (2.6.18-128.el5)
15 root (hd0,0)
16 kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/VolGroup00/LogVol00
17 initrd /initrd-2.6.18-128.el5.img
18 title CentOS (2.6.32-rc5)
19 root (hd0,0)
20 kernel /vmlinuz-2.6.32-rc5 ro root=/dev/VolGroup00/LogVol00
21 initrd /initrd-2.6.32-rc5.img
http://www.fogonacaixadagua.com.br/2009/09/how-to-compile-a-new-kernel-i…
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[root@localhost boot]# ls -al
합계 46813
drwxr-xr-x 4 root root 1024 10월 25 13:22 .
drwxr-xr-x 23 root root 4096 10월 25 11:22 ..
-rw-r–r– 1 root root 161 9월 3 18:16 .vmlinuz-2.6.18-164.el5xen.hmac
-rw-r–r– 1 root root 952318 9월 3 18:16 System.map-2.6.18-164.el5xen
-rw-r–r– 1 root root 1293759 10월 25 12:54 System.map-2.6.32-rc5
-rw-r–r– 1 root root 68285 9월 3 18:16 config-2.6.18-164.el5xen
-rw-r–r– 1 root root 82676 10월 25 12:54 config-2.6.32-rc5
drwxr-xr-x 2 root root 1024 10월 25 13:38 grub
-rw——- 1 root root 3234265 10월 24 18:22 initrd-2.6.18-164.el5xen.img
drwx—— 2 root root 12288 10월 24 18:11 lost+found
-rw-r–r– 1 root root 80032 3월 13 2009 message
-rw-r–r– 1 root root 107385 9월 3 18:16 symvers-2.6.18-164.el5xen.gz
-rwxr-xr-x 1 root root 36121495 10월 25 12:42 vmlinux-2.6.32-rc5.bz2
-rw-r–r– 1 root root 2225793 9월 3 18:16 vmlinuz-2.6.18-164.el5xen
-rw-r–r– 1 root root 2332320 10월 25 12:54 vmlinuz-2.6.32-rc5
-rwxr-xr-x 1 root root 817160 9월 3 19:06 xen-syms-2.6.18-164.el5
-rw-r–r– 1 root root 375877 9월 3 16:27 xen.gz-2.6.18-164.el5
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[root@localhost grub]# ls -al
합계 263
drwxr-xr-x 2 root root 1024 10월 25 13:38 .
drwxr-xr-x 4 root root 1024 10월 25 13:22 ..
-rw-r–r– 1 root root 63 10월 24 18:33 device.map
-rw-r–r– 1 root root 7584 10월 24 18:33 e2fs_stage1_5
-rw-r–r– 1 root root 7456 10월 24 18:33 fat_stage1_5
-rw-r–r– 1 root root 6720 10월 24 18:33 ffs_stage1_5
-rw——- 1 root root 855 10월 25 13:34 grub.conf
-rw——- 1 root root 646 10월 25 13:30 grub2.conf
-rw-r–r– 1 root root 6720 10월 24 18:33 iso9660_stage1_5
-rw-r–r– 1 root root 8192 10월 24 18:33 jfs_stage1_5
lrwxrwxrwx 1 root root 11 10월 24 18:33 menu.lst -> ./grub.conf
-rw-r–r– 1 root root 6880 10월 24 18:33 minix_stage1_5
-rw-r–r– 1 root root 9248 10월 24 18:33 reiserfs_stage1_5
-rw-r–r– 1 root root 55808 3월 13 2009 splash.xpm.gz
-rw-r–r– 1 root root 512 10월 24 18:33 stage1
-rw-r–r– 1 root root 104988 10월 24 18:33 stage2
-rw-r–r– 1 root root 7072 10월 24 18:33 ufs2_stage1_5
-rw-r–r– 1 root root 6272 10월 24 18:33 vstafs_stage1_5
-rw-r–r– 1 root root 8904 10월 24 18:33 xfs_stage1_5
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
/boot/grub/grub.conf
# 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/hdc
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
##title CentOS (2.6.32-rc5)
## root (hd0,0)
## kernel /xen.gz-2.6.32-rc5
## module /vmlinuz-2.6.32-rc5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
## module /initrd-2.6.32-rc5.img
title CentOS (2.6.18-164.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-164.el5
module /vmlinuz-2.6.18-164.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-164.el5xen.img
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
이건 분위기바꿔서, /boot/안의 화일과
/boot/grub/grub.conf 의 내용중에서,
xen어쩌구,, 하는 화일 때문인데,
그것을 해결하려면, menuconfig를
다시 해야겠네,,
rpm이 웬수다.
http://derwynd.com/2008/11/10/fedoraredhat-kernel-rpm-with-xen-reiserfs/
https://lists.sdsc.edu/pipermail/npaci-rocks-discussion/2008-September/0…
Fedora/Redhat Kernel RPM with Xen & reiserfs
Posted On November 10, 2008
Filed under Uncategorized
Comments Dropped leave a response
Download the src rpm
(eg. kernel-2.6.18-92.el5.src.rpm)
$ rpm -ivh kernel-2.6.18-92.el5.src.rpm
$ cd /usr/src/redhat/SPECS/
$ rpmbuild -bb kernel-2.6.spec
This will build
kernel-2.6.18-92.el5.x86_64.rpm kernel-devel-2.6.18-92.el5.x86_64.rpm
kernel-debug-2.6.18-92.el5.x86_64.rpm kernel-headers-2.6.18-92.el5.x86_64.rpm
kernel-debug-debuginfo-2.6.18-92.el5.x86_64.rpm kernel-xen-2.6.18-92.el5.x86_64.rpm
kernel-debug-devel-2.6.18-92.el5.x86_64.rpm kernel-xen-debuginfo-2.6.18-92.el5.x86_64.rpm
kernel-debuginfo-2.6.18-92.el5.x86_64.rpm kernel-xen-devel-2.6.18-92.el5.x86_64.rpm
kernel-debuginfo-common-2.6.18-92.el5.x86_64.rpm
Install the following rpm
$ kernel-xen-2.6.18-53.el5 xen-libs
Check the grub.conf file the xen lines will be added
#boot=/dev/sda
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-53.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-53.el5
module /vmlinuz-2.6.18-53.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-53.el5xen.img
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-53.el5.img
If you list the files in /boot/ are added
vmlinuz-2.6.18-53.el5
initrd-2.6.18-53.el5.img
xen.gz-2.6.18-53.el5
xen-syms-2.6.18-53.el5
Now to build the kernel from the BUILD dir
$ cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.x86_64/
$ make menuconfig
——————————————————————-
Processor type and features —>
[*] Enable Xen compatible kernel
File systems —>
Reiserfs support
[ ] Enable reiserfs debug mode
[ ] Stats in /proc/fs/reiserfs
[*] ReiserFS extended attributes
[ ] ReiserFS POSIX Access Control Lists
[ ] ReiserFS Security Labels
XEN —>
[*] Privileged Guest (domain 0)
<*> Backend driver support
Block-device backend driver
Block-device tap backend driver
Network-device backend driver
[ ] Pipelined transmitter (DANGEROUS)
Network-device loopback driver
PCI-device backend driver
PCI Backend Mode (Virtual PCI) —>
[ ] PCI Backend Debugging
< > TPM-device backend driver
Block-device frontend driver
Network-device frontend driver
<*> Framebuffer-device frontend driver
<*> Keyboard-device frontend driver
[*] Scrub memory before freeing it to Xen
[ ] Disable serial port drivers
<*> Export Xen attributes in sysfs
Xen version compatibility (3.0.2 and later) —>
——————————————————————-
Build the kernel (if you have not changed the Makefile the subversion is EXTRAVERSION = -92.el5debug)
This will create vmlinuz-2.6.18-92.el5debug
$ mkinitrd /boot/initrd-2.6.18-92.el5debug.img 2.6.18-92.el5debug
(For the initrd img)
Add lines to grub.conf
——————————————————————
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-53.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-53.el5
module /vmlinuz-2.6.18-53.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-53.el5xen.img
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title Red Hat Enterprise Linux Server (2.6.18-53.el5Debxen)
root (hd0,0)
kernel /xen.gz-2.6.18-53.el5
module /vmlinuz-2.6.18-92.el5debug ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-92.el5debug.img
——————————————————————
Reboot
xen.gz-2.6.32-rc5
xen.gz-2.6.18-164.el5
grub.conf 와의 관계규명.
xen홈피주소::
http://www.xen.org/
xen details 1::
http://wiki.xensource.com/xenwiki/Korean
xen details 2 centos5::
http://www.howtoforge.com/centos_5.0_xen
xen kernel details::
http://wiki.xensource.com/xenwiki/Kernel.org_Linux_on_Xen
http://wiki.xensource.com/xenwiki/XenDom0Kernels
http://article.gmane.org/gmane.comp.emulators.xen.user/40892
이런저런 xen에 관한 문서를 보면서, ㅤㅎㅡㄾ어보니,
xen은 커널등을 암호화, 가상화화하는 방법으로 개발된것이고,
물론 커널만이 아니라, 다양한것들을 망라하고 있었다.
그런데 내가 목적으로 했던 2.6.32-rc5 같은 최신버젼에는
적용할수가 현재 없고, xen 개발자들이 연구중에 있는것같다.
여기 센토스54에 있는 2.6.18 버젼이 아직은 xen 을 적용한
최신버젼이고, 나는 여기서, 커널 업을 잠깐 보류해야할것같다.

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

1 Response

  1. 서진우 말해보세요:

    2.0.x~2.4.x 때 까지는 밥먹고 하는것이 커널컴파일이였는데, 근 몇년간 안하다 다시 할려니, 막막하군..애공..너무 편리해진 패키지관리 방식에 길드려진거 같네요..ㅠ.ㅠ

페이스북/트위트/구글 계정으로 댓글 가능합니다.