以下是 的内容/boot
:
drwxr-xr-x 5 root root 3072 Apr 18 09:10 .
drwxr-xr-x 26 root root 4096 Mar 22 15:43 ..
-rw-r--r-- 1 root root 217495 Jan 17 05:59 config-4.15.0-76-generic
-rw-r--r-- 1 root root 217457 Feb 28 02:45 config-4.15.0-91-generic
drwxr-xr-x 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 1024 Mar 22 15:50 grub
-rw-r--r-- 1 root root 60196828 Apr 18 09:05 initrd.img-4.15.0-76-generic
-rw-r--r-- 1 root root 60206115 Apr 18 09:05 initrd.img-4.15.0-91-generic
drwx------ 2 root root 12288 Feb 13 2016 lost+found
-rw-r--r-- 1 root root 182704 Jan 28 2016 memtest86+.bin
-rw-r--r-- 1 root root 184380 Jan 28 2016 memtest86+.elf
-rw-r--r-- 1 root root 184840 Jan 28 2016 memtest86+_multiboot.bin
-rw------- 1 root root 4068355 Jan 17 05:59 System.map-4.15.0-76-generic
-rw------- 1 root root 8367768 Jan 17 06:27 vmlinuz-4.15.0-76-generic
-rw------- 1 root root 8375960 Feb 28 02:51 vmlinuz-4.15.0-91-generic
我的内核版本是4.15.0-91-generic
(基于uname -r
)。
的输出dpkg --list | grep linux-image
为:
c linux-image-4.15.0-74-generic 4.15.0-74.84 amd64 Signed kernel image generic
ii linux-image-4.15.0-76-generic 4.15.0-76.86 amd64 Signed kernel image generic
ii linux-image-4.15.0-91-generic 4.15.0-91.92 amd64 Signed kernel image generic
ic linux-image-4.4.0-171-generic 4.4.0-171.200 amd64 Signed kernel image generic
这是我运行时发生的情况sudo apt-get upgrade
:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
thermald
Use 'sudo apt autoremove' to remove it.
The following packages have been kept back:
linux-headers-generic
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up linux-firmware (1.173.17) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-91-generic
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-4.15.0-76-generic
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-69-generic
WARNING: missing /lib/modules/3.19.0-69-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-69-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_BapeFK/lib/modules/3.19.0-69-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_BapeFK/lib/modules/3.19.0-69-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-66-generic
WARNING: missing /lib/modules/3.19.0-66-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-66-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_oFrhwW/lib/modules/3.19.0-66-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_oFrhwW/lib/modules/3.19.0-66-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-65-generic
WARNING: missing /lib/modules/3.19.0-65-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-65-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_cmnh3Q/lib/modules/3.19.0-65-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_cmnh3Q/lib/modules/3.19.0-65-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-59-generic
WARNING: missing /lib/modules/3.19.0-59-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-59-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_kimz35/lib/modules/3.19.0-59-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_kimz35/lib/modules/3.19.0-59-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-58-generic
WARNING: missing /lib/modules/3.19.0-58-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-58-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_yH46Fl/lib/modules/3.19.0-58-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_yH46Fl/lib/modules/3.19.0-58-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
update-initramfs: Generating /boot/initrd.img-3.19.0-25-generic
WARNING: missing /lib/modules/3.19.0-25-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-25-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_gmb7aZ/lib/modules/3.19.0-25-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_gmb7aZ/lib/modules/3.19.0-25-generic/modules.builtin: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirclientplatform.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_mirplatformgraphics.conf: No such file or directory
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.19.0-25-generic with 1.
dpkg: error processing package linux-firmware (--configure):
installed linux-firmware package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)
现在,/boot 的内容是:
drwxr-xr-x 5 root root 3072 Apr 18 09:14 .
drwxr-xr-x 26 root root 4096 Mar 22 15:43 ..
-rw-r--r-- 1 root root 217495 Jan 17 05:59 config-4.15.0-76-generic
-rw-r--r-- 1 root root 217457 Feb 28 02:45 config-4.15.0-91-generic
drwxr-xr-x 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 1024 Mar 22 15:50 grub
-rw-r--r-- 1 root root 16975438 Apr 18 09:14 initrd.img-3.19.0-58-generic
-rw-r--r-- 1 root root 16975489 Apr 18 09:14 initrd.img-3.19.0-59-generic
-rw-r--r-- 1 root root 16975434 Apr 18 09:14 initrd.img-3.19.0-65-generic
-rw-r--r-- 1 root root 16975144 Apr 18 09:14 initrd.img-3.19.0-66-generic
-rw-r--r-- 1 root root 16975428 Apr 18 09:14 initrd.img-3.19.0-69-generic
-rw-r--r-- 1 root root 60195966 Apr 18 09:14 initrd.img-4.15.0-76-generic
-rw-r--r-- 1 root root 60204841 Apr 18 09:14 initrd.img-4.15.0-91-generic
drwx------ 2 root root 12288 Feb 13 2016 lost+found
-rw-r--r-- 1 root root 182704 Jan 28 2016 memtest86+.bin
-rw-r--r-- 1 root root 184380 Jan 28 2016 memtest86+.elf
-rw-r--r-- 1 root root 184840 Jan 28 2016 memtest86+_multiboot.bin
-rw------- 1 root root 4068355 Jan 17 05:59 System.map-4.15.0-76-generic
-rw------- 1 root root 8367768 Jan 17 06:27 vmlinuz-4.15.0-76-generic
-rw------- 1 root root 8375960 Feb 28 02:51 vmlinuz-4.15.0-91-generic
系统似乎正在尝试initrd
在 中构建旧文件/boot
,然后/boot
填满,然后dpkg
失败。我该如何修复此问题?
答案1
update-initramfs
删除指示已安装哪个内核的残留文件sudo rm /var/lib/initramfs-tools/3.19*
确认(不会处理 3.19* 图像)
sudo update-initramfs -u -k all
去修复 apt 安装
sudo apt install -f
然后您可以永久删除那些 3.19* 图像。
注意:步骤 2 是可选的,因为在安装包时它会在步骤 3 中重复linux-firmware
。我把它包括进去是为了清楚起见。
答案2
仔细阅读https://help.ubuntu.com/community/RemoveOldKernels
根据这篇文章,您只需使用autoremove
终端中的命令即可删除旧的未使用的内核:
sudo apt-get autoremove --purge
注意:apt-get autoremove
不会删除所有自动安装的旧内核提供包,因为保留了后备版本;保留的内核列表将保留并自动更新/etc/apt/apt.conf.d/01autoremove-kernels
为匹配正则表达式的列表。因此我写了仔细阅读上述帖子。
列出所有内核,包括已启动的内核:
dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
如果您想要清除一个特定的内核提供包,您可以通过终端中的以下命令进行操作:
sudo apt-get purge linux-image-4.**.*-**-generic
sudo dpkg --purge linux-headers-4.**.*-* linux-headers-4.**.*-**-generic
以上页面还提供了如何“安全删除旧内核”的信息,包括initrd.img
。最好一步一步地遵循。
答案3
您的清除操作仅获取与内核相关的六个软件包中的一个,而剩余的部分会导致问题。对于 /boot 中的 3.19 initrd 文件,请获取编号,例如 3.19.0-58,然后通过 dpkg --list | fgrep 3.19.0-58 运行该编号。对 3.19 软件包列表运行 apt-get purge。然后获取下一个,直到所有软件包都已修复。
下次您想要清除整个内核时请执行此操作 - 使用 dpkg --list | fgrep xyz-w 获取相关软件包,然后如果仅列出您想要删除的软件包,请将该列表提供给清除操作(调用上一行中的命令以生成列表):
dpkg --list |fgrep x.y.z-w
apt-get purge `!!`
答案4
一个相当安全的解决方案对于大多数未来的读者来说:
对于每个不存在此类文件或目录的情况,创建一个虚拟文件供 apt 删除。Apt 不关心文件内容,它只需要删除该文件。因此,请给它一个要删除的文件。
这种方法可能很繁琐(您会丢失很多文件),但比下面的替代方法安全得多。
例子
这是一个错误:
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory
/etc 中的文件归 root 所有,因此使用以下命令创建一个虚拟文件sudo touch /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf
现在有一个文件需要 apt/dpkg 删除,这解决了没有这样的文件或目录的错误。
不太安全的解决方案是使用 dpkg 的 --force-remove-reinstreq 标志。我们称之为核选项 - 它会删除 dpkg 数据库中的软件包条目无需删除任何文件。
这似乎对你(也只有你)来说是一个有效的解决方案。所有未来的读者都应该忘记他们看到过它
警告在重新安装之前,使用 --force-remove-reinstreq 作为最后的手段。如果误用,可能会破坏包管理器并需要重新安装。此选项仅适用于有经验的用户。这是一剂猛药——误用可能会杀死患者。