先日はDebian/UbutnuでのKernel再構築したので
今回はArch Linuxでやってみたいと思います。
今のKernelは3.2.8系
# uname -r 3.2.8-1-ARCH
これを再構築してみます。
正直、ABSでKernel再構築は面倒だと思います。
書き換えることが多すぎます。。。
1)ABSを使えるようにする
# pacman -Syu abs base-devel # vim /etc/abs.conf REPOS=(core extra community !testing !community-testing !staging !community-staging !gnome-unstable !kde-unstable)
「core」が必要です。
# abs ==> Starting ABS sync... receiving file list ... done sent 178 bytes received 308007 bytes 47413.08 bytes/sec total size is 19643906 speedup is 63.74 # # ls /var/abs/ community core extra local README
作業ディレクトリにコピーしてきます。
$ mkdir -p ~/abs/core/ $ cp -r /var/abs/core/linux/ ~/abs/core $ cd ~/abs/core/linux $ ls -lah total 312K drwxr-xr-x 2 root root 4.0K Mar 2 11:23 . drwx------ 4 hoge hoge 4.0K Mar 2 11:23 .. -rw-r--r-- 1 hoge hoge 12K Mar 2 11:23 PKGBUILD -rw-r--r-- 1 hoge hoge 603 Mar 2 11:23 change-default-console-loglevel.patch -rw-r--r-- 1 hoge hoge 130K Mar 2 11:23 config -rw-r--r-- 1 hoge hoge 125K Mar 2 11:23 config.x86_64 -rw-r--r-- 1 hoge hoge 1.5K Mar 2 11:23 ext4-options.patch -rw-r--r-- 1 hoge hoge 804 Mar 2 11:23 i915-fix-ghost-tv-output.patch -rw-r--r-- 1 hoge hoge 2.1K Mar 2 11:23 i915-gpu-finish.patch -rw-r--r-- 1 hoge hoge 2.2K Mar 2 11:23 linux.install -rw-r--r-- 1 hoge hoge 376 Mar 2 11:23 linux.preset
パッチなどもありますね。
2)カーネルパラメータについて
Arch Linuxのデフォルトパラメータを使う場合はいいのですが、
現在のKernelパラメータ(一度再構築した後など)を使う場合は、
「/proc/config.gz」を使います。
64Bit版
$ mv config.x86_64 config.x86_64.back $ zcat /proc/config.gz >./config.x86_64
32Bit版
$ mv config config.back $ zcat /proc/config.gz >./config
どうやら、そのまま「makepkg」すると
今使っているカーネルパラメータは引き継がられず
Arch Linuxで使われてるデフォルパラメータの
「config」、「config.x86_64」がそのままコピーされ
~/abs/core/linux/src/linux-3.2/.config
として使われるようです。
3)PKGBUILDの編集
新Kernel名はそのまま「linux」とする場合には無視して下さい。
でも、オススメしないです。
新Kernel名・・・kernel-custom
6行目・・・・・・コメントアウト
7、105、157行目・・・「kernel-custom」にします。(新Kernel名)
110、159、290行目・・・「provides=(‘kernel26-docs’)」をコメントアウト
111、160、291行目・・・「conflicts=(‘kernel26-headers’)」をコメントアウト
112、161、292行目・・・「replaces=(‘kernel26-headers’)」をコメントアウト
84行目あたり・・・カーネルパラメータを変更する(今回は「menuconfig」にします)
provides=(‘kernel26-docs’)
conflicts=(‘kernel26-headers’)
replaces=(‘kernel26-headers’)
この3つをコメントアウトしないと、新Kernelインストール時に
conflictを起こしてしまいます。
今回は、KernelとKernel-headersを作ります。
$ vi PKGBUILD 6 #pkgname=('linux' 'linux-headers' 'linux-docs') # Build stock -ARCH kernel 7 pkgname=('linux-custom' 'linux-custom-headers') # Build kernel with a different name 84 # load configuration 85 # Configure the kernel. Replace the line below with one of your choice. 86 make menuconfig # CLI menu for configuration 87 #make nconfig # new CLI menu for configuration 88 #make xconfig # X-based configuration 89 #make oldconfig # using old config from previous kernel version 90 # ... or manually edit .config 105 package_linux-custom() { 106 pkgdesc="The Linux Kernel and modules" 107 groups=('base') 108 depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7') 109 optdepends=('crda: to set the correct wireless channels of your country') 110 #provides=('kernel26') 111 #conflicts=('kernel26') 112 #replaces=('kernel26') 113 backup=("etc/mkinitcpio.d/${pkgname}.preset") 114 install=${pkgname}.install 157 package_linux-custom-headers() { 158 pkgdesc="Header files and scripts for building modules for linux kernel" 159 #provides=('kernel26-headers') 160 #conflicts=('kernel26-headers') 161 #replaces=('kernel26-headers')
あと一息です。。。。
docsもやるなら同じようにやります。
$ makepkg -s ==> ERROR: One or more files did not pass the validity check!
と言われるので、
PKGBUILDの更新します。
$ makepkg -g >>PKGBUILD ==> Retrieving Sources... -> Found linux-3.2.tar.xz -> Found patch-3.2.8.xz -> Found config -> Found config.x86_64 -> Found linux.preset -> Found change-default-console-loglevel.patch -> Found i915-fix-ghost-tv-output.patch -> Found i915-gpu-finish.patch -> Found ext4-options.patch ==> Generating checksums for source files...
新Kernel名に以下も変えておきます
$ makepkg -s ==> ERROR: install file (linux-custom.install) does not exist. -> Found config -> Found config.x86_64 ==> ERROR: linux.preset was not found in the build directory and is not a URL.
と言われるので
linux.install・・・linux-custom.install(新Kernel名.install)
linux.preset・・・linux-custom.preset(新Kernel名.preset)
Kernel-headersのほうも同じエラーが出ますので、
linux.install・・・linux-custom-headers.install(新Kernel名-headers.install)
linux.preset・・・linux-custom-headers.preset(新Kernel名-headers.preset)
$ cp linux.install linux-custom.install $ cp linux.preset linux-custom.preset $ $ cp linux.install linux-custom-headers.install $ cp linux.preset linux-custom-headers.preset
これで再構築の準備が出来ました。。。。
4)再構築してみる
makepkg一発です。「-s」で依存を解決させます。
途中で、「make menuconfig」が行われますので、
オプションを変更しましょう
一時間ほどかかるのでコーヒーでも飲みましょうw
$ makepkg -s makepkg --asroot ==> Making package: linux 3.2.8-1 (Fri Mar 2 14:09:33 JST 2012) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving Sources... -> Found linux-3.2.tar.xz -> Found patch-3.2.8.xz -> Found config -> Found config.x86_64 -> Found linux-custom.preset -> Found change-default-console-loglevel.patch -> Found i915-fix-ghost-tv-output.patch -> Found i915-gpu-finish.patch -> Found ext4-options.patch ==> Validating source files with md5sums... ==> Tidying install... -> Purging unwanted files... -> Compressing man and info pages... ==> Creating package... -> Generating .PKGINFO file... -> Adding install file... -> Compressing package... ==> Starting package_linux-custom-headers()... ==> Tidying install... -> Purging unwanted files... -> Compressing man and info pages... ==> Creating package... -> Generating .PKGINFO file... -> Compressing package... ==> Finished making: linux 3.2.8-1 (Thu Mar 1 22:48:54 JST 2012)
終わったようです。。。
$ ls -lha total 113M drwxr-xr-x 4 root root 4.0K Mar 2 11:45 . drwxr-xr-x 6 hoge hoge 4.0K Mar 1 16:21 .. -rw-r--r-- 1 hoge hoge 13K Mar 1 22:04 PKGBUILD -rw-r--r-- 1 hoge hoge 603 Mar 1 16:21 change-default-console-loglevel.patch -rw-r--r-- 1 hoge hoge 130K Mar 1 16:21 config.back -rw-r--r-- 1 hoge hoge 86K Mar 1 22:03 config.x86_64 -rw-r--r-- 1 hoge hoge 125K Mar 1 16:21 config.x86_64.back -rw-r--r-- 1 hoge hoge 1.5K Mar 1 16:21 ext4-options.patch -rw-r--r-- 1 hoge hoge 804 Mar 1 16:21 i915-fix-ghost-tv-output.patch -rw-r--r-- 1 hoge hoge 2.1K Mar 1 16:21 i915-gpu-finish.patch -rw-r--r-- 1 hoge hoge 63M Mar 1 16:29 linux-3.2.tar.xz -rw-r--r-- 1 hoge hoge 2.2K Mar 2 14:36 linux-custom-headers.install -rw-r--r-- 1 hoeg hoge 376 Mar 2 14:36 linux-custom-headers.preset -rw-r--r-- 1 hoge hoge 2.2K Mar 1 22:47 linux-custom.install -rw-r--r-- 1 hoge hoge 376 Mar 1 16:21 linux-custom.preset -rw-r--r-- 1 hoge hoge 25M Mar 1 19:46 linux-custom-3.2.8-1-x86_64.pkg.tar.xz -rw-r--r-- 1 hoge hoge 4.7M Mar 1 19:47 linux-custom-headers-3.2.8-1-x86_64.pkg.tar.xz -rw-r--r-- 1 hoge hoge 130K Mar 1 16:29 patch-3.2.8.xz drwxr-xr-x 4 hoge hoge 4.0K Mar 1 22:47 pkg drwxr-xr-x 3 hoge hoge 4.0K Mar 1 22:57 src
出来たぁ
インストールしましょう〜
Rootになって
# pacman -U linux-custom-3.2.8-1-x86_64.pkg.tar.xz linux-custom-headers-3.2.8-1-x86_64.pkg.tar.xz ==> Tidying install... -> Purging unwanted files... -> Compressing man and info pages... ==> Creating package... -> Generating .PKGINFO file... -> Compressing package... ==> Finished making: linux 3.2.8-1 (Thu Mar 1 22:48:54 JST 2012)
インストールできました。
確認してみます。
#ls -lha /boot total 31M drwxr-xr-x 4 root root 4.0K Mar 1 23:20 . drwxr-xr-x 22 root root 4.0K Feb 25 20:06 .. drwxr-xr-x 2 root root 4.0K Mar 1 22:50 grub -rw-r--r-- 1 root root 9.6M Mar 1 21:49 initramfs-linux-custom-fallback.img -rw-r--r-- 1 root root 2.2M Mar 1 21:48 initramfs-linux-custom.img -rw-r--r-- 1 root root 11M Mar 1 20:44 initramfs-linux-fallback.img -rw-r--r-- 1 root root 2.6M Mar 1 20:44 initramfs-linux.img drwx------ 2 root root 16K Feb 25 20:02 lost+found -rw-r--r-- 1 root root 3.2M Feb 28 05:54 vmlinuz-linux -rw-r--r-- 1 root root 3.1M Mar 1 19:44 vmlinuz-linux-custom
きちんと出来ています。
5)menu.listを編集します
UUIDは環境により変わります。
# vi /boot/grub/menu.list # (0) Arch Linux Custom title Arch Linux Custom root (hd0,0) kernel /vmlinuz-linux-custom root=/dev/disk/by-uuid/2765fd25-20cd-47e6-aefd-d22b1d0506ec ro initrd /initramfs-linux-custom.img # (1) Arch Linux title Arch Linux root (hd0,0) kernel /vmlinuz-linux root=/dev/disk/by-uuid/2765fd25-20cd-47e6-aefd-d22b1d0506ec ro initrd /initramfs-linux.img # (2) Arch Linux title Arch Linux Fallback root (hd0,0) kernel /vmlinuz-linux root=/dev/disk/by-uuid/2765fd25-20cd-47e6-aefd-d22b1d0506ec ro initrd /initramfs-linux-fallback.img
デフォルト起動にしてみました。
UUIDの確認方法
# ls -lha /dev/disk/by-uuid/ total 0 drwxr-xr-x 2 root root 120 Mar 1 22:53 . drwxr-xr-x 5 root root 100 Mar 1 22:53 .. lrwxrwxrwx 1 root root 10 Mar 1 22:53 05a8bd16-3b64-4ba3-bd3d-effd3710d2ac -> ../../sda1 lrwxrwxrwx 1 root root 10 Mar 1 22:53 05e019b0-7a70-490a-8ba7-f450169a5dff -> ../../sda2 lrwxrwxrwx 1 root root 10 Mar 1 22:53 2765fd25-20cd-47e6-aefd-d22b1d0506ec -> ../../sda3 lrwxrwxrwx 1 root root 10 Mar 1 22:53 5b58d381-1adc-4c82-a84a-1f15ed55497d -> ../../sda4 # # df -h Filesystem Size Used Avail Use% Mounted on rootfs 18G 1.4G 16G 9% / /dev 498M 0 498M 0% /dev /run 500M 104K 500M 1% /run /dev/sda3 18G 1.4G 16G 9% / shm 500M 0 500M 0% /dev/shm tmpfs 500M 0 500M 0% /tmp /dev/sda1 595M 33M 533M 6% /boot /dev/sda4 21G 7.0G 13G 36% /home
僕の環境では
boot・・・sda1
UUID・・・05a8bd16-3b64-4ba3-bd3d-effd3710d2ac
です。
# reboot
無事に新Kernelで起動出来ました。
$ uname -r 3.2.8-1-custom
あとは僕の場合はopen-vm-tools-modulesを入れなおしました。
この記事が人目に付くことはあるんだろうか。。。w
[tegaki]つかれたよw[/tegaki]