Ubuntu 升级 kernel 至 5.13.11(5.15.10)

借鉴

最新的 release 版本

kernel 的种类说明

警告

⚠升级有风险,先备份数据以防万一。但用一台虚拟机来折腾升级的过程,这个风险还是能够承受滴,再则,升级失败了,大不了回滚之前的版本呗。

现在的版本

现在的 grub 是这样子滴。

Ubuntu 升级 kernel 至 5.13.11(5.15.10)_第1张图片

ubuntu: 20.04.2

kernel:  5.4.0

node8:~$ uname -r
5.4.0-81-generic
node8:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

升级

下载需要的 deb 文件

这里可以按需选择升级的版本,这里选择升级至 5.13.11

node8:~$ mkdir kernel-5.13.11
node8:~$ cd kernel-5.13.11
node8:~/kernel-5.13.11$ wget -q https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.13.11/amd64/linux-headers-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb
node8:~/kernel-5.13.11$ wget -q https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.13.11/amd64/linux-headers-5.13.11-051311_5.13.11-051311.202108151332_all.deb
node8:~/kernel-5.13.11$ wget -q https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.13.11/amd64/linux-image-unsigned-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb
node8:~/kernel-5.13.11$ wget -q https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.13.11/amd64/linux-modules-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb
node8:~/kernel-5.13.11$ wget -q https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.13.11/amd64/CHECKSUMS
### check 一下,万一下载过程中,文件下偏了呢?
node8:~/kernel-5.13.11$ shasum -c CHECKSUMS
linux-headers-5.13.11-051311_5.13.11-051311.202108151332_all.deb: OK
linux-headers-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-headers-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-headers-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
linux-image-unsigned-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-image-unsigned-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-image-unsigned-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
linux-modules-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-modules-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-modules-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
linux-headers-5.13.11-051311_5.13.11-051311.202108151332_all.deb: OK
linux-headers-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-headers-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-headers-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
linux-image-unsigned-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-image-unsigned-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-image-unsigned-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
linux-modules-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb: OK
shasum: linux-modules-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: No such file or directory
linux-modules-5.13.11-051311-lowlatency_5.13.11-051311.202108151332_amd64.deb: FAILED open or read
shasum: WARNING: 6 listed files could not be read

安装

用 dpkg 命令安装准备好的 deb 包,安?过分了撒,我就升级一个 kernel,居然出错了。系统的 libc6==2.31-0ubuntu9.2 还满足不了依赖,还需要 >= 2.33

node8:~/kernel-5.13.11$ sudo dpkg -i *.deb
Selecting previously unselected package linux-headers-5.13.11-051311.
(Reading database ... 108176 files and directories currently installed.)
Preparing to unpack linux-headers-5.13.11-051311_5.13.11-051311.202108151332_all.deb ...
Unpacking linux-headers-5.13.11-051311 (5.13.11-051311.202108151332) ...
Selecting previously unselected package linux-headers-5.13.11-051311-generic.
Preparing to unpack linux-headers-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-headers-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Selecting previously unselected package linux-image-unsigned-5.13.11-051311-generic.
Preparing to unpack linux-image-unsigned-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Selecting previously unselected package linux-modules-5.13.11-051311-generic.
Preparing to unpack linux-modules-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-modules-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Setting up linux-headers-5.13.11-051311 (5.13.11-051311.202108151332) ...
dpkg: dependency problems prevent configuration of linux-headers-5.13.11-051311-generic:
 linux-headers-5.13.11-051311-generic depends on libc6 (>= 2.33); however:
  Version of libc6:amd64 on system is 2.31-0ubuntu9.2.

dpkg: error processing package linux-headers-5.13.11-051311-generic (--install):
 dependency problems - leaving unconfigured
Setting up linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.4.0-84-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.4.0-84-generic
I: /boot/vmlinuz is now a symlink to vmlinuz-5.13.11-051311-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.13.11-051311-generic
Setting up linux-modules-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Processing triggers for linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.11-051311-generic
/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.13.11-051311-generic
Found initrd image: /boot/initrd.img-5.13.11-051311-generic
Found linux image: /boot/vmlinuz-5.4.0-84-generic
Found initrd image: /boot/initrd.img-5.4.0-84-generic
Found linux image: /boot/vmlinuz-5.4.0-81-generic
Found initrd image: /boot/initrd.img-5.4.0-81-generic
done
Errors were encountered while processing:
 linux-headers-5.13.11-051311-generic

升级 libc6 至 2.33

哎,算你狠,惹不起,我升级得了。

