无法通过 apt-get install 或删除任何软件包。initramfs-tool 失败

无法通过 apt-get install 或删除任何软件包。initramfs-tool 失败

当我尝试安装某些东西时,我的 cryptswap 似乎出现了问题。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package meofetch
t@pop-os:~$ sudo apt-get remove neofetch
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  neofetch
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 339 kB disk space will be freed.
Do you want to continue? [Y/n] y
Setting up initramfs-tools (0.136ubuntu6) ...
update-initramfs: deferring update (trigger activated)
(Reading database ... 358177 files and directories currently installed.)
Removing neofetch (7.0.0-1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for initramfs-tools (0.136ubuntu6) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-7634-generic
cryptsetup: WARNING: Resume target cryptswap uses a key file
Error 24 : Write error : cannot write compressed block 
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.4.0-7634-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

问题中报告的错误消息仅出现在 20.04 中。这里有一个解决方法。

  1. 启动到恢复模式并等到 cryptswapfile 加载超时。

  2. 转到根 shell(恢复菜单中从底部开始的第二个条目)并注释掉以下行,/etc/fstab并在/etc/crypttab每行前面加上一个#字符。

    /etc/fstab

     /dev/mapper/cryptswap none swap defaults 0 0  
    

    /etc/crypttab

    cryptswap /cryptswapfile /dev/urandom swap,cipher=aes-xts-plain64,size=256    
    
  3. 跑步 swapoff -a && update-initramfs -u

  4. 取消注释 fstab 和 crypttab 中注释掉的行,然后使用 重新启动sudo reboot

答案2

对于具有类似消息的人,但也谈论将设置为错误 UUID 的 RESUME 变量:

只需删除 initramfs-tools () 的恢复文件中自动设置的 RESUME 变量sudo rm /etc/initramfs-tools/conf.d/resume,或者将其更新为交换分区的正确 UUID。

相关内容