I have an HPC including a server and about 20 diskless computing nodes. The server has a swap partition. I wonder if I could use this swap partition over network (ie. using NFS) to be used by computing nodes. I know this would cause serious speed reduction, but as nodes need small amount of swap for just some seconds, it worth to use this strange type of swapping.

P.S: nodes don't have HDD and they have the maximum supported memory(RAM).

P.S: Here:http://www.tldp.org/HOWTO/Network-boot-HOWTO/x542.html, it is said that I can do it for one remote workstation, but it doesn't say anything about having many workstations simultaneously.


No you can not share a swap partition (or a swap file) between different active hosts. Linux' paging is not programmed in a way that expects that the swap partition is accessed concurrently from different systems.

| improve this answer | |

you shall get an error like this, cause kernel needs to write to swap-file directly

  swapon: /mnt/shady/swapfile: swapon failed: Invalid argument

It's not possible to directly write to an NFS mount without going through the file-system you might be able to use i SCSI to do this, but the real question is whether it's worth it at all.

| improve this answer | |
  • thanks for your reply, but as I searched, I can use swap partition over NFS(http://www.tldp.org/HOWTO/Network-boot-HOWTO/x542.html), but only for one remote system. As I mentioned, I have a number of computing node and I wonder if I can use only one swap space shared for all of them. – mohammadh montazeri Jan 17 '16 at 11:14
  • wow fascinating stuff as i said nfs swap cant be done unless that patch,other one with nbd protocol i have to try this thanks for the link, amazing stuff – Shantanu Bedajna Jan 17 '16 at 11:45

Sharing a swap partition between more than one concurrently running system is an exceedingly bad idea. The system swaps memory pages on and off this area. Consider what would happen if system A swaps out some pages, system B also does this with no knowledge of system A, System A retrieves it's pages (mangled by system B).

The space can be shared if you can guarantee that only one OS will use it at a time, but that doesn't appear to be your use case. If the nodes have the maximum supported memory, the real question is do I need swap at all?

| improve this answer | |

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.