ubuntu升级内核报boot空间不足的解决过程

突然想起我的vps好久没有升级系统软件了,于是照惯例上去一顿apt updateapt upgrade,结果在安装内核的时候报错了:

Setting up linux-firmware (20220329.git681281e4-0ubuntu3.26) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-91-generic
zstd: error 25 : Write error : No space left on device (cannot write compressed block) 
E: mkinitramfs failure zstd -q -1 -T0 25
update-initramfs: failed for /boot/initrd.img-5.15.0-91-generic with 1.
dpkg: error processing package linux-firmware (--configure):
 installed linux-firmware package post-installation script subprocess returned error exit status 1

按报错信息说的是boot分区空间不足了,于是df -h /boot看了下,好家伙,直接干到了97%,这个时候第一反应是两个解决途径:

  • 清理磁盘空间
  • 卸载旧版内核

清理磁盘空间

这里需要先清理磁盘空间,否则直接卸载旧版内核依然会报以上错误。首先看看boot分区有哪些文件,并且将这些文件备份到其他分区:

(base) root@cheerful-nodes-1:~# ls /boot
System.map-5.15.0-76-generic  config-5.15.0-89-generic      initrd.img-5.15.0-89-generic  vmlinuz-5.15.0-89-generic
System.map-5.15.0-83-generic  config-5.15.0-91-generic      initrd.img-5.15.0-91-generic  vmlinuz-5.15.0-91-generic
System.map-5.15.0-89-generic  config-5.15.0-94-generic      initrd.img.old                vmlinuz-5.15.0-94-generic
System.map-5.15.0-91-generic  grub                          lost+found                    vmlinuz.old
System.map-5.15.0-94-generic  initrd.img                    vmlinuz
config-5.15.0-76-generic      initrd.img-5.15.0-76-generic  vmlinuz-5.15.0-76-generic
config-5.15.0-83-generic      initrd.img-5.15.0-83-generic  vmlinuz-5.15.0-83-generic
(base) root@cheerful-nodes-1:~# mkdir /home/bootback
(base) root@cheerful-nodes-1:~# cp -r /boot /home/bootback

然后将不需要的旧版文件删除:

rm System.map-xxxxxxx

卸载旧版内核

清理完空间后,先看看系统已经安装了的内核:

dpkg --get-selections | grep linux-image
linux-image-5.15.0-25-generic                   install
linux-image-5.15.0-76-generic                   install
linux-image-5.15.0-83-generic                   install
linux-image-5.15.0-89-generic                   install
linux-image-5.15.0-91-generic                   install
linux-image-5.15.0-94-generic                   install
linux-image-generic                             install

使用以下命令删除不需要的内核,建议保留最新的三个版本即可:

apt purge linux-image-5.15.0-25-generic

清理完空间之后,重新apt upgrade,大功告成!

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