Menu
blog.headdesk.me
blog.headdesk.me

Enable zswap on memory-limited systems

Posted on 2022/09/282022/11/03

On systems where memory is limited – be that a SOC compute or a low-end virtual machine, enable zswap gives you more usable memory. This is similar to Stacker which compress your data and let you have more space. Back in those days, hard drives were measures in MB!

First, check that your kernel supports zswap. If CONFIG_ZSWAP is yes, then you’re good to go with the next steps.

❯ grep -i config_zswap /boot/config-$(uname -r)

Now, configure initramfs to load the lz4 kernel modules

❯ echo lz4 >> /etc/initramfs-tools/modules
❯ echo lz4_compress >> /etc/initramfs-tools/modules
❯ update-initramfs -u

Finally, modify the grub boot parameters to enable zswap. Edit /etc/default/grub, append zswap.enabled=1 to GRUB_CMDLINE_LINUX_DEFAULT

Run update-grub to actually apply that to grub.cfg and then reboot. When the system comes back, check that zswap is enabled by running:

❯ dmesg | grep zswap

If it is, you should be able to see a message like this:

[ 0.804273] zswap: loaded using pool lz4/zbud

To see zswap usage:

❯ grep -R . /sys/kernel/debug/zswap/
/sys/kernel/debug/zswap/same_filled_pages:1
/sys/kernel/debug/zswap/stored_pages:12
/sys/kernel/debug/zswap/pool_total_size:24576
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

To learn more about zswap, take a look at the kernel documentation.

Loading

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Full text search

Recent Posts

  • Generate secure password
  • AWS Compute Savings Plans
  • AWS Zonal Shift
  • Coffee break…
  • Prevent private key from being committed to git
  • aws (14)
  • coffee (2)
  • headfi (1)
  • linux (9)
  • others (61)
  • security (2)
  • tech (41)
  • terraform (3)
  • wordpress (2)

Loading

apache aws awscli azure backup boot cloud coffee docker ec2 EL8 ElasticBeanstalk espresso featured git kernel lelit linux lvm meltdown MFA nat gateway php power proliant python rdp Redhat RHEL rpm Ryzen scp security smartarray smart switch snapshot spectre tech terraform ubuntu ubuntu upgrade vpn windows wordpress workspace

©2026 blog.headdesk.me | Powered by SuperbThemes