Ubuntu系統---系統驅動丟失、Kernel內核卸載、禁止更新


Ubuntu系統---系統驅動丟失、Kernel內核卸載、禁止更新

  一早開機發現,ubuntu字體異常,字體很大,直接反應是驅動壞了。一查,確實丟失英偉達驅動,為什么呢?莫名的消失。想知道:1.英偉達驅動丟失的原因?2.如何解決和避免?

  上次,英偉達驅動出現問題,是循環在登陸界面。這次,英偉達驅動丟失,是內核升級了,不知道何時自動升級了,導致內核和驅動不兼容。

  摘至網絡資源:”一般在運行apt upgrade時會自動更新Linux內核,但是有些時候更新內核后會出現驅動程序不兼容的情況
我們可以使用以下命令降級內核:設置為hold狀態的軟件包,對於 apt upgrade 命令不會升級,但是依然可以通過 apt install 命令將其升級並將其狀態切換到install。因此,從安全性角度看,這樣做其實效果不大,僅僅是避免了偶然的操作失誤。本人還是推薦使用 apt install 來進行“定點升級”。
考慮到這個問題可能是因為ubuntu的自動更新造成的,於是重新啟動,在啟動界面選擇“ubuntu 高級選項”后,發現有兩個內核,並且系統默認從新內核啟動,選擇舊內核啟動后順利進入桌面。其實可以選擇更改內核啟動順序來解決這個問題,但我選擇直接刪除新內核。該方法同樣適用於卸載系統中無用的舊內核。”

  最后:1.英偉達驅動丟失的原因?內核與驅動不匹配   2.如何解決和避免? 可以有的解決方式 重新裝驅動 或 降低內核 或 選擇匹配的內核,這里卸載內核並禁止更新,希望以后不要再出現錯誤。后附,解決問題時候些許筆記。

一、幾個常用命令

1.查看ubuntu版本號:
方法一:
cat /etc/issue
 
方法二:
sudo lsb_release -a

方法三:
 cat /etc/lsb-release

2.查看內核版本號:
方法一:
cat /proc/version
 
方法二:查看系統當前的內核版本
uname -a
 
方法三:僅僅查看內核版本
uname -r

方法四:查看系統安裝的所有內核版本
sudo dpkg --get-selections | grep linux

3、刪除內核
較新內核的版本為4.13.0-36,使用以下命令刪除該內核:
sudo apt-get purge linux-headers-x.x.x-x linux-image-x.x.x-x-generic

刪除舊內核
sudo apt-get remove linux-image-x.x.x-x-generic
sudo apt-get remove linux-image-extra-x.x.x-x-generic  

或用這個命令移除
sudo dpkg --purge linux-image-x.x.x-x-generic

4、使用以下命令解除阻止:
sudo apt-mark unhold linux-image-generic linux-headers-generic
sudo apt update

5、更新grub
sudo update-grub

 

二、查看詳細問題

u@u1604:~$ sudo dpkg --get-selections  |  grep  'linux'
[sudo] u 的密碼:
console-setup-linux                install
libselinux1:amd64                install
linux-base                    install
linux-firmware                    install
linux-generic-hwe-16.04                install
linux-headers-4.15.0-29                install
linux-headers-4.15.0-29-generic            install
linux-headers-4.15.0-55                install
linux-headers-4.15.0-55-generic            install
linux-headers-4.15.0-58                install
linux-headers-4.15.0-58-generic            install
linux-headers-generic-hwe-16.04            install
linux-image-4.15.0-29-generic            install
linux-image-4.15.0-55-generic            install
linux-image-4.15.0-58-generic            install
linux-image-generic-hwe-16.04            install
linux-libc-dev:amd64                install
linux-modules-4.15.0-29-generic            install
linux-modules-4.15.0-55-generic            install
linux-modules-4.15.0-58-generic            install
linux-modules-extra-4.15.0-29-generic        install
linux-modules-extra-4.15.0-55-generic        install
linux-modules-extra-4.15.0-58-generic        install
linux-signed-generic-hwe-16.04            install
linux-sound-base                install
pptp-linux                    install
syslinux                    install
syslinux-common                    install
syslinux-legacy                    install
util-linux                    install
u@u1604:~$ 


先卸載headers。
sudo apt-get purge linux-headers-4.15.0-58
sudo apt-get purge linux-headers-4.15.0-58-generic

接着卸載image。
sudo apt-get purge linux-image-4.15.0-58-generic
sudo apt-get purge linux-modules-4.15.0-58-generic
sudo apt-get purge linux-modules-extra-4.15.0-58-generic

