Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Code Style: Black

Script to manage swap on:

  • zswap - Enable/Configure
  • zram - Autoconfigurating for swap
  • files - (sparse files for saving space, supports btrfs)
  • block devices - auto find and do swapon

ℹ️ It is configurable in /etc/systemd/swap.conf.

Additional terms:

  • SwapFC (File Chunked) - provides a dynamic swap file allocation/deallocation

File location


Please don't forget to enable and start with

sudo systemctl enable --now systemd-swap


  • Arch Linux: in the community repo.

  • Debian based distros

    git clone
    cd systemd-swap
    make deb
    sudo apt install ./systemd-swap_*_all.deb
  • Fedora based distros

    sudo dnf copr enable zeno/systemd-swap
    sudo dnf install systemd-swap


    git clone
    cd systemd-swap
    make rpm
    sudo dnf install ./systemd-swap-*noarch.rpm
  • Manual

    Install dependencies:

    • python3 >= 3.7
    • python3 packages: systemd-python and sysv_ipc
    git clone
    cd systemd-swap
    sudo make install
    # or into /usr/local:
    sudo make prefix=/usr/local 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 (Notebook, Desktop, Server) it's enough to enable zswap + swapfc (on server tuning of swapfc can be needed). If you use a SSD and care about flash memory wear, use only ZRam.

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).


  • ℹ️ Zram dependence: util-linux >= 2.26

  • ℹ️ If you use zram not for swap only, use kernel 4.2+ or please add rule for modprobe like:

    options zram max_devices=32

Switch on systemd-swap:s automatic swap management

  • Enable swapfc if wanted (note, you should never use zram and zswap at the same time)

    vim /etc/systemd/swap.conf.d/overrides.conf
  • Stop any external swap:

    sudo swapoff -a
  • Remove swap entry from fstab:

    vim /etc/fstab
  • Remove your swap

    # For Ubuntu
    sudo rm -f /swapfile
    # For Centos 7 (if using a swap partition and lvm)
    lvremove -Ay /dev/centos/swap
    lvextend -l +100%FREE centos/root
  • Remove swap from Grub:

    # For Ubuntu remove resume* in grub
    vim /etc/default/grub
    # For Centos 7 remove*
    vim /etc/default/grub
    # For Manjaro remove resume* in grub & mkinitcpio
    vim /etc/default/grub
    vim /etc/mkinitcpio.conf
    # For Ubuntu
    # For Centos 7
    grub2-mkconfig -o /boot/grub2/grub.cfg
    # For Manjaro
    mkinitcpio -P
You can’t perform that action at this time.