- Print
- PDF
Ubuntu 20.04
- Print
- PDF
Available in VPC
This guide describes how to update a kernel on the Ubuntu 20.04 server of NAVER Cloud Platform.
This guide is written based on new servers created on NAVER Cloud Platform, so there might be differences from the user server environment. User server environments may be affected by kernel updates and server restarts due to various reasons such as security hardening operations and various setting operations. Therefore, be familiar with the following before you perform a kernel update.
- Create a replicated server using Server image before updating a kernel of the actual server. Perform the kernel update on the replicated server and check if it restarts normally. When switching to operational status after restarting, check for any issues in the server. Proceed with the server kernel update only when no issues were found after through validation.
- In the case of GPU servers, the GPU driver that matches the kernel version must be installed for normal operation. If the updated kernel isn't compatible with GPU drivers, the GPU server might not function normally. Therefore, check GPU driver compatibility before you perform kernel updates. For related information, see GPU driver guide.
- NCP Repo is a repository provided by NAVER Cloud Platform to support user environments where external access is limited, such as VPC private subnet. NCP Repo may not provide the latest package.
NAVER Cloud Platform has not tested all kernel versions after each update. As of January 1, 2024, the kernel version tested on Ubuntu 20.04 is 5.4.0-167-generic.
- The user is entirely responsible for performing user's server kernel updates. NAVER Cloud Platform does not take responsibility for issues caused by kernel updates.
- Normal server usage might be unavailable during kernel updates and restart, and recovery due to this is not supported. In addition, server recovery is not supported when the kernel update fails.
- Before updating the kernel, be sure to keep the backup created through Server image until it is no longer needed.
- No separate support is provided for problems related to this guide.
Update kernel
To update kernels for Ubuntu 20.04 servers, follow these steps:
Connect to the server you want to apply the kernel update to remotely.
Check the kernel version of the server.
root@ubuntu2004:~# uname -r 5.4.0-99-generic
Check the repository information connected to the server.
- The private VPC Ubuntu 20.04 has
http://repo.ncloud.com/ubuntu
, which is NCP Repo, set to base url by default.
root@ubuntu2004:~# grep ^deb /etc/apt/sources.list deb http://repo.ncloud.com/ubuntu focal main restricted deb http://repo.ncloud.com/ubuntu focal-updates main restricted deb http://repo.ncloud.com/ubuntu focal universe deb http://repo.ncloud.com/ubuntu focal-updates universe deb http://repo.ncloud.com/ubuntu focal multiverse deb http://repo.ncloud.com/ubuntu focal-updates multiverse deb http://repo.ncloud.com/ubuntu focal-backports main restricted universe multiverse deb http://repo.ncloud.com/ubuntu focal-security main restricted deb http://repo.ncloud.com/ubuntu focal-security universe deb http://repo.ncloud.com/ubuntu focal-security multiverse
- The private VPC Ubuntu 20.04 has
Check the kernel version provided by the repository.
root@ubuntu2004:~# apt-get update Hit:1 http://repo.ncloud.com/ubuntu focal InRelease Get:2 http://repo.ncloud.com/ubuntu focal-updates InRelease [114 kB] Get:3 http://repo.ncloud.com/ubuntu focal-backports InRelease [108 kB] Get:4 http://repo.ncloud.com/ubuntu focal-security InRelease [114 kB] ... Omitted... Get:40 http://repo.ncloud.com/ubuntu focal-security/universe amd64 c-n-f Metadata [19.2 kB] Get:41 http://repo.ncloud.com/ubuntu focal-security/multiverse amd64 Packages [23.6 kB] Get:42 http://repo.ncloud.com/ubuntu focal-security/multiverse i386 Packages [7,188 B] Get:43 http://repo.ncloud.com/ubuntu focal-security/multiverse Translation-en [5,504 B] Get:44 http://repo.ncloud.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [548 B] Fetched 18.2 MB in 3s (5,331 kB/s) Reading package lists... Done root@ubuntu2004:~# apt-cache search linux-image-5.4.0-167-generic linux-image-5.4.0-167-generic - Signed kernel image generic
Install the latest version of the kernel.
Carefully review the list of packages being newly installed, updated, or removed. If everything is in order, enterY
to complete the installation.root@ubuntu2004:~# apt install linux-{image,headers}-5.4.0-167-generic Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: linux-headers-5.4.0-167 linux-modules-5.4.0-167-generic Suggested packages: fdutils linux-doc | linux-source-5.4.0 linux-tools The following NEW packages will be installed: linux-headers-5.4.0-167 linux-headers-5.4.0-167-generic linux-image-5.4.0-167-generic linux-modules-5.4.0-167-generic 0 upgraded, 4 newly installed, 0 to remove and 276 not upgraded. Need to get 37.8 MB of archives. After this operation, 179 MB of additional disk space will be used. Do you want to continue? [Y/n] Y ... Omitted... /etc/kernel/postinst.d/zz-update-grub: Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-167-generic Found initrd image: /boot/initrd.img-5.4.0-167-generic Found linux image: /boot/vmlinuz-5.4.0-99-generic Found initrd image: /boot/initrd.img-5.4.0-99-generic done
After the installation is complete, check all bootable kernel versions.
root@ubuntu2004:~# awk -F"--class" '/menuentry/ && /with Linux/ {print $1}' /boot/grub/grub.cfg | awk '{print i++ " : " $5,$6,$7,$8}' | sed -e "s/'/ /g" 0 : 5.4.0-167-generic 1 : 5.4.0-167-generic (recovery mode) 2 : 5.4.0-99-generic 3 : 5.4.0-99-generic (recovery mode)
Configure it so that the most recent kernel version can be selected as the default when booting.
root@ubuntu2004:~# sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/g' /etc/default/grub root@ubuntu2004:~# grep "GRUB_DEFAULT" /etc/default/grub GRUB_DEFAULT=saved root@ubuntu2004:~# grub-set-default "Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-167-generic" root@ubuntu2004:~# grub-editenv list saved_entry=Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-167-generic root@ubuntu2004:~# update-grub Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-167-generic Found initrd image: /boot/initrd.img-5.4.0-167-generic Found linux image: /boot/vmlinuz-5.4.0-99-generic Found initrd image: /boot/initrd.img-5.4.0-99-generic done
Reboot the server to activate the latest kernel version.
root@ubuntu2004:~# reboot
NoteIf the server reboot fails, it means the kernel update was not performed normally. In this case, see Restore kernel update to revert to the previous kernel version.
Log in to the server again and check if the new kernel is activated.
root@ubuntu2004:~# uname -r 5.4.0-167-generic
NoteTo check if the updated kernel is properly applied, see Checking kernel updates to check the kernel installation status.
Check kernel update
To check if the kernel update is applied normally, follow these steps:
- Connect to the server remotely.
- Check if the kernel package is installed.
root@ubuntu2004:~# dpkg -l | grep linux-image-5.4.0-167-generic ii linux-image-5.4.0-167-generic 5.4.0-167.184 amd64 Signed kernel image generic
- Check if the initramfs file and vmlinuz file are created in the /boot directory.
root@ubuntu2004:~# ls -l /boot/initrd.img-5.4.0-167-generic -rw-r--r-- 1 root root 33241845 Dec 6 14:50 /boot/initrd.img-5.4.0-167-generic root@ubuntu2004:~# ls -l /boot/vmlinuz-5.4.0-167-generic -rw------- 1 root root 13677320 Oct 31 18:07 /boot/vmlinuz-5.4.0-167-generic
- Check if the latest kernel settings are registered in the grub.cfg file.
root@ubuntu2004:~# awk -F"--class" '/menuentry/ && /with Linux/ {print $1}' /boot/grub/grub.cfg | awk '{print i++ " : " $5,$6,$7,$8}' | sed -e "s/'/ /g" 0 : 5.4.0-167-generic 1 : 5.4.0-167-generic (recovery mode) 2 : 5.4.0-99-generic 3 : 5.4.0-99-generic (recovery mode)
Restore kernel update
If you can't restart the server normally after a kernel update, you need to revert to the previous kernel before the update.
You can revert it to one of the many installed kernel versions. This guide deals with how to revert the kernel to the version immediately before the update.
To restore the kernel version, follow these steps:
To resolve server restart issues, you can attempt server recovery by entering single mode. For how to run reboot in Single Mode, see Server recovery guide.
- Click the environment you are using in the Region menu and the Platform menu on the NAVER Cloud Platform console.
- Click Services > Compute > Server, in order.
- Click the Server menu.
- Select the server to recover from the server image list, and then click the [Server connection console] button.
- Select the previous version as the booting kernel from the grub booting page and reboot.
Ubuntu 20.04 grub boot page
- After booting is complete, check the kernel version of the server.
root@ubuntu2004:~# uname -r 5.4.0-99-generic
- Check the kernel version that is currently active.
root@ubuntu2004:~# awk -F"--class" '/menuentry/ && /with Linux/ {print $1}' /boot/grub/grub.cfg | awk '{print i++ " : " $5,$6,$7,$8}' | sed -e "s/'/ /g" 0 : 5.4.0-167-generic 1 : 5.4.0-167-generic (recovery mode) 2 : 5.4.0-99-generic 3 : 5.4.0-99-generic (recovery mode)
- Reset the default kernel version to the previous kernel version when booting.
root@ubuntu2004:~# sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/g' /etc/default/grub root@ubuntu2004:~# grep "GRUB_DEFAULT" /etc/default/grub GRUB_DEFAULT=saved root@ubuntu2004:~# grub-set-default "Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-99-generic" root@ubuntu2004:~# grub-editenv list saved_entry=Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-99-generic root@ubuntu2004:~# update-grub Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-167-generic Found initrd image: /boot/initrd.img-5.4.0-167-generic Found linux image: /boot/vmlinuz-5.4.0-99-generic Found initrd image: /boot/initrd.img-5.4.0-99-generic done
- (Optional) Reboot the server to check whether the server boots up normally with the updated kernel version.
root@ubuntu2004:~# reboot
- (Optional) Log back into the server to check the booting status and the kernel version.
root@ubuntu2004:~# uname -r 5.4.0-99-generic