Linux swap file creation and management

The first issue is that your first command created a file, swapfile, in your current directory, and that your subsequent command(s) were explicitly referencing /swapfile, a file called swapfile in the root directory. If that was not your current working directory when you executed the first command, all of the subsequent commands would be referring to a file that is not there to operate upon.

If you got no output from cat /proc/swaps, that indicates that either your system does not have procfs running (unlikely), or that you currently have no active swap space configured.

The output you claim to get from grep swap /etc/fstab makes no sense whatsoever. That looks like the output of free -m (incidentally confirming that you have no active swap configured), not the partial contents of the filesystem table.

Your post-reboot swapon -s (which as the manual states gives the same information as cat /proc/swaps) indicates that at some point prior to your reboot, someone executed swapoff.


You made a typo:

of=swapfile

should be

of=/swapfile

the guide creates the swap file in the root directory, whereas the command that you entered would have created a swap file in your current directory.

Tags:

Swap