[Linux] Ubuntu 20.04 upgrade 時遇到的問題

在每次做 apt upgrade 時,總是會出現以下類似以下的錯誤

  dpkg: error processing package linux-image-4.4.0-121-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-121-generic:
 linux-image-extra-4.4.0-121-generic depends on linux-image-4.4.0-121-generic; however:
  Package linux-image-4.4.0-121-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.4.0-121-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-4.4.0-121-generic; however:
  Package linux-image-4.4.0-121-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-4.4.0-121-generic; however:
  Package linux-image-extra-4.4.0-121-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 4.4.0.121.127); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
Setting up linux-image-4.4.0-108-generic (4.4.0-108.131) ...
Internal Error: Could not find image (/boot/vmlinuz-4.4.0-108-generic)
dpkg: error processing package linux-image-4.4.0-108-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-108-generic:
 linux-image-extra-4.4.0-108-generic depends on linux-image-4.4.0-108-generic; however:
  Package linux-image-4.4.0-108-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.4.0-108-generic (--configure):
 dependency problems - leaving unconfigured
Processing triggers for initramfs-tools (0.122ubuntu8.11) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-119-generic

gzip: stdout: No space left on device
E: mkinitramfs failure find 141 cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-119-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 linux-image-4.4.0-121-generic
 linux-image-extra-4.4.0-121-generic
 linux-image-generic
 linux-generic
 linux-image-4.4.0-108-generic
 linux-image-extra-4.4.0-108-generic
 initramfs-tools
  
仔細查了一下,發現有人提供解法

sudo rm -f /var/lib/dpkg/info/initramfs-tools.post*

sudo rm -f /var/lib/dpkg/info/initramfs-tools.pre*

sudo rm -f /var/lib/dpkg/info/bcmwl-kernel-source.post*
sudo rm -f /var/lib/dpkg/info/bcmwl-kernel-source.pre*

sudo dpkg --configure -a
  
但還是會失敗,結果找到這篇
發現問題竟然是 /boot 竟然 100% 滿了!!

這樣問題就簡單多了,繼續 Google 發現這篇
https://gist.github.com/ipbastola/2760cfc28be62a5ee10036851c654600

1. 列出舊的 kernel
sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`

2. 移除上面列出的舊 kernel
sudo apt purge linux-image-5.4.0-42-generic

問題解決!

留言

這個網誌中的熱門文章

[MySQL] schema 與資料類型優化

[翻譯] 介紹現代網路負載平衡與代理伺服器