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

facebookShare on Facebook
TwitterTweet

Leave a Reply Cancel reply

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

Full text search

Recent Posts

  • Upgrade RockyLinux 8 to 9
  • Terraform and segregated permissions
  • LVM Compression and Deduplication
  • Edit gpg encrypted file with vim
  • Lelit Elizabeth PL92T Pressure Tuning
  • aws (8)
  • coffee (1)
  • headfi (1)
  • linux (6)
  • others (59)
  • security (2)
  • tech (36)
  • wordpress (2)

Loading

apache apigateway aws awscli azure backup cloud coffee docker ec2 EL8 ElasticBeanstalk enpass espresso featured kernel lelit linux lvm meltdown MFA nat gateway nginx php proliant python rdp Redhat RHEL rpm Ryzen s2s scp serverless site-to-site smartarray snapshot spectre tech terraform transit gateway ubuntu ubuntu upgrade vpn wordpress

©2023 blog.headdesk.me | Powered by SuperbThemes & WordPress