服务器重启后由于自动更新内核导致Nvidia失效

服务器重启后由于自动更新内核导致Nvidia失效

linux指令集

//查看当前操作系统版本
lsb_release -a
// 查看当前正在使用的内核
uname -r
uname -a
// 查看ubuntu系统内核启动顺序
grep menuentry /boot/grub/grub.cfg
// 显示系统已安装的内核
dpkg --get-selections | grep linux-image
dpkg --get-selections | grep linux-header

dpkg -l | grep linux-image
// 修改系统启动默认内核
sudo vim /etc/default/grub
// 更新grup引导文件
sudo update-grub
// 搜索可用内核
sudo apt search linux-image
// 下载linux内核
sudo apt install xxx
// 卸载linux内核
sudo apt-get purge xxx

回退旧内核步骤

服务器更新后由于内核升级导致与Nvidia版本不匹配,使得Nvidia失效,因此需要将linux内核回退到旧版本。
首先查看当前使用的linux内核版本以及安装了的内核,从中找到所需回退的版本,要求已安装。

1 | uname -r
//Linux t43 5.11.0-41-generic #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux	
//内核版本为5.11.0-41-generic

//uname -r
//5.11.0-41-generic

2 | dpkg --get-selections | grep linux-image
//linux-image-5.11.0-25-generic                   deinstall		deinstall表示内核已卸载
//linux-image-5.11.0-27-generic                   deinstall
//linux-image-5.11.0-34-generic                   deinstall
//linux-image-5.11.0-36-generic                   deinstall
//linux-image-5.11.0-37-generic                   deinstall
//linux-image-5.11.0-38-generic                   deinstall
//linux-image-5.11.0-40-generic                   install		install表示内核已安装
//linux-image-5.11.0-41-generic                   install
//linux-image-5.8.0-43-generic                    deinstall
//linux-image-5.8.0-50-generic                    install		假设该项为回退内核
//linux-image-5.8.0-55-generic                    deinstall
//linux-image-5.8.0-59-generic                    deinstall
//linux-image-5.8.0-63-generic                    deinstall
//linux-image-generic-hwe-20.04                   install

(可选)如果所需版本未安装,可手动下载

2.5 | sudo apt-get install linux-image-5.8.0-50-generic		

查看ubuntu系统的内核启动顺序

3 | grep menuentry /boot/grub/grub.cfg
//if [ x"${feature_menuentry_id}" = xy ]; then
//  menuentry_id_option="--id"
//  menuentry_id_option=""
//export menuentry_id_option
//menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-5fb3d19d-30fb-4407-a527-77012b39c097' {
//submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.11.0-41-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-41-generic-advanced-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.11.0-41-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-41-generic-recovery-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.11.0-40-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-40-generic-advanced-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.11.0-40-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.11.0-40-generic-recovery-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.8.0-50-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-50-generic-advanced-5fb3d19d-30fb-4407-a527-77012b39c097' {
//        menuentry 'Ubuntu, with Linux 5.8.0-50-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-50-generic-recovery-5fb3d19d-30fb-4407-a527-77012b39c097' {
//menuentry 'Memory test (memtest86+)' {
//menuentry 'Memory test (memtest86+, serial console 115200)' {

修改/etc/default/grub的默认引导配置

4 | sudo vim /etc/default/grub
//找到GRUB_DEFAULT,该项表示启动的默认内核

//修改该项为
5.1 | GRUB_DEFAULT=4	//5.8.0-50-generic内核为第五项
//或者
5.2 | GRUB_DEFAULT="Ubuntu, with Linux 5.8.0-50-generic"
//或者
5.3 | GRUB_DEFAULT="gnulinux-5.8.0-50-generic-advanced-5fb3d19d-30fb-4407-a527-77012b39c097"

更新引导配置

6 | sudo update-grub  

重启服务器

7 | sudo reboot  
上一篇:关于nvidia-smi


下一篇:总结20220110