I’ve been playing around with zswap (not zram, which is easy enough with the zramSwap
NixOS option). I’ve set kernelParams = [ "zswap.enabled=1" "zswap.compressor=zstd" ]
(and I’m using linuxPackages_latest
on nixos-unstable, currently 5.11.11) but when I boot I see the following:
$ journalctl -b | grep zswap
Apr 13 17:54:23 spica kernel: Command line: initrd=\efi\nixos\x0db1dj4h1z9p8vls7kyrvlicbsdpypy-initrd-linux-5.11.11-initrd.efi init=/nix/store/pbrr653xr0b63d6h4pvxpw16pdaws02m-nixos-system-spica-21.05.20210412.311ceed/init zswap.enabled=1 zswap.compressor=zstd loglevel=4
Apr 13 17:54:23 spica kernel: Kernel command line: initrd=\efi\nixos\x0db1dj4h1z9p8vls7kyrvlicbsdpypy-initrd-linux-5.11.11-initrd.efi init=/nix/store/pbrr653xr0b63d6h4pvxpw16pdaws02m-nixos-system-spica-21.05.20210412.311ceed/init zswap.enabled=1 zswap.compressor=zstd loglevel=4
Apr 13 17:54:23 spica kernel: zswap: compressor zstd not available, using default lzo
Apr 13 17:54:23 spica kernel: zswap: loaded using pool lzo/zbud
I’ve tried adding "zstd"
to several different combinations of boot.kernelModules
, boot.initrd.kernelModules
and boot.initrd.availableKernelModules
. My reading of people running into this problem on other distros is that the zstd
module needs to be loaded into the initramfs, which to me suggests that boot.initrd.kernelModules
would be the right place, but it doesn’t work there either: the same compressor zstd not available
error is shown, then zstd is loaded just after. I can always switch to zstd
via the sysfs interface after boot, and that works fine, it’s only the boot-time configuration that doesn’t work.
I could presumably solve this by building a custom kernel changing CONFIG_CRYPTO_ZSTD
to y
instead of m
but I don’t particularly want to go down that road if I can avoid it:
$ zgrep ZSTD /proc/config.gz
CONFIG_HAVE_KERNEL_ZSTD=y
CONFIG_KERNEL_ZSTD=y
CONFIG_RD_ZSTD=y
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD is not set
# CONFIG_ZRAM_DEF_COMP_ZSTD is not set
CONFIG_F2FS_FS_ZSTD=y
CONFIG_UBIFS_FS_ZSTD=y
CONFIG_SQUASHFS_ZSTD=y
# CONFIG_PSTORE_ZSTD_COMPRESS is not set
CONFIG_CRYPTO_ZSTD=m
CONFIG_ZSTD_COMPRESS=y
CONFIG_ZSTD_DECOMPRESS=y
CONFIG_DECOMPRESS_ZSTD=y