우분투 9.04 (Jaunty Jackalope) 커널 컴파일하기
-. 원문: http://blog.avirtualhome.com/2009/04/29/how-to-compile-a-kernel-for-ubuntu-jaunty/
-. 내용은 최대한 원문을 유지하려고 하였으며, 몇가지 개인적으로 필요하다고 생각되는 내용을 추가하여 포함시켰습니다.
-. 컴파일 환경: VirtualBox 3.04 + Ubuntu 9.04 + Core2 Duo 3.2G + 896MB RAM
-. 컴파일 할 커널 버전: 2.6.28-15-51
- 준비
sudo su -
apt-get update
apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile
apt-get build-dep linux
apt-get install git-core libncurses5 libncurses5-dev
apt-get install initramfs-tools coreutils module-init-tools wireless-crda
커널 소스를 다운 받고 컴파일 작업을 할 디렉토리를 원하는곳에 만듭니다.
여기서는 /d1/packaging/kernel/jaunty 이 디렉토리로 정했네요..
- 커널 소스 받기
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-jaunty.git source
소스를 다 받으면 source 디렉토리에 저장됩니다.
- 새 브랜치 만들기
처음에는 branch가 master로 되있습니다. 이 브랜치는 유지하면서 앞으로 수정 작업을 할 브랜치를 새로 만들겁니다.
우선 최신 버전을 확인합니다.
cat debian.master/changelog|more
다음과 같은 내용을 확인 할 수 있습니다.
UNRELEASED라고 적힌 버전 아래에 있는 버전을 컴파일 할 겁니다.
여기서는 2.6.28-15.51이 되겠네요. 버전은 이것과 다를 수 있습니다.
이 명령을 실행하면 core2라는 branch가 생성됩니다.
이제 작업 브랜치가 *core2로 설정된것을 확인 할 수 있습니다.
- config 파일 만들기
cat debian.master/config/i386/config.generic >> .config
컴파일 설정을 변경합니다. 설정 변경 안하고 그냥 하려면 그냥 "Exit"를 선택하여 빠져나옵니다. (종료시 save 여부를 물어본다면 "yes"를 선택하세요)
만들어진 config 파일을 백업합니다.
git 트리를 정리합니다.
git clean -xdf
- 컴파일 준비
기본으로 들어있는 generic flavour를 보존하기 위해, 이것을 복사하여 새 flavour (여기서는core2)를 만듭니다.
지금 컴파일 하려고 하는 버전인 2.6.28-15.51의 이전 버전인 2.6.28-15.50이라는 디렉토리가 있는것을 확인합니다.
디렉토리명은 버전 마다 다를 수 있으니 본인의 환경에 맞게 수정하면됩니다.
cp debian.master/abi/2.6.28-15.50/i386/generic.modules debian.master/abi/2.6.28-15.50/i386/core2.modules
cp ../config.core2 debian.master/config/i386/
파일 몇개를 수정해야합니다.
거의 마지막 부분에 있는...
이 라인을 찾아 이렇게 수정...
이 부분을 찾아서...
이렇게 수정...
그 외....
파일을 열어서...
Package: linux-image-PKGVER-ABINUM-FLAVOUR
Architecture: ARCH
Section: base
Priority: optional
Pre-Depends: dpkg (>= 1.10.24)
Provides: linux-image, linux-image-2.6, fuse-module, =PROVIDES=
Depends: initramfs-tools (>= 0.36ubuntu6), coreutils | fileutils (>= 4.0), module-init-tools (>= 3.3-pre11-4ubuntu3), wireless-crda
Conflicts: hotplug (<< 0.0.20040105-1)
Recommends: BOOTLOADER
Suggests: fdutils, SRCPKGNAME-doc-PKGVER | SRCPKGNAME-source-PKGVER
Description: Linux kernel image for version PKGVER on DESC
This package contains the Linux kernel image for version PKGVER on
DESC.
.
Also includes the corresponding System.map file, the modules built by the
packager, and scripts that try to ensure that the system is not left in an
unbootable state after an update.
.
Supports SUPPORTED processors.
.
TARGET
.
You likely do not want to install this package directly. Instead, install
the linux-FLAVOUR meta-package, which will ensure that upgrades work
correctly, and that supporting packages are also installed.
Package: linux-headers-PKGVER-ABINUM-FLAVOUR
Architecture: ARCH
Section: devel
Priority: optional
Depends: coreutils | fileutils (>= 4.0), SRCPKGNAME-headers-PKGVER-ABINUM, ${shlibs:Depends}
Provides: SRCPKGNAME-headers, SRCPKGNAME-headers-2.6
Description: Linux kernel headers for version PKGVER on DESC
This package provides kernel header files for version PKGVER on
DESC.
.
This is for sites that want the latest kernel headers. Please read
/usr/share/doc/SRCPKGNAME-headers-PKGVER-ABINUM/debian.README.gz for details.
Package: linux-image-debug-PKGVER-ABINUM-FLAVOUR
Architecture: ARCH
Section: devel
Priority: optional
Provides: linux-debug
Description: Linux kernel debug image for version PKGVER on DESC
This package provides a kernel debug image for version PKGVER on
DESC.
.
This is for sites that wish to debug the kernel.
.
The kernel image contained in this package is NOT meant to boot from. It
is uncompressed, and unstripped. This package also includes the
unstripped modules.
위 세가지 Package (linux-image..., linux-headers..., linux-image-debug...)에 대한 내용을 모두 복사해서...
이 파일의 마지막 부분에 추가하여 붙여 넣고 다음과 같이 수정합니다. (반드시 각 Package 문단 사이에 공백 한 줄을 넣어 띄어야 합니다.)
파일안에 나타나는 모든 부분에 대해 변경해야 합니다. 빼먹으면 컴파일하다 멈추니까 정확히 수정하세용.
ARCH => i386
BOOTLOADER => grub
=PROVIDES= => 삭제
DESC, SUPPORTED, TARGET => 패키지 설명하는 부분인데 수정하지 않아도 상관없습니다.
PKGVER = > 2.6.28
ABINUM => 15 # 컴파일 할 버전인 2.6.28-11에서 11에 해당하는 번호
SRCPKGNAME => linux
debian 폴더에 심볼릭 링크를 생성합니다. (현재 디렉토리가 /d1/packaging/kernel/jaunty/source 인 상태에서 진행)
ln -sf ../debian.master/control.stub.in debian/control
ln -sf ../debian.master/control.stub.in debian/control.stub
지금까지 수정한 내용을 git 저장소에 올립니다.
git commit -a -m "Core2 modifications"
-m 뒤에는 적당한 코멘트 문자열을 적어주면 됩니다.
- 이제 컴파일을 합시다!
CONCURRENYCY_LEVEL을 cpu의 코어 개수로 설정하여 컴파일을 좀 빠르게 해봅시다. 듀얼 코어인 경우 2로 적으면 됩니다.
- 설치
커널이 제대로 컴파일 되었으면 현재 디렉토리인 source의 상위 디렉토리에 deb 파일이 생성 됩니다.
이제 이 파일들을 설치합니다. 역시 이번에도 파일명은 본인의 버전에 맞는걸루....
원문에서는 deb 파일이 세개 생성된거 같은데 제가 했을 땐 linux-image~.deb랑 linux-headers~i386.deb 두개만 생겼습니다. 그냥 있는거 다 설치하면 되겠습니다.
dpkg -i linux-headers-2.6.28-15-core2_2.6.28-15.51_i386.deb
설치가 정상적으로 완료 되었다면 /boot 디렉토리에 다음과 같은 파일들이 생성됩니다.
config-2.6.28-15-core2
abi-2.6.28-15-core2
System.map-2.6.28-15-core2
initrd.img-2.6.28-15-core2
vmcoreinfo-2.6.28-15-core2
패키지 설치시 grub의 내용를 변경하게 되는데, 혹시 제대로 변경되지 않았다면 직접 수정합니다.
uuid afc6f9fa-3333-449b-8f02-e7f517cacf21
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=afc6f9fa-3333-449b-8f02-e7f517cacf21 ro find_preseed=/preseed.cfg automatic-ubiquity noprompt crashkernel=384M-2G:64M@16M,2G-:128M@16M
initrd /boot/initrd.img-2.6.28-15-generic
위와 같이 menu.lst 파일의 마지막 부분에 보면 기존 커널 버전의 메뉴 옵션이 있는데 그대로 복사한 다음에 색이 칠해진 부분만 지금 컴파일하여 설치한 파일 이름으로 수정합니다.
이제 재부팅을 하고 부팅 메뉴에서 새로 추가한 커널 버전을 선택해여 해당 버전으로 부팅합니다.
2.6.28-11-core2
새로 컴파일한 커널로 바뀌었습니다!
'Workspace > Linux' 카테고리의 다른 글
| [cscope] cscope with crontab (0) | 2011/01/05 |
|---|---|
| [Linux] Ubuntu 9.04 - Jaunty Kernel Compile (0) | 2009/09/02 |
| [Ubuntu] password 길이 제한하기... (0) | 2009/07/24 |
| [Linux] Ubuntu에서 VMware 실행시 키보드 입력 오류 (0) | 2009/03/03 |
| [Ubuntu] grub 복구하기 (0) | 2006/09/11 |
| [Ubuntu] 우분투 5.10 시작 가이드 (0) | 2005/12/29 |