問題:
執行更新命令apt-get update時,出現No space left on device:
cannot copy extracted data for './boot/vmlinuz-4.4.0-116-generic' to
'/boot/vmlinuz-4.4.0-116-generic.dpkg-new': failed to write (No space left on device)
分析:
因爲我們經常更新,但是在安裝系統的時候,boot空間設置太小,就會導致boot空間不足了,導致更新失敗;最好是在裝系統的時候將boot設置大一點,搞個兩三個G。
解決方案:
1、打開終端,輸入:
sudo df -h /boot
查看boot有多少內存,使用了多少。
2、查看目前系統中安裝的內核鏡像,如圖所示
sudo dpkg --get-selections |grep linux-image
3、查看目前系統所使用的內核鏡像,如圖所示,我係統使用的是4.15.0-60
sudo uname -r
4、除了自己使用的鏡像,其餘的鏡像都是多餘的,手動刪除。
sudo apt-get remove linux-image-4.15.0-62-generic
如果成功就繼續把所有的刪除。若是不成功,出現如下錯誤:
這個錯誤說明,你要卸載linux-image-4.15.0-62-generic,必須先卸載他所依賴的文件,如linux-image-generic-hwe-16.04、linux-modules-extra-4.15.0-62-generic;
然後....
5、把所有依賴都刪除,刪除出現什麼依賴,就把依賴添加在刪除命名的後面,一直到出現如圖所示結果,就刪除成功。
我這裏是使用下面這個命令:
sudo apt-get remove linux-image-4.15.0-62-generic linux-modules-extra-4.15.0-62-generic linux-modules-extra-4.15.0-72-generic linux-image-generic-hwe-16.04 linux-generic-hwe-16.04 linux-signed-generic-hwe-16.04
6、我這裏下面命令把所有的多餘鏡像刪除了,把鏡像名字放在刪除後面就行
sudo apt-get purge linux-image-4.15.0-50-generic linux-image-4.15.0-51-generic linux-image-4.15.0-52-generic linux-image-4.15.0-54-generic linux-image-4.15.0-55-generic linux-image-4.15.0-58-generic linux-image-4.15.0-62-generic
這裏 注意,使用sudo apt-get purge 與使用sudo apt-get remove 命令刪除,結果是不一樣的。
使用remove命令會保留相應的配置文件,所以apt-get remove命令後還會有deinstall文件,但還是已經刪除了。
使用purge將包括配置文件在內的內容一起刪除,推薦這個。
7、檢查
dpkg --get-selections |grep linux-image
df -h /boot
就可以看到是否有沒有刪除完,