6

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 [email protected]:/sdcard/r /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.

eadmaster
  • 1,573
  • 4
  • 18
  • 30

1 Answers1

1

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.

Tom Hale
  • 28,728
  • 32
  • 139
  • 229
Ed Neville
  • 1,330
  • 10
  • 11
  • 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 04: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 07: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 09:22
  • 1
    [`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) – Tom Hale May 24 '19 at 11:57