Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Btrfs doesn't allow to swap on a file. This script allows you do swap on a file anyway.

License

Notifications You must be signed in to change notification settings

sebastian-philipp/btrfs-swapon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

btrfs-swapon

From kernel 5.0+ btrfs have native swap files support, but with some limitations. Swap file - must be fully allocated as NOCOW with no compression on one device.

-- https://btrfs.wiki.kernel.org/index.php/FAQ#Does_btrfs_support_swap_files.3F

Btrfs doesn't allow to swap on a file. This script allows you do swap on a file anyway.

Keep in mind, that a copy-on-write file system is not the best choice to use a swap file. Don't expect high performance.

This script is based on http://www.spinics.net/lists/linux-btrfs/msg28533.html and https://gist.github.com/romaninsh/118952ce61643914fb00

Usage

Usage: btrfs-swapon <size> <file>
       btrfs-swapoff <file>

size:      the size of the file, like "8G"
file:      path to the swap file.

Using the systemd service

Installing

cp btrfs-swapoff btrfs-swapon /sbin/
cp btrfs-swapon.service /etc/systemd/system/

executing systemctl

systemctl start btrfs-swapon.service
systemctl stop btrfs-swapon.service

WARNNG

Don't balance your file system as long as you use this swap file.

About

Btrfs doesn't allow to swap on a file. This script allows you do swap on a file anyway.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages