| 
 | 
I think that needs some improvements.  The swap file should really be owned by root, and located in the root directory "/". 
 
To create the file with zero size in / : 
$ sudo touch /swapfile 
Then : 
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=512 
512+0 records in 
512+0 records out 
536870912 bytes (537 MB) copied, 64.1348 s, 8.4 MB/s 
$ sudo mkswap /swapfile 
Setting up swapspace version 1, size = 524284 KiB 
no label, UUID=312d835c-759d-4d5c-8c60-2ac4e6bf7117 
$ sudo swapon /swapfile 
$ 
 
After rebooting you will have to make the file the swapfile again : 
$ sudo swapon /swapfile 
$ 
 
To check it is the swapfile : 
$ sudo swapon --summary 
Filename                Type        Size    Used    Priority 
/swapfile                     file        524284    0    -1 
$ 
 |   
 
 
 
 |