相关的 deb 都在这里 ,打开网站,自寻搜索下载。

我。。。 libc6 2.33 又需要 locales 2.33???

node8:~/kernel-5.13.11$ mkdir libc6-2.33
node8:~/kernel-5.13.11$ cd libc6-2.33
node8:~/kernel-5.13.11/libc6-2.33$ wget -q http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.33-0ubuntu5_amd64.deb
node8:~/kernel-5.13.11/libc6-2.33$ sudo dpkg -i libc6_2.33-0ubuntu5_amd64.deb
dpkg: regarding libc6_2.33-0ubuntu5_amd64.deb containing libc6:amd64:
 libc6:amd64 breaks locales (<< 2.33)
  locales (version 2.31-0ubuntu9.2) is present and installed.

dpkg: error processing archive libc6_2.33-0ubuntu5_amd64.deb (--install):
 installing libc6:amd64 would break locales, and
 deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
 libc6_2.33-0ubuntu5_amd64.deb

node8:~/kernel-5.13.11/libc6-2.33$ dpkg -l | grep locales
ii  krb5-locales                                1.17-6ubuntu4.1                   all          internationalization support for MIT Kerberos
ii  locales                                     2.31-0ubuntu9.2                   all          GNU C Library: National Language (locale) data [support]
ii  python-apt-common                           2.0.0ubuntu0.20.04.4              all          Python interface to libapt-pkg (locales)
node8:~/kernel-5.13.11/libc6-2.33$ dpkg -l | grep 2.31-0ubuntu9.2
ii  libc-bin                                    2.31-0ubuntu9.2                   amd64        GNU C Library: Binaries
ii  libc6:amd64                                 2.31-0ubuntu9.2                   amd64        GNU C Library: Shared libraries
ii  locales                                     2.31-0ubuntu9.2                   all          GNU C Library: National Language (locale) data [support]

要不然咱把 libc-bin libc6 和 locales 都升级试试?

PS, 在 sudo dpkg --auto-deconfigure -i *.deb 会出现一个交互式的选项, yes 即可。

Ubuntu 升级 kernel 至 5.13.11(5.15.10)_第2张图片

node8:~/kernel-5.13.11/libc6-2.33$ wget -q http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-bin_2.33-0ubuntu5_amd64.deb
node8:~/kernel-5.13.11/libc6-2.33$ wget -q http://ports.ubuntu.com/pool/main/g/glibc/locales_2.33-0ubuntu5_all.deb
node8:~/kernel-5.13.11/libc6-2.33$ ls
libc6_2.33-0ubuntu5_amd64.deb  libc-bin_2.33-0ubuntu5_amd64.deb  locales_2.33-0ubuntu5_all.deb
node8:~/kernel-5.13.11/libc6-2.33$ sudo dpkg --auto-deconfigure -i *.deb
dpkg: considering deconfiguration of locales, which would be broken by installation of libc6:amd64 ...
dpkg: yes, will deconfigure locales (broken by libc6:amd64)
(Reading database ... 143051 files and directories currently installed.)
Preparing to unpack libc6_2.33-0ubuntu5_amd64.deb ...
De-configuring locales (2.31-0ubuntu9.2) ...
Checking for services that may need to be restarted...
Checking init scripts...
Checking for services that may need to be restarted...
Checking init scripts...
Stopping some services possibly affected by the upgrade (will be restarted later):
  cron: stopping...done.

Unpacking libc6:amd64 (2.33-0ubuntu5) over (2.31-0ubuntu9.2) ...
Preparing to unpack libc-bin_2.33-0ubuntu5_amd64.deb ...
Unpacking libc-bin (2.33-0ubuntu5) over (2.31-0ubuntu9.2) ...
Preparing to unpack locales_2.33-0ubuntu5_all.deb ...
Unpacking locales (2.33-0ubuntu5) over (2.31-0ubuntu9.2) ...
Setting up libc6:amd64 (2.33-0ubuntu5) ...
Checking for services that may need to be restarted...
Checking init scripts...
Restarting services possibly affected by the upgrade:
  cron: restarting...done.
  atd: restarting...done.

Services restarted successfully.
Setting up libc-bin (2.33-0ubuntu5) ...
Setting up locales (2.33-0ubuntu5) ...
Installing new version of config file /etc/locale.alias ...
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
Processing triggers for man-db (2.9.1-1) ...

  再次安装 kernel

这一次看起来一切顺利。

node8:~/kernel-5.13.11/libc6-2.33$ cd ..
node8:~/kernel-5.13.11$ sudo dpkg -i *.deb
(Reading database ... 143047 files and directories currently installed.)
Preparing to unpack linux-headers-5.13.11-051311_5.13.11-051311.202108151332_all.deb ...
Unpacking linux-headers-5.13.11-051311 (5.13.11-051311.202108151332) over (5.13.11-051311.202108151332) ...
Preparing to unpack linux-headers-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-headers-5.13.11-051311-generic (5.13.11-051311.202108151332) over (5.13.11-051311.202108151332) ...
Preparing to unpack linux-image-unsigned-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) over (5.13.11-051311.202108151332) ...
Preparing to unpack linux-modules-5.13.11-051311-generic_5.13.11-051311.202108151332_amd64.deb ...
Unpacking linux-modules-5.13.11-051311-generic (5.13.11-051311.202108151332) over (5.13.11-051311.202108151332) ...
Setting up linux-headers-5.13.11-051311 (5.13.11-051311.202108151332) ...
Setting up linux-headers-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Setting up linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Setting up linux-modules-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
Processing triggers for linux-image-unsigned-5.13.11-051311-generic (5.13.11-051311.202108151332) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.11-051311-generic
/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.13.11-051311-generic
Found initrd image: /boot/initrd.img-5.13.11-051311-generic
Found linux image: /boot/vmlinuz-5.4.0-84-generic
Found initrd image: /boot/initrd.img-5.4.0-84-generic
Found linux image: /boot/vmlinuz-5.4.0-81-generic
Found initrd image: /boot/initrd.img-5.4.0-81-generic
done

验证

这一次,grub 这样了,但何时多出了 5.4.0-84 ?

Ubuntu 升级 kernel 至 5.13.11(5.15.10)_第3张图片

哈哈,成功了,kernel 已经从 5.4.0 变成了 5.13.11 了 

node8:~$ uname -r
5.13.11-051311-generic
node8:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

 后悔药

后悔了,不想要新 kernel 了,就想回到 5.4.0,也不想每次启动的时候修改 grub,怎么办?哎,天下哪有后悔药给你呢?但还是抱着希望试试呗。

### 重启系统,让我们回到 5.4.0 的 kernel
node8:~$ uname -r
5.4.0-84-generic
### 移除 5.13.11 相关的 headers、image 和 modules
node8:~$ sudo apt remove linux-headers-5.13.11* -y
node8:~$ sudo apt remove linux-image-unsigned-5.13.11* -y
node8:~$ sudo apt remove linux-modules-5.13.11* -y

升级到 5.15.10

当前版本

# 现在的版本
# uname -r
5.4.0-91-generic

# cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

下载 deb 包

### 这里比较粗了
### https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.5.10/
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.5.10/linux-headers-5.5.10-050510_5.5.10-050510.202003180732_all.deb
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.5.10/linux-headers-5.5.10-050510-generic_5.5.10-050510.202003180732_amd64.deb
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.5.10/linux-image-unsigned-5.5.10-050510-generic_5.5.10-050510.202003180732_amd64.deb
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.5.10/linux-modules-5.5.10-050510-generic_5.5.10-050510.202003180732_amd64.deb
### https://ubuntu.pkgs.org/
# wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-bin_2.34-0ubuntu3_amd64.deb
# wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/locales_2.34-0ubuntu3_all.deb
# wget http://archive.ubuntu.com/ubuntu/pool/main/n/nspr/libnspr4_4.32-1_amd64.deb
# wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.34-0ubuntu3_amd64.deb
### https://packages.ubuntu.com/jammy/amd64/libssl3/download
# wget http://mirrors.kernel.org/ubuntu/pool/main/o/openssl/libssl3_3.0.0-1ubuntu1_amd64.deb 

安装 kernel

### 可能会存在依赖的错误,错了就再来一次呗
# DEBIAN_FRONTEND=noninteractive dpkg -i *.deb
......
Errors were encountered while processing:
 libc6_2.34-0ubuntu3_amd64.deb
 libc-bin
 libnspr4:amd64
 libssl3:amd64
 locales
......
# DEBIAN_FRONTEND=noninteractive dpkg -i *.deb
......
/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.5.10-050510-generic
Found initrd image: /boot/initrd.img-5.5.10-050510-generic
Found linux image: /boot/vmlinuz-5.4.0-91-generic
Found initrd image: /boot/initrd.img-5.4.0-91-generic
done
......
### 重启验证
# reboot

验明正身

# cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
# uname -r
5.15.10-051510-generic

你可能感兴趣的:(ubuntu,linux,kernel,运维)