13
12

More than 5 years have passed since last update.

CentOS6.7 カーネルアップデート

Last updated at Posted at 2015-08-19

経緯

ipvsadm + iptables でSNATできるLBを構築しようとしたらカーネルのアップデートが必要ぽかったので、やったことないしチャレンジしてみました。

環境

  • CentOS6.7 64bit
  • VMware ESXi 5.5

やりたいこと

カーネルを2.6.36以上にバージョンアップをしたい
※yum では2.6.32-573.3.1.el6 までしか上がらず

変更前 変更後
2.6.32-504.el6.x86_64 2.6.36.4       

手順

1. 事前準備

1.1. 現在のカーネルバージョン確認

# uname -r
2.6.32-504.el6.x86_64

1.2. カーネルモジュールのダウンロード

# cd /usr/local/src/
# wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.4.tar.bz2
# ll
合計 68616
-rw-r--r--. 1 root root 70262144  8月 19 13:55 2015 linux-2.6.36.4.tar.bz2

1.3. カーネルモジュールの解凍

# tar xvfj linux-2.6.36.4.tar.bz2
# ll
合計 68620
drwxrwxr-x. 23 root root     4096  2月 18 08:14 2011 linux-2.6.36.4
-rw-r--r--.  1 root root 70262144  8月 19 13:55 2015 linux-2.6.36.4.tar.bz2

2. インストール

2.1. ディレクトリ移動

# cd linux-2.6.36.4

2.2. 現在のカーネルビルド設定引き継ぎ

# cp -p /boot/config-2.6.32-504.el6.x86_64 ./.config

2.3. 設定ファイルの作成

2.2. でコピーした設定ファイルを用いて新しい設定ファイルを作成

# make oldconfig
  HOSTCC  scripts/basic/fixdep
/bin/sh: gcc: コマンドが見つかりません
make[1]: *** [scripts/basic/fixdep] エラー 127
make: *** [scripts_basic] エラー 2

2.3.1. gcc のインストール

gccがないと怒られたのでインストール

# yum -y install gcc

2.4. 気を取り直して再度設定ファイルの作成

# make oldconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
...省略

2.5. コンパイル

※ここがめっちゃ時間かかりました

# make
scripts/kconfig/conf --silentoldconfig arch/x86/Kconfig
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
...省略

2.6. カーネルモジュールインストール

# make modules_install

2.7. カーネルインストール

※なんか色々ERRORってなってるけど大丈夫なのだろうか?w

# make install
sh /usr/local/src/linux-2.6.36.4/arch/x86/boot/install.sh 2.6.36.4 arch/x86/boot/bzImage \
        System.map "/boot"
ERROR: modinfo: could not find module nf_defrag_ipv6
ERROR: modinfo: could not find module vsock
ERROR: modinfo: could not find module vmware_balloon
ERROR: modinfo: could not find module vmci

3. インストール後の確認

3.1. /boot ディレクトリの確認

