- Notifications
You must be signed in to change notification settings - Fork77
Script for creating hybrid swap space from zram swaps, swap files and swap partitions.
License
nefelim4ag/systemd-swap
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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
/etc/systemd/swap.conf/usr/lib/systemd/system/systemd-swap.service/usr/bin/systemd-swap
sudo systemctlenable --now systemd-swap
Arch Linux: in thecommunity repo.
git clone https://github.com/Nefelim4ag/systemd-swap.gitcd systemd-swapmake debsudo apt install ./systemd-swap_*_all.deb
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.7python3
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
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).
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.