或者:
sudo apt-get purge linux-headers-4.15.0-58 \
linux-headers-4.15.0-58-generic \
linux-image-4.15.0-58-generic \
linux-modules-4.15.0-58-generic \
linux-modules-extra-4.15.0-58-generic

更新grub引導。
sudo update-grub

u@u1604:~$ sudo apt-get purge linux-headers-4.15.0-58 \
> linux-headers-4.15.0-58-generic \
> linux-image-4.15.0-58-generic \
> linux-modules-4.15.0-58-generic \
> linux-modules-extra-4.15.0-58-generic
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹       
正在讀取狀態信息... 完成       
下列軟件包是自動安裝的並且現在不需要了:
  amd64-microcode intel-microcode iucode-tool linux-image-4.15.0-29-generic
  linux-modules-4.15.0-29-generic linux-modules-extra-4.15.0-29-generic
  thermald
使用'sudo apt autoremove'來卸載它(它們)。
下列軟件包將被【卸載】:
  linux-generic-hwe-16.04* linux-headers-4.15.0-58*
  linux-headers-4.15.0-58-generic* linux-headers-generic-hwe-16.04*
  linux-image-4.15.0-58-generic* linux-image-generic-hwe-16.04*
  linux-modules-4.15.0-58-generic* linux-modules-extra-4.15.0-58-generic*
  linux-signed-generic-hwe-16.04*
