Home

Awesome

systemd-swap

Code Style: Black

⚠️ Current code quality and commit frequency is low ⚠️

Users should migrate to systemd/zram-generator since zram should be enough in most systems

Script to manage swap on:

:information_source: It is configurable in /etc/systemd/swap.conf.

Additional terms:

File location

/etc/systemd/swap.conf
/usr/lib/systemd/system/systemd-swap.service
/usr/bin/systemd-swap

Please don't forget to enable and start with

sudo systemctl enable --now systemd-swap

Install

About configuration

Q: Do we need to activate both zram and zswap?
A: Nope, it's useless, as zram is a compressed RAM DISK, but zswap is a compressed "writeback" CACHE on swap file/disk. Also having both activated can lead to inverse LRU as noted here

Q: Do I need to use swapfc_force_use_loop on swapFC?
A: Nope, as you wish really, native swapfile should work faster and it's safer in OOM condition in comparison to loop backed scenario.

Q: When would we want a certain configuration?
A: In most cases zram is enough since it on average compresses 2-3x and is much faster than disk based swap.

Q: How many zram devices should one use? A: If you are not using an ancient kernel (pre 4.7) there's no benefit from using multiple zram devices.

Q: Can we use this to enable hibernation?
A: Nope as hibernation wants a persistent fs blocks and wants access to swap data directly from disk, this will not work on: swapfc (without some magic of course, see #85).

Switch on systemd-swap:s automatic swap management