And I’m back, paging myself in, so we wrap up this topic.
So with the process pages all in in their frames, let’s add some more swap. File format this time.
1- Creating a Swap file
So Linux being Linux, you can be anything, as long as you’re a file!
So let’s get started and create a file using dd. After that, the process is very similar to what we’ve already seen. Have a look below:
The only difference is the use of the -f parameter to state that swap will be in a file and not in a partition.
In this example I created a 128MB file, but we can have multiple of these or even different sizes like the example below.
2- Making swap file available on boot
After the swap files created, they can be added to fstab to be available on boot, just like a partition, and all the same rules apply.
And there you have it. Swap files instead of swap partitions. These can be a quick(er) way of adding some swap space and have the same functionality.
Se let’s swap out and make space for a new process!
Note: As seen in my screenshots, the swap files should be made available only to the root user. I didn’t, since this was done in a lab environment, but don’t forget to do chmod 0600 on each file.