Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.

License

NotificationsYou must be signed in to change notification settings

nefelim4ag/systemd-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Style: Black

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

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

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

/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 systemctlenable --now systemd-swap

Install

  • Arch Linux: in thecommunity repo.

  • Debian based distros

    git clone https://github.com/Nefelim4ag/systemd-swap.gitcd systemd-swapmake debsudo apt install ./systemd-swap_*_all.deb
  • Fedora based distros

    sudo dnf coprenable zeno/systemd-swapsudo dnf install systemd-swap

    or

    git clone https://github.com/Nefelim4ag/systemd-swap.gitcd systemd-swapmake rpmsudo dnf install ./systemd-swap-*noarch.rpm
  • Manual

    Install dependencies:

    • python3 >= 3.7
    • python3 packages:systemd-python andsysv_ipc
    git clone https://github.com/Nefelim4ag/systemd-swap.gitcd systemd-swapsudo 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 notedhere

Q: Do I need to useswapfc_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

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

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

    sudo swapoff -a
  • Remove swap entry from fstab:

    vim /etc/fstab
  • Remove your swap

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

    # For Ubuntu remove resume* in grubvim /etc/default/grub# For Centos 7 remove rd.lvm.lv=centos/swap*vim /etc/default/grub# For Manjaro remove resume* in grub & mkinitcpiovim /etc/default/grubvim /etc/mkinitcpio.conf
    # For Ubuntuupdate-grub# For Centos 7grub2-mkconfig -o /boot/grub2/grub.cfg# For Manjaroupdate-grubmkinitcpio -P

About

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors21


[8]ページ先頭

©2009-2025 Movatter.jp