I published a collection with a swap file module a little over a year ago. It will automatically choose fallocate based on kernel version and filesystem type, can handle creating swap files on BTRFS and won’t leave the system in an unexpected state if it fails or is interrupted.