ESXi用Kernelの再構築

http://www.kernel.org
stable: 3.2.8 2012-02-27

3.2.8出てる。。。

ESXiで使っているUbuntuはgenericで
必要ないデバイスドライバがいっぱいあるので、

# cat /boot/config-2.6.32-38-generic |grep =y|wc -l
1227
# cat /boot/config-2.6.32-38-generic |grep =m|wc -l
2407
# cat /boot/config-2.6.32-38-generic |grep not\ set|wc -l
519

Kernel再構築してみた。

元Kernel・・・2.6.32-38-generic
新Kernel・・・3.2.8

DebianとRedhat系(CentOS、Scientific Linux)でも行けるはず。

変更点

CONFIG_MCORE2 *1
# CONFIG_ATA is not set *2
# CONFIG_IDE *2
# CONFIG_I2C_PIIX4 is not set *3
CONFIG_RTC_DRV_CMOS=y *4
CONFIG_VMWARE_BALLOON=y
CONFIG_VMWARE_PVSCSI=y *5
CONFIG_VMXNET3=y
CONFIG_SYSFS_DEPRECATED=y *6*7
CONFIG_SYSFS_DEPRECATED_V2=y *6*7
# CONFIG_SYSFS_DEPRECATED is not set *6*7
CONFIG_INOTIFY_USER=y *7
CONFIG_SIGNALFD=y *7

他にもいらないドライバも削っていく。

南十字さんありがとう〜
http://blog.thnetworks.info/


*1
CPUタイプ。僕の場合は
Core 2/newer Xeon

*2
使ってないので削除してもOKです。

*3
piix4_smbusでエラー吐くので削除。

# dmesg |grep piix4_smbus
[    3.457719] piix4_smbus 0000:00:07.3: Host SMBus controller not enabled!

ESXiでは使えない。
http://communities.vmware.com/thread/144562

*4
RTCを全部削除すると下記エラーが発生するので
CONFIG_RTC_DRV_CMOSのみビルドインする。

# dmesg |grep rtc
[    2.669216] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[   10.447288] rtc_cmos 00:04: rtc core: registered rtc_cmos as rtc0
[   10.447364] rtc0: alarms up to one month, y3k, 114 bytes nvram, hpet irqs

*5
ゲストOSのSCSIコントローラタイプを
「準仮想化」にしても起動できるようになります
includeしたほうが起動が速いです。

*6
Kernel2.6.3x以降から必要になったようです。
RedHat系のCentOSやScientificLinuxなどでは有効にして下さい。
Denian/Ubuntuとは逆です!!
Enable deprecated sysfs features to support old userspace tools
 SYSFS_DEPRECATED=y
Enable deprecated sysfs features by default
 SYSFS_DEPRECATED_V2=y

*7
Debian Squeez/ubuntuなどでは、無効にして下さい。
Redhat系とは逆です!!
Enable deprecated sysfs features to support old userspace tools
 # CONFIG_SYSFS_DEPRECATED is not set
Enable deprecated sysfs features by default
 # CONFIG_SYSFS_DEPRECATED_V2 is not set
Inotify support for userspace
 CONFIG_INOTIFY_USER=y
Enable signalfd() system call
 CONFIG_SIGNALFD=y

1)オプション変更

# apt-get install libncurses-dev kernel-package
# cp cp /boot/config-2.6.32-38-generic linux-3.2.8/.config
# cd linux-3.2.8
# make oldconfig
# make menuconfig

2)コンパイル
・Kernelリリース名
 3.2.8-custom

・出来上がるKernelファイル名
 linux-headers-3.2.8-custom_20120228_amd64.deb
 linux-image-3.2.8-custom_20120228_amd64.deb

・オプション
 CONCURRENCY_LEVEL=CPU-Core数+1

# make-kpkg clean
# CONCURRENCY_LEVEL=3 make-kpkg -initrd --revision=20120228 --append-to-version=-custom kernel_image kernel_headers
#
# cd ../
# ll
drwxrwxr-x 25 root  root  4.0K 2012-02-28 22:40 linux-3.2.8/
-rw-r--r--  1 root  root   75M 2012-02-28 07:07 linux-3.2.8.tar.bz2
-rw-r--r--  1 root  root  6.8M 2012-02-28 22:31 linux-headers-3.2.8-custom_20120228_amd64.deb
-rw-r--r--  1 root  root  7.7M 2012-02-28 22:30 linux-image-3.2.8-custom_20120228_8amd64.deb

出来上がり。

!!重要!!
このままKernelをインストールすると
initrd.img-3.2.8-customが作成されず、
GRUBにinitrdの指定が追記されない。

# ll /boot
-rw-r--r--  1 root root 2.1M 2012-01-04 20:57 System.map-2.6.32-38-generic
-rw-r--r--  1 root root 1.9M 2012-02-2802-28 10:50 System.map-3.2.8-custom
-rw-r--r--  1 root root 632K 2012-01-04 20:57 abi-2.6.32-38-generic
-rw-r--r--  1 root root 108K 2012-01-04 20:57 config-2.6.32-38-generic
-rw-r--r--  1 root root  67K 2012-02-28 10:28 config-3.2.8-custom
drwxr-xr-x  3 root root 4.0K 2012-02-28 22:04 grub/
-rw-r--r--  1 root root 8.0M 2012-02-27 11:16 initrd.img-2.6.32-38-generic
-rw-r--r--  1 root root 157K 2010-03-23 18:40 memtest86+.bin
-rw-r--r--  1 root root 1.4K 2012-01-04 20:57 vmcoreinfo-2.6.32-38-generic
-rw-r--r--  1 root root 3.9M 2012-01-04 20:57 vmlinuz-2.6.32-38-generic
-rw-r--r--  1 root root 3.4M 2012-02-28 10:50 vmlinuz-3.2.8-custom

initrd.img-3.2.8-customが作成されていない。

# cat /boot/grub/grub.cfg
menuentry 'Ubuntu, with Linux 3.2.8-custom-10' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set e0c6d136-59ee-445a-a0f6-347d83a5c4e9
        linux   /boot/vmlinuz-3.2.8-custom-10 root=UUID=e0c6d136-59ee-445a-a0f6-347d83a5c4e9 ro   splash quiet
}

本来あるはずの「initrd /boot/initrd.img-3.2.8-custom」の記述がない。

対策方法

# mkdir -p /etc/kernel/postinst.d/
# cp -a /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/

新Kernelのインストール

# dpkg -i linux-image-3.2.8-custom_20120228_amd64.deb 
未選択パッケージ linux-image-3.2.8-custom を選択しています。
(データベースを読み込んでいます ... 現在 63145 個のファイルとディレクトリがインストールされています。)
(linux-image-3.2.8-custom_20120228_amd64.deb から) linux-image-3.2.8-custom を展開しています...
Examining /etc/kernel/preinst.d/
Done.
linux-image-3.2.8-custom (20120228) を設定しています ...
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs 3.2.8-custom /boot/vmlinuz-3.2.8-custom
Running postinst hook script update-grub.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.8-custom
Found initrd image: /boot/initrd.img-3.2.8-custom
Found linux image: /boot/vmlinuz-2.6.32-38-generic
Found initrd image: /boot/initrd.img-2.6.32-38-generic
Found memtest86+ image: /boot/memtest86+.bin
done

新Kernelヘッダをインストール

# dpkg -i linux-headers-3.2.8-custom_20120228_amd64.deb 
未選択パッケージ linux-headers-3.2.8-custom を選択しています。
(データベースを読み込んでいます ... 現在 63917 個のファイルとディレクトリがインストールされています。)
(linux-headers-3.2.8-custom_20120228_amd64.deb から) linux-headers-3.2.8-custom を展開しています...
linux-headers-3.2.8-custom (20120228) を設定しています ...
Examining /etc/kernel/header_postinst.d.

#
# shutdown -h now

SCSIコントローラタイプを「準仮想化」
ネットワークアダプタを「VMXNET3」

にして起動します。

起動したら、再度VMware-toolsをインストールします。
時々エラー吐きますがKernelにinclude&Module化されてるので大丈夫です。

3)補足
他のDebian/Ubuntuにインストールする場合、
/usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs
が存在しない(kernel-packageに含まれています)ので、
インストールしたいOS上でファイルを作り、実行権限を与えます。

#vi /etc/kernel/postinst.d/initramfs

#! /bin/sh

set -e

if [ -n "$INITRD" ] && [ "$INITRD" = 'No' ]; then
    exit 0
fi
version="$1"
vmlinuz_location="$2"


if [ -n "$DEB_MAINT_PARAMS" ]; then
    eval set -- "$DEB_MAINT_PARAMS"
    if [ -z "$1" ] || [ "$1" != "configure" ]; then
        exit 0;
    fi
fi

# passing the kernel version is required
[ -z "$version" ] && exit 1


if [  -n "$vmlinuz_location" ]; then
    # Where is the image located? We'll place the initrd there.
    boot=$(dirname "$vmlinuz_location")
    bootarg="-b $boot"
fi

# 
if which update-initramfs >/dev/null ; then
    update-initramfs -c -t -k "$version" $bootarg
fi

実行権限を与えます

# chmod +x /etc/kernel/postinst.d/initramfs

これで、Kernel、Kernel-headerをインストールすれば、OK

ちなみに僕のKernel

# cat /boot/config-3.2.8-custom|grep =y|wc -l
719
# cat /boot/config-3.2.8-custom|grep =m|wc -l
529
# cat /boot/config-3.2.8-custom-11|grep not\ set|wc -l
869

こんな感じですw

[tegaki]削りましたw[/tegaki]

ESXi用Kernelの再構築」への2件のフィードバック

  1. 南十字@Tokyo

    いつも分かりやすく書いてあって助かります。
    自分もカーネル弄って遊んでますが、ドはまりしたことも書いてあるのでびっくりしました。

    返信
    1. ねころく 投稿作成者

      コメント有難うございます。

      いつもお世話になっています。
      一言書いておくのを忘れました。。。

      南十字さんのKernelには負けます。。。。w

      返信

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Enter code * Time limit is exhausted. Please reload CAPTCHA.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください