OpenWrt Forum Archive

Topic: Swapfile on a CIFS share?

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I'm running some tests on my Linksys WRT54GL (want to run ctorrent there before my USB enabled asus wl500g arrives).

Would it be feasible to create a swapfile on a cifs mounted share?  Is it possible? (there are people who are successfully swapping to a nfs share)



I'm getting these errors when I try it (the .swapfile has been created with dd):

root@OpenWrt:/usr/lib# mkswap /tmp/windowsshare/.swapfile
Setting up swapspace version 1, size = 16773 kB

root@OpenWrt:/usr/lib# swapon /tmp/windowsshare/.swapfile
swapon: /tmp/windowsshare/.swapfile: Invalid argument


and on the logs:


Jul 17 19:10:30 (none) kern.warn kernel: rw_swap_page: bad swap file
Jul 17 19:10:30 (none) kern.warn kernel: Unable to find swap-space signature

Thanks in advance

In order to swap to a cifs share, you need to mount it and then use the loopback module to create the swapfile.


Steps:

Install kmod-loop and losetup


Then just setup a swapfile on the share and run the following commands:

root@OpenWrt:/mnt/windowsshare# losetup /dev/loop/0 /mnt/windowsshare/swapfile
root@OpenWrt:/mnt/windowsshare# mkswap /dev/loop/0
Setting up swapspace version 1, size = 134213 kB
root@OpenWrt:/mnt/windowsshare# swapon /dev/loop/0

The discussion might have continued from here.