概要
docker
の機能を使うためにCentOS
のkernel
のversion を上げる必要があったのでその為の備忘録。
環境
- OS : cent7.2
cat /etc/redhat-release
# CentOS Linux release 7.2.1511 (Core)
- kernel : 3.10
uname -r
# 3.10.0-327.el7.x86_64
update 手順
今回はmake
してupdate する方法とyum
でupdate する方法を試してみた。
make
下準備
KERNEL_VERSION=`uname -r`
echo $KERNEL_VERSION
# 3.10.0-327.el7.x86_64
yum -y update
yum -y install gcc bc
kernel module のダウンロード
cd /usr/local/src/
wget https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.26.tar.xz
ls -l
# total 79120
# -rw-r--r-- 1 root root 81017800 Jan 26 02:50 linux-3.18.26.tar.xz
kernel module の解凍
tar xvfJ linux-3.18.26.tar.xz
ls -l
# total 79124
# drwxrwxr-x 24 root root 4096 Feb 11 09:02 linux-3.18.26
# -rw-r--r-- 1 root root 81017800 Jan 26 02:50 linux-3.18.26.tar.xz
設定ファイルの作成
cd linux-3.18.26
cp -i /boot/config-$KERNEL_VERSION ./.config
make oldconfig
# HOSTCC scripts/basic/fixdep
# HOSTCC scripts/kconfig/conf.o
# SHIPPED scripts/kconfig/zconf.tab.c
# SHIPPED scripts/kconfig/zconf.lex.c
# SHIPPED scripts/kconfig/zconf.hash.c
# ・
# ・
# ・
## いっぱい質問が出てくるがひたすらEnter
コンパイル
make -j4
# scripts/kconfig/conf --silentoldconfig Kconfig
# 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
# HOSTCC scripts/basic/bin2c
# ・
# ・
# ・
make
には時間がかかるため同時に実行できるジョブの数を指定するため-j
オプションを用いています。
kernel module インストール
make modules_install
# INSTALL Documentation/connector/cn_test.ko
# INSTALL Documentation/filesystems/configfs/configfs_example_explicit.ko
# INSTALL Documentation/filesystems/configfs/configfs_example_macros.ko
# INSTALL arch/x86/crypto/aesni-intel.ko
# ・
# ・
# ・
kernel インストール
make install
# sh ./arch/x86/boot/install.sh 3.18.26 arch/x86/boot/bzImage \
# System.map "/boot"
grub 設定確認
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
# CentOS Linux (3.18.26) 7 (Core)
# CentOS Linux 7 Rescue 7444b2222355f84187a4cda79dec6cc3 # (3.10.0-327.4.5.el7.x86_64)
# CentOS Linux (3.10.0-327.4.5.el7.x86_64) 7 (Core)
# CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
# CentOS Linux (0-rescue-01fb3288265b4ee59a2301e4de11e3e6) 7 (Core)
3.18.26
のkernel が入っていることが確認できる。
grub 起動設定変更
## 起動kernel 変更
grub2-set-default 0
## 設定反映
grub2-mkconfig -o /boot/grub2/grub.cfg
再起動
reboot
起動後確認
uname -r
# 3.18.26
無事にversion があがっていることを確認できた。
yum
下準備
yum -y install
repolist にelrepo を追加
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
elrepo-kernel の有効化
elrepo-kernel
のenabled
を1
に変更する
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
http://jur-linux.org/download/elrepo/kernel/el7/$basearch/
http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/
http://mirror.ventraip.net.au/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=1 <--- ここを`1` に変更する
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
既存のkernel のパッケージを確認
yum list installed | grep kernel
# kernel.x86_64 3.10.0-327.el7 @anaconda
# kernel.x86_64 3.10.0-327.4.5.el7 @updates
# kernel-tools.x86_64 3.10.0-327.4.5.el7 @updates
# kernel-tools-libs.x86_64 3.10.0-327.4.5.el7 @updates
既存のkernel のパッケージを削除
yum -y remove kernel.x86_64 kernel-tools.x86_64 kernel-tools-libs.x86_64
yum -y update
kernel インストール
yum -y install kernel-ml.x86_64 kernel-ml-devel.x86_64 kernel-ml-headers.x86_64 kernel-ml-tools.x86_64 kernel-ml-tools-libs.x86_64
grub 設定確認
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
# CentOS Linux (4.4.1-1.el7.elrepo.x86_64) 7 (Core)
# CentOS Linux 7 Rescue 30e13afa85251a45b9ea22e336df111e (3.10.0-327.4.5.el7.x86_64)
# CentOS Linux (3.10.0-327.4.5.el7.x86_64) 7 (Core)
# CentOS Linux (0-rescue-01fb3288265b4ee59a2301e4de11e3e6) 7 (Core)
4.4.1
のkernel が入っていることが確認できる。
grub 起動設定変更
## 起動kernel 変更
grub2-set-default 0
## 設定反映
grub2-mkconfig -o /boot/grub2/grub.cfg
再起動
reboot
起動後確認
uname -r
# 4.4.1-1.el7.elrepo.x86_64
無事にversion があがっていることを確認できた。
まとめ
無事にCentOS
のkernel
のversion をアップデートすることができた。
しかし、Docker
を使っていくにあたって、そろそろCoreOS
を使ってみようかなと思いました。