カーネルのビルド手順

Linuxカーネルのビルド手順です。

環境

 ・KVM上のubuntu10.04

ビルド方法

必要なパッケージの取得

 ビルドに必要なパッケージを取得しておきます。

apt-get install build-essential
apt-get install kernel-package libncurses5-dev libqt3-mt-dev

ソースファイルの取得

 The Linux Kernel Archivesからビルドしたいカーネルのソースを取得して展開します。

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.tar.bz2
tar jxf linux-2.6.35.4.tar.bz2

コンフィグファイルの作成

 以前のコンフィグファイルから作成します。

cd linux-2.6.36
cp /boot/config-2.6.35.4 .config
make oldconfig

ビルドパラメータを変更

 ビルドパラメータを変更します。今回は特に変更しませんでした。

make menuconfig

カーネルのインストールパッケージを作る

 「CONCURRENCY_LEVEL=2」はスレッドを2つ作ってビルドする指定です。

make-kpkg clean
CONCURRENCY_LEVEL=2 make-kpkg --initrd --revision=20101025 kernel_image kernel_headers

.deb ができるので dpkg でインストール & initrd.imgの作成

cd ..
dpkg -i linux-image-2.6.36_20101025_amd64.deb
mkinitramfs -o /boot/initrd.img-2.6.36 2.6.36
update-grub2

再起動

 これで再起動すると新しいカーネルで起動するはずです。

$ uname -r
2.6.36

ビルドパラメータについて

Processor type and features

 KVMではなく通常のマシンにインストールしているのであれば、CPUに関するパラメータを最適なものにしておくと、パフォーマンスが向上するようです。

Processor type and features >
    Processor family => Core 2/newer Xeon
    Timer frequency => 1000 HZ

参考

カーネルのビルド

このエントリーをはてなブックマークに追加
Share on Facebook

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>