Welcome! Log In Create A New Profile


Swapping to Network File (NFS and iSCSI)

Posted by bodhi 
Swapping to Network File (NFS and iSCSI)
March 06, 2021 06:54PM
This is a tutorial about swapping to network shared file. For now, the outline, and then I'll fill in the details (very slowly, whenever I have time).

While I'm writing this, if anybody'd like to experiment with iSCSI target/initiator, feel free to do that. The Kirkwood and MVEBU kernel I release in this forum have this capability. I could use some helps to co-author the iSCSI part of the tutorial.

I. Swap over NFS

1. Create swap file in NFS shared folder

Assuming the NFS share folder /srv/nfs/swap was exported by the server. Create 512MB swap file.

mkdir -p /srv/nfs/swap
cd /srv/nfs/swap
dd if=/dev/zero of=swapfile3 bs=1024 count=524288
chmod 600 swapfile3 
mkswap swapfile3

2. Set up swap device in NFS client rootfs

Assuming on the client box, the NFS server was mounted at


Set up loop device for the swapfile3 and turn swap on.
losetup -v /dev/loop0 /mnt/nfs/nfs_server/srv/nfs/swap/swapfile3 
swapon -v /dev/loop0

Expected output

/dev/loop0 partition 512M 17M -2

cat /proc/swaps
Expected output

Filename Type Size Used Priority
/dev/loop0 partition 524284 256 -2

3.NFS client rootfs
4. NFS rootfs
5. RAM disk

II. Swap over iSCSI

1. Create iSCSI target
1.1 Windows iSCSI
1.2 Linux iSCSI
2. Create swap file in iSCSI target folder
3. Create iSCSI initiator in the client rootfs
3. RAM disk

Forum Wiki
bodhi's corner

Edited 4 time(s). Last edit at 04/04/2021 11:57PM by bodhi.
Re: Swapping to Network File (NFS and iSCSI)
March 23, 2021 04:54AM
This isnt much of a helpful reply,

That is right in my wheelhouse and interest set...... only problem is, I have had to relocate 140miles away from where all my toys reside :(
Re: Swapping to Network File (NFS and iSCSI)
March 23, 2021 07:22AM
This is interesting. I will keep my eyes on this thread.

Thank you, Bodhi.
Re: Swapping to Network File (NFS and iSCSI)
April 09, 2021 07:50PM
1st post updated.

Forum Wiki
bodhi's corner

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.