# ll /boot/
合計 109652
lrwxrwxrwx. 1 root root       25  8月 19 15:15 2015 System.map -> /boot/System.map-2.6.36.4
-rw-r--r--. 1 root root  2544748 10月 15 13:54 2014 System.map-2.6.32-504.el6.x86_64
-rw-r--r--. 1 root root  2585052  7月 26 02:34 2015 System.map-2.6.32-573.1.1.el6.x86_64
-rw-r--r--. 1 root root  2585088  8月 14 08:25 2015 System.map-2.6.32-573.3.1.el6.x86_64
-rw-r--r--. 1 root root  2140702  8月 19 15:15 2015 System.map-2.6.36.4
-rw-r--r--. 1 root root   106308 10月 15 13:54 2014 config-2.6.32-504.el6.x86_64
-rw-r--r--. 1 root root   107138  7月 26 02:34 2015 config-2.6.32-573.1.1.el6.x86_64
-rw-r--r--. 1 root root   107138  8月 14 08:25 2015 config-2.6.32-573.3.1.el6.x86_64
drwxr-xr-x. 3 root root     1024  8月 11 14:51 2015 efi
drwxr-xr-x. 2 root root     1024  8月 19 15:15 2015 grub
-rw-------. 1 root root 19194026  8月 11 15:11 2015 initramfs-2.6.32-504.el6.x86_64.img
-rw-------. 1 root root 24877833  8月 11 17:38 2015 initramfs-2.6.32-573.1.1.el6.x86_64.img
-rw-------. 1 root root 24896551  8月 19 13:44 2015 initramfs-2.6.32-573.3.1.el6.x86_64.img
-rw-------. 1 root root 10641846  8月 19 15:15 2015 initramfs-2.6.36.4.img
-rw-------. 1 root root  5481545  8月 11 17:35 2015 initrd-2.6.32-504.el6.x86_64kdump.img
drwx------. 2 root root    12288  8月 11 14:33 2015 lost+found
-rw-r--r--. 1 root root   200191 10月 15 13:55 2014 symvers-2.6.32-504.el6.x86_64.gz
-rw-r--r--. 1 root root   205998  7月 26 02:35 2015 symvers-2.6.32-573.1.1.el6.x86_64.gz
-rw-r--r--. 1 root root   205998  8月 14 08:25 2015 symvers-2.6.32-573.3.1.el6.x86_64.gz
lrwxrwxrwx. 1 root root       22  8月 19 15:15 2015 vmlinuz -> /boot/vmlinuz-2.6.36.4
-rwxr-xr-x. 1 root root  4152336 10月 15 13:54 2014 vmlinuz-2.6.32-504.el6.x86_64
-rwxr-xr-x. 1 root root  4220816  7月 26 02:34 2015 vmlinuz-2.6.32-573.1.1.el6.x86_64
-rwxr-xr-x. 1 root root  4221776  8月 14 08:25 2015 vmlinuz-2.6.32-573.3.1.el6.x86_64
-rw-r--r--. 1 root root  3758512  8月 19 15:15 2015 vmlinuz-2.6.36.4

3.2. カーネルモジュールの確認

# ll /lib/modules/
合計 16
drwxr-xr-x. 8 root root 4096  8月 11 15:10 2015 2.6.32-504.el6.x86_64
drwxr-xr-x. 7 root root 4096  8月 11 17:37 2015 2.6.32-573.1.1.el6.x86_64
drwxr-xr-x. 7 root root 4096  8月 19 13:43 2015 2.6.32-573.3.1.el6.x86_64
drwxr-xr-x. 3 root root 4096  8月 19 15:15 2015 2.6.36.4

3.3. grub.conf の確認

grub.conf
# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_lb01-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.36.4)
        root (hd0,0)
        kernel /vmlinuz-2.6.36.4 ro root=/dev/mapper/vg_lb01-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_lb01/lv_swap crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_lb01/lv_root LANG=ja_JP.UTF-8 rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.36.4.img
title CentOS (2.6.32-573.3.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-573.3.1.el6.x86_64 ro root=/dev/mapper/vg_lb01-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_lb01/lv_swap crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_lb01/lv_root LANG=ja_JP.UTF-8 rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-573.3.1.el6.x86_64.img
title CentOS (2.6.32-573.1.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-573.1.1.el6.x86_64 ro root=/dev/mapper/vg_lb01-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_lb01/lv_swap crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_lb01/lv_root LANG=ja_JP.UTF-8 rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-573.1.1.el6.x86_64.img
title CentOS 6 (2.6.32-504.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=/dev/mapper/vg_lb01-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_lb01/lv_swap crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_lb01/lv_root LANG=ja_JP.UTF-8 rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-504.el6.x86_64.img

4. 新しいバージョンのカーネルで起動

4.1. 再起動

# reboot

4.2. 新しいカーネルの選択

CentOS (2.6.36.4) を選択する

WS000409.png

4.3. カーネルバージョンの確認

# uname -r
2.6.36.4

4.4. デフォルト起動カーネルバージョンの設定

今後、デフォルト起動をカーネル2.6.36.4にしたい場合は下記ファイルを編集する

変更前 変更後
default=1 default=0
grub.conf
# vim /etc/grub.conf
default=0
...省略

後記

わりとすんなりできてよかった!
後はSNATできるようになるかどうかが問題。。。
make module_installのコマンドが抜けていたので追記しましたorz

13
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
12