CentOS 7 に Kernel 4.6系をインストールする方法

現時点のカーネルバージョンを確認します。

# uname -r
3.10.0-327.18.2.el7.x86_64


カーネルのインストールに使う、レポジトリを追加します。

# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm


最新カーネルをインストールします。

# yum -y install --enablerepo=elrepo-kernel kernel-ml


/boot直下にKernel 4.6 系に関連するファイルが複数生成されています。

# ls -1 /boot/ | grep -E '.*-4\.'
System.map-4.6.2-1.el7.elrepo.x86_64
config-4.6.2-1.el7.elrepo.x86_64
initramfs-4.6.2-1.el7.elrepo.x86_64.img
symvers-4.6.2-1.el7.elrepo.x86_64.gz
vmlinuz-4.6.2-1.el7.elrepo.x86_64


最新カーネルがサーバ起動時に読み込まれるように/etc/default/grubを編集します。

# sed -i "s/^GRUB_DEFAULT\=.*/GRUB_DEFAULT\=0/g" /etc/default/grub


GRUBをアップデートします。

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.6.2-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.6.2-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-327.18.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.18.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f09801905e2f4e13966d8d90c3939e2e
Found initrd image: /boot/initramfs-0-rescue-f09801905e2f4e13966d8d90c3939e2e.img


サーバを最新カーネルで起動させるため、再起動します。

# reboot


再起動後、カーネルが4系になったことを確認できました。

# uname -r
4.6.2-1.el7.elrepo.x86_64