升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 9 個軟件包,有 119 個軟件包未被升級。
解壓縮后將會空出 334 MB 的空間。
您希望繼續執行嗎? [Y/n]
(正在讀取數據庫 ... 系統當前共安裝有 273212 個文件和目錄。)
正在卸載 linux-signed-generic-hwe-16.04 (4.15.0.58.79) ...
正在卸載 linux-generic-hwe-16.04 (4.15.0.58.79) ...
正在卸載 linux-headers-generic-hwe-16.04 (4.15.0.58.79) ...
正在卸載 linux-headers-4.15.0-58-generic (4.15.0-58.64~16.04.1) ...
正在卸載 linux-headers-4.15.0-58 (4.15.0-58.64~16.04.1) ...
正在卸載 linux-image-generic-hwe-16.04 (4.15.0.58.79) ...
正在卸載 linux-modules-extra-4.15.0-58-generic (4.15.0-58.64~16.04.1) ...
正在清除 linux-modules-extra-4.15.0-58-generic (4.15.0-58.64~16.04.1) 的配置文件 ...
正在卸載 linux-image-4.15.0-58-generic (4.15.0-58.64~16.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.15.0-29-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.15.0-29-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-4.15.0-55-generic
I: /initrd.img is now a symlink to boot/initrd.img-4.15.0-55-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-58-generic
/etc/kernel/postrm.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-55-generic
Found initrd image: /boot/initrd.img-4.15.0-55-generic
Found linux image: /boot/vmlinuz-4.15.0-29-generic
Found initrd image: /boot/initrd.img-4.15.0-29-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Windows Boot Manager on /dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi
Found Ubuntu 18.04.2 LTS (18.04) on /dev/sda7
Adding boot menu entry for EFI firmware configuration
done
正在清除 linux-image-4.15.0-58-generic (4.15.0-58.64~16.04.1) 的配置文件 ...
rmdir: 刪除 '/lib/modules/4.15.0-58-generic' 失敗: 目錄非空
正在卸載 linux-modules-4.15.0-58-generic (4.15.0-58.64~16.04.1) ...
正在清除 linux-modules-4.15.0-58-generic (4.15.0-58.64~16.04.1) 的配置文件 ...
u@u1604:~$ 

再次,查看當前信息:

u@u1604:~$ sudo dpkg --get-selections | grep 'linux'
console-setup-linux                install
libselinux1:amd64                install
linux-base                    install
linux-firmware                    install
linux-headers-4.15.0-29                install
linux-headers-4.15.0-29-generic            install
linux-headers-4.15.0-55                install
linux-headers-4.15.0-55-generic            install
linux-image-4.15.0-29-generic            install
linux-image-4.15.0-55-generic            install
linux-libc-dev:amd64                install
linux-modules-4.15.0-29-generic            install
linux-modules-4.15.0-55-generic            install
linux-modules-extra-4.15.0-29-generic        install
linux-modules-extra-4.15.0-55-generic        install
linux-sound-base                install
pptp-linux                    install
syslinux                    install
syslinux-common                    install
syslinux-legacy                    install
util-linux                    install
u@u1604:~$ 

禁止內核更新

sudo apt-mark hold linux-headers-4.15.0-55 \
linux-headers-4.15.0-55-generic \
linux-image-4.15.0-55-generic \
linux-modules-4.15.0-55-generic \
linux-modules-extra-4.15.0-55-generic

echo "linux-headers-4.15.0-55 hold" | dpkg --set-selections
echo "linux-headers-4.15.0-55-generic hold" | dpkg --set-selections
echo "linux-image-4.15.0-55-generic hold" | dpkg --set-selections
echo "linux-modules-4.15.0-55-generic hold" | dpkg --set-selections
echo "linux-modules-extra-4.15.0-55-generic hold" | dpkg --set-selections

u@u1604:~$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-55-generic
Found initrd image: /boot/initrd.img-4.15.0-55-generic
Found linux image: /boot/vmlinuz-4.15.0-29-generic
Found initrd image: /boot/initrd.img-4.15.0-29-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Windows Boot Manager on /dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi
Found Ubuntu 18.04.2 LTS (18.04) on /dev/sda7
Adding boot menu entry for EFI firmware configuration
done
u@u1604:~$


打開終端執行以下命令:
lspci | grep VGA     # 查看集成顯卡
lspci | grep NVIDIA  # 查看NVIDIA顯卡

NVIDIA提供了一個切換顯卡的命令:
sudo prime-select nvidia # 切換nvidia顯卡
sudo prime-select intel  # 切換intel顯卡
sudo prime-select query  # 查看當前使用的顯卡

linux內核鏡像包含的包
    linux-image : 內核鏡像
    linux-image-extra : 額外的內核模塊
    linux-headers : 內核文件

 

 

參考並感謝:
Linux安裝NVIDIA顯卡驅動的正確姿勢@https://blog.csdn.net/wf19930209/article/details/81877822
Linux內核卸載和禁止更新@https://blog.csdn.net/qq_40829288/article/details/96672970
如何阻止apt更新Linux內核@https://blog.csdn.net/yyws2039725/article/details/90999447
禁止ubuntu更新內核@https://www.cnblogs.com/medsci/p/8338170.html
Linux禁止內核更新@https://blog.csdn.net/liuwinner/article/details/91043386
Ubuntu刪除多余內核@https://www.jianshu.com/p/f284bc90944f
ubuntu16.04 刪除內核@https://www.cnblogs.com/sench/p/8567819.html
ubuntu16.04卸載自己安裝的linux內核@https://jingyan.baidu.com/article/ff42efa9cdebecc19f220240.html

****《ubuntu18.04 內核自動更新導致驅動掉了》,考慮了一下是不是內核的問題,試了一下重啟電腦選擇低版本的內核,好用@https://blog.csdn.net/qq_43222384/article/details/90314297
****Ubuntu設置默認內核啟動版本,圖文@https://blog.csdn.net/SweeNeil/article/details/87937269
禁止ubuntu更新內核@https://blog.csdn.net/weixin_40522162/article/details/80302735
ubuntu不同版本的內核與顯卡驅動兼容問題@https://blog.csdn.net/chenhezhuyan/article/details/23453217
ubuntu內核與驅動不兼容問題@https://blog.csdn.net/chaihuimin/article/details/71083397,將Ubuntu NVIDIA驅動卸載再重新安裝即可
Ubuntu下默認更新內核或更新NVIDIA顯卡驅動導致的重啟無法進入操作系統@https://blog.csdn.net/huang98778/article/details/89922052
最全面解析 Ubuntu 16.04 安裝nvidia驅動以及各種錯誤,進入blos關閉secure boot (華碩還有fast boot),否則無法安裝
成功@https://blog.csdn.net/u014561933/article/details/79958017
Ubuntu16.04下安裝顯卡驅動+內核記錄,@https://www.cnblogs.com/myblog1993/p/9284071.html
ubuntu循環登錄問題的解決,@https://www.cnblogs.com/talugirl/p/5870875.html
Ubuntu16.04安裝NVIDIA驅動時的一些坑與解決方案:一、循環登錄;二、重啟黑屏;三、驅動不工作@https://www.cnblogs.com/matthewli/p/6715553.html
[詭異現象] 開機進ubuntu系統莫名驅動丟失@https://blog.csdn.net/mcmggradty/article/details/43129351
ubuntu突然顯卡消失,主要原因是ubuntu的內核發生改變,可能安裝環境和軟件的時候,系統內核也更新了@https://blog.csdn.net/zz2230633069/article/details/90553810
ubuntu16.04掉顯卡驅動解決方法@https://blog.csdn.net/xiaohuhu11/article/details/90339697
ubuntu16.0.4 顯卡驅動崩掉,如何重裝@https://blog.csdn.net/u011345885/article/details/77329371

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM