Create Virtual Memory

Webmin>System>Disk and Network Filesystems>Virtual Memory Mount Details.

I followed the webmin documentation…

1. On the main page of the Disk and Network Filesystems module, select Virtual Memory from the drop-down box of filesystem types, and click the Add mount button. A form will appear for entering the source and other options.
2. If you want the virtual memory to be added at boot time, select Save and mount at boot for the Save Mount option. Otherwise, select Don’t save if this is to be only a temporary addition.
3. For the Mount now? option, select Mount if you want the virtual memory to be added immediately, or Don’t mount if you just want it to be recorded for future addition at boot time.
4. If you want to add an entire partition as virtual memory, select Disk for the Swap File option and select the partition from the list. Otherwise, select Swap File and enter the path that you want to use as virtual memory. If you enter the path to a file that already exists, it will be overwritten when the virtual memory is added.
5. Click the Create button at the bottom of the page. If you are adding a swap file which does not exist yet, you will be prompted to enter a size for the file, and Webmin will create it for you. If all goes well, the browser will return to the list of filesystems on the main page.
6. Once the new virtual memory has been added, your system’s available memory should increase by the size of the partition or swap file. Use the memory display of the Running Processes module (explained in chapter 11) to see how much real and virtual memory is available.

I decided to use a swap file and have created the directory /var/swap for Virtualmin to add the swap file in the above outline.

unfortunately, i get the following error…
swapon: /var/swap: read swap header failed

It seems to me that step 1 doesnt actually explain how to configure the swap file in the directory i have created. I assumed that based on the limited information above, Virtualmin would automatically do everything needed, however that is not the experience i am having right now. (i am logged into webmin as root)
Can someone elaborate more on this and fill in the blanks please.

There is actually a much better way of doing this…follow this article. Simple and worked perfectly first time for me

https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/