Is it possible to have a compressed swap file without using zram or zswap?

Actually, I've successfully mounted a swap file over sftp with sshfs with these commands and I'd like to use compression with it:

mkdir /tmp/remoter
sshfs anonymous@ /tmp/remoter -C -p 2222  -o allow_root -o no_readahead -o cache=no -o uid=0 -o gid=0

dd if=/dev/zero of=/tmp/remoter/swapfile bs=50M count=1

sudo losetup /dev/loop0 /tmp/remoter/swapfile
sudo mkswap /dev/loop0
sudo swapon /dev/loop0

zram support is missing on both the local and the remote host.


I think to get transparent compression you'll need to use zfs. Why would you want to slow swap down even further? If the computer has to go to disk rather than RAM then things are suboptimal. You're by the looks of it putting swap on the network too. This is going to have serious performance impacts.

| improve this answer | |
  • Actually i'm using this with my orangepi where there is only 1GB or RAM and no disk swap by default. I haven't noticed any performance loss with sftp compression only. – eadmaster Feb 27 '17 at 4:55
  • Only? I've had <1GB on my desktop for all but the last five years of my life. If you've not noticed any performance differences, then take a look with something like egrep 'pgp' /proc/vmstat and see if that changes regularly as an indication of number of bytes that go to/from swap. – Ed Neville Feb 27 '17 at 7:41
  • I've checked the 50MB swapfile usage with free -h and after a while it gets filled completely. Without a swapfile when browsing with Firefox i constantly risk to go out of memory, and i am forced to close some tabs and external process to free some. – eadmaster Feb 27 '17 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.