Thursday, November 21, 2024

Debian升级kernel

本文介绍Debian 9更新Linux内核。

一、通过更新源自动升级kernel

修改更新源

sudo sh -c 'echo -e "deb http://http.debian.net/debian stretch-backports main\ndeb-src http://http.debian.net/debian stretch-backports main" > /etc/apt/sources.list.d/sources.list.bak'

更新package

sudo apt-get update
sudo apt-get dist-upgrade

安装新版内核镜像

sudo apt-cache search linux-image
linux-headers-4.9.0-3-amd64 - Header files for Linux 4.9.0-3-amd64
linux-headers-4.9.0-3-rt-amd64 - Header files for Linux 4.9.0-3-rt-amd64
linux-image-4.9.0-3-amd64 - Linux 4.9 for 64-bit PCs
linux-image-4.9.0-3-amd64-dbg - Debug symbols for linux-image-4.9.0-3-amd64
linux-image-4.9.0-3-rt-amd64 - Linux 4.9 for 64-bit PCs, PREEMPT_RT
linux-image-4.9.0-3-rt-amd64-dbg - Debug symbols for linux-image-4.9.0-3-rt-amd64
linux-image-amd64 - Linux for 64-bit PCs (meta-package)
linux-image-amd64-dbg - Debugging symbols for Linux amd64 configuration (meta-package)
linux-image-rt-amd64 - Linux for 64-bit PCs (meta-package), PREEMPT_RT
linux-image-rt-amd64-dbg - Debugging symbols for Linux rt-amd64 configuration (meta-package)
linux-headers-4.11.0-0.bpo.1-amd64 - Header files for Linux 4.11.0-0.bpo.1-amd64
linux-headers-4.11.0-0.bpo.1-rt-amd64 - Header files for Linux 4.11.0-0.bpo.1-rt-amd64
linux-image-4.11.0-0.bpo.1-amd64 - Linux 4.11 for 64-bit PCs
linux-image-4.11.0-0.bpo.1-amd64-dbg - Debug symbols for linux-image-4.11.0-0.bpo.1-amd64
linux-image-4.11.0-0.bpo.1-rt-amd64 - Linux 4.11 for 64-bit PCs, PREEMPT_RT
linux-image-4.11.0-0.bpo.1-rt-amd64-dbg - Debug symbols for linux-image-4.11.0-0.bpo.1-rt-amd64
sudo apt-get install -t stretch-backports linux-image-amd64

重启系统

sudo update-grub
sudo apt-get clean
sudo reboot

检查下,已经切到了新内核

uname -r
4.11.0-0.bpo.1-amd64

清理

sudo apt purge linux-image-4.12.6-041206-generic
sudo apt purge linux-image-4.9.0-3-amd64

二、手动升级kernel

mirrors.kernel.org 上直接下载deb包,比如当前最新版本为 4.18.20 :

wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-image-4.18.0-3-amd64_4.18.20-2_amd64.deb
wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-kbuild-4.18_4.18.20-2_amd64.deb
wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-headers-4.18.0-3-common_4.18.20-2_all.deb
wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-headers-4.18.0-3-amd64_4.18.20-2_amd64.deb
wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-headers-4.18.0-3-all-amd64_4.18.20-2_amd64.deb
wget http://mirrors.kernel.org/debian/pool/main/l/linux/linux-headers-4.18.0-3-all_4.18.20-2_amd64.deb

sudo dpkg -i linux-*.deb

查看新安装的内核

dpkg -l | grep linux

重启系统

sudo update-grub
sudo apt-get clean
sudo reboot

检查下,已经切到了新内核

uname -r
4.18.20-2_amd64

清理

sudo apt purge linux-image-4.18.0-3-amd64

参考文章:https://josta.me/blog/201708/debian_9_upgrade_kernel/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.