ZFS bpool 几乎已满;如何释放空间以便能够继续更新系统而不会出现错误?

l k*_*l k 8 upgrade apt kernel zfs

我在 root 上运行带有 ZFS 的 Ubuntu,而且我的bpool似乎几乎已满。

输出zpool list bpool

NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
bpool  1.88G  1.69G   191M        -         -    60%    90%  1.00x    ONLINE  -
Run Code Online (Sandbox Code Playgroud)

输出df -h /boot

Filesystem                                        Size  Used Avail Use% Mounted on
bpool/BOOT/ubuntu_s2c09x                          367M  303M   64M  83% /boot
Run Code Online (Sandbox Code Playgroud)

这会导致完成内核更新安装时出现问题,例如运行sudo apt upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Requesting to save current system state
ERROR couldn't save system state: Minimum free space to take a snapshot and preserve ZFS performance is 20%.
Free space on pool "bpool" is 10%.
Please remove some states manually to free up space. 
Setting up linux-firmware (1.197.5) ...
update-initramfs: Generating /boot/initrd.img-5.11.0-41-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p2
I: (UUID=abdb40da-2d0b-4a45-b024-1c7245ea27ea)
I: Set the RESUME variable to override this.
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.11.0-41-generic with 1.
dpkg: error processing package linux-firmware (--configure):
 installed linux-firmware package post-installation script subprocess returned error exit status 1
Setting up linux-image-5.11.0-34-generic (5.11.0-34.36) ...
Processing triggers for linux-image-5.11.0-34-generic (5.11.0-34.36) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.11.0-34-generic
Error! Your kernel headers for kernel 5.11.0-34-generic cannot be found.
Please install the linux-headers-5.11.0-34-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-34-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p2
I: (UUID=abdb40da-2d0b-4a45-b024-1c7245ea27ea)
I: Set the RESUME variable to override this.
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.11.0-34-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-5.11.0-34-generic (--configure):
 installed linux-image-5.11.0-34-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-firmware
 linux-image-5.11.0-34-generic
ZSys is adding automatic system snapshot to GRUB menu
Run Code Online (Sandbox Code Playgroud)

我尝试销毁一些 bpool 快照,但zfs list -t snapshot | grep bpool没有列出超过 100K 的快照。我还尝试删除一些内核,请参阅输出dpkg -l linux-{image,headers}-"[0-9]*"

un  linux-headers-3.0               <none>         <none>       (no description available)
un  linux-headers-5.10.0-1045-oem   <none>         <none>       (no description available)
un  linux-headers-5.11.0-34-generic <none>         <none>       (no description available)
un  linux-headers-5.11.0-35-generic <none>         <none>       (no description available)
un  linux-headers-5.11.0-36-generic <none>         <none>       (no description available)
un  linux-headers-5.11.0-37-generic <none>         <none>       (no description available)
un  linux-headers-5.11.0-38-generic <none>         <none>       (no description available)
ii  linux-headers-5.11.0-40         5.11.0-40.44   all          Header files related to Linux kernel version 5.11.0
ii  linux-headers-5.11.0-40-generic 5.11.0-40.44   amd64        Linux kernel headers for version 5.11.0 on 64 bit x86 SMP
ii  linux-headers-5.11.0-41         5.11.0-41.45   all          Header files related to Linux kernel version 5.11.0
ii  linux-headers-5.11.0-41-generic 5.11.0-41.45   amd64        Linux kernel headers for version 5.11.0 on 64 bit x86 SMP
un  linux-headers-686-pae           <none>         <none>       (no description available)
ic  linux-image-5.10.0-1045-oem     5.10.0-1045.47 amd64        Signed kernel image oem
un  linux-image-5.11.0-27-generic   <none>         <none>       (no description available)
iF  linux-image-5.11.0-34-generic   5.11.0-34.36   amd64        Signed kernel image generic
rc  linux-image-5.11.0-35-generic   5.11.0-35.37   amd64        Signed kernel image generic
rc  linux-image-5.11.0-36-generic   5.11.0-36.40   amd64        Signed kernel image generic
rc  linux-image-5.11.0-37-generic   5.11.0-37.41   amd64        Signed kernel image generic
rc  linux-image-5.11.0-38-generic   5.11.0-38.42   amd64        Signed kernel image generic
ii  linux-image-5.11.0-40-generic   5.11.0-40.44   amd64        Signed kernel image generic
ii  linux-image-5.11.0-41-generic   5.11.0-41.45   amd64        Signed kernel image generic
Run Code Online (Sandbox Code Playgroud)

当前安装的最旧的似乎是 linux-image-5.11.0-34-generic,但是sudo apt purge linux-image-5.11.0-34-generic表明它还想安装linux-image-unsigned-5.11.0-34-generic,占用更多空间。

我还能尝试什么?是否可以选择调整/增长我的 bpool?我对使用 ZFS 还很陌生。

编辑:我做了一些更多的调查。zfs list bpool/BOOT/ubuntu_s2c09x -o space -r报告

NAME                                                             AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
bpool/BOOT/ubuntu_s2c09x                                          229M  1.51G     1.22G    303M             0B         0B
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_weekly-2021-11-19-1344        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-21-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-22-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-23-1340         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-24-1335         -    56K         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-25-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-26-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_weekly-2021-11-26-1343        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-27-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-28-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-29-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-11-30-1340         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-01-1340         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-02-1340         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-03-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_weekly-2021-12-03-1344        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-04-1337         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-05-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-06-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-07-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-08-1337         -    80K         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-09-0645         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_a2u0ly                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-10-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_weekly-2021-12-10-1341        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-11-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-12-1335         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_omna1o                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_5q7106                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-13-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_fwalez                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-14-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_dsm4th                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-15-1335         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_4t769s                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-16-1336         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_z8aa09                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-17-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_weekly-2021-12-17-1344        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_dqsnib                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_7w0l6s                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_323q08                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@autozsys_gqbsa5                             -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-18-1338         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-19-1339         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0217        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0317        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0417        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0517        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0617        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0717        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0817        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-0917        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1017        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1117        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1217        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1317        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_daily-2021-12-21-1337         -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1417        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1517        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1617        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1717        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1817        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-1917        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-2017        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-2117        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-2217        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-21-2317        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-22-0017        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_frequent-2021-12-22-0100      -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_frequent-2021-12-22-0115      -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_hourly-2021-12-22-0117        -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_frequent-2021-12-22-0130      -     0B         -       -              -          -
bpool/BOOT/ubuntu_s2c09x@zfs-auto-snap_frequent-2021-12-22-0145      -     0B         -       -              -          -
Run Code Online (Sandbox Code Playgroud)

我不明白它如何声称快照使用了 1.22 GB,但列出的 bpool 快照均未使用任何空间?

Ale*_*lex 15

卸载旧的和未使用的内核及相关文件是正确的操作;为了避免安装未签名内核的建议,请删除依赖于linux-image-5.11.0-34-genericvia 的软件包:

sudo apt purge linux*5.11.0-34*
Run Code Online (Sandbox Code Playgroud)

释放空间所需的第二步是删除引用已删除文件的旧快照;通过以下方式列出快照:

zfs list -r -t snapshot -o name,used,referenced,creation bpool/BOOT
Run Code Online (Sandbox Code Playgroud)

您可以在该REFER列中看到引用了多少数据。相同的数字通常与最小值一致USED;快照实际上是先前快照的副本。

通过以下方式手动删除五个最旧的快照:

zfs list -H -r -t snapshot -o name,used,referenced,creation bpool/BOOT | head -n 5 | cut -c 35-40 | xargs -n 1 sudo zsysctl state remove --system
Run Code Online (Sandbox Code Playgroud)

继续删除快照,直到看到空间被释放。

(最后一行和更多信息的来源:https://github.com/ubuntu/zsys/issues/155

笔记:

  1. 如果有未分配的空间,则可以增大 ZFS 池,但 Ubuntu 将剩余空间分配给rpool. 就地缩小 ZFS 池显然是不可能的。

  2. 我看到自动快照已打开bpool,但除非您希望任何文件在 APT 之外更改,否则 ZSys 快照应该足够了,并且会减少您必须考虑的快照数量。

  3. 为了避免将来出现此问题,请随时关注内核升级并定期删除旧内核。还要考虑减少 中的 ZSys 垃圾清理默认值/etc/zsys.conf。有关示例,请参阅:https://github.com/ubuntu/zsys/issues/155#issuecomment-758902487

  • bpool 上的自动快照似乎确实是问题的一部分。删除较旧的快照确实释放了空间,尽管它们的已使用值很小。仅供参考,当存在自动快照时,删除 5 个最旧快照的一行会中断,但我可以通过 `zfs list -r -t snapshot -o name bpool/BOOT | 删除它们,只留下 ZSys 快照。grep 自动捕捉 | xargs -n 1 sudo zfs destroy`。 (2认同)
  • “USED”仅显示该快照特有的数据大小。通过“-o引用”,您可以看到“REFER”值,它捕获快照引用的所有数据,提供总快照大小(通常与其他快照的大小重叠,最明显的是当“REFER”值大于“已使用”值)。“REFER”值应显示自动快照引用了许多旧文件,从而防止磁盘空间被释放,直到引用这些旧文件的最后一个快照被销毁。感谢您分享如何摆脱自动快照! (2认同)