gitでLinuxカーネルを入手
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Cloning into 'linux-stable'...
remote: Counting objects: 3942199, done.
remote: Compressing objects: 100% (603472/603472), done.
Receiving objects: 100% (3942199/3942199), 844.41 MiB | 2.54 MiB/s, done.
remote: Total 3942199 (delta 3325415), reused 3924475 (delta 3307964)
Resolving deltas: 100% (3325415/3325415), done.
/は8GBしか確保しておらず空き容量が足りないため別のディレクトリに落として作業してみました。
コンパイル中に結構膨れ上がるので十分な空きのある場所で行いましょう。
カーネルの構成設定
下記のコマンド(どれかお好みの1つ)で行うことが出来ます。
$ make config インタラクティブ
$ make menuconfig CUIベースのメニュー
$ make xconfig KDEベースのメニュー
$ make gconfig Gnomeベースのメニュー
いざカーネルの設定
$ cd linux-stable
$ make menuconfig
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
make[1]: *** [scripts/kconfig/dochecklxdialog] エラー 1
make: *** [menuconfig] エラー 2
menuconfigを実行するためにはncurses-develというライブラリが必要だそうです。
$ sudo apt-get install libncurses5-dev
改めてカーネルを設定
$ make menuconfig

ここでいらんものと居るものをチェックをはずしたりつけたりして俺好みにチューニングします。
.configに設定をsaveしてexit
カーネルを弄る必要,自信が無い場合は、defconfigターゲットでカーネルのデフォルト値が設定された.configファイルを作成することが出来ます。
$ make defconfig
.configを作成したら今度はmake
$ make
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
#
# configuration written to .config
#
SYSTBL arch/x86/syscalls/../include/generated/asm/syscalls_32.h
SYSHDR arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h
SYSHDR arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h
SYSTBL arch/x86/syscalls/../include/generated/asm/syscalls_64.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
SYSHDR arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
:
Setup is 15900 bytes (padded to 16384 bytes).
System is 1428 kB
CRC bed62813
Kernel: arch/x86/boot/bzImage is ready (#1)
installを実行する前に気が変わったりエラーが起こった場合は下記コマンドで.configを取り消し、変更を初期化することが出来ます。
$ make mrproper
その必要が無いなら次の工程へ進みましょう
モジュールをインストール
modules_installターゲットで/lib/modules/バージョン以下にモジュールがインストールされます。
カーネルモジュールに一応ついている拡張子は.koです。
$ make modules_install
:
INSTALL /lib/firmware/edgeport/boot.fw
INSTALL /lib/firmware/edgeport/boot2.fw
INSTALL /lib/firmware/edgeport/down.fw
INSTALL /lib/firmware/edgeport/down2.fw
INSTALL /lib/firmware/edgeport/down3.bin
INSTALL /lib/firmware/whiteheat_loader.fw
INSTALL /lib/firmware/whiteheat.fw
INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw
INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
INSTALL /lib/firmware/cpia2/stv0672_vp4.bin
DEPMOD 3.16.0
$ ls /lib/modules
3.11.0-24-generic 3.11.0-26-generic 3.16.0
カーネルをインストール
$ sudo make install
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.16.0 /boot/vmlinuz-3.16.0
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.16.0 /boot/vmlinuz-3.16.0
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.16.0
Found initrd image: /boot/initrd.img-3.16.0
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.11.0-24-generic
Found initrd image: /boot/initrd.img-3.11.0-24-generic
Found memtest86+ image: /boot/memtest86+.bin
done
よーくコンソールを見ているとどうやら自動的に/bootにカーネルを配置するだけでなくgrub.cfgもアップデートしてくれています。親切ですね。
再起動してバージョンを確認してみます。
$ uname -r
3.16.0
再起動前が3.11.0-24-genericだったので成功したようです。
- 関連記事
-
-
sysctl, /etc/sysctl.conf カーネルパラメーターの設定 2014/08/09
-
カーネルモジュール関連のコマンド 201 2014/08/07
-
Linuxカーネルをコンパイル,インストールしてみる 201 2014/08/07
-
Linuxカーネル 201 2014/08/05
-
LPIC 201と202の模擬問題をやってみた 2014/08/05
-