Would you like to learn how to create a swap file on Ubuntu Linux? In this tutorial, we are going to show you how to create and enable a swap file on Ubuntu Linux version 17.
Hardware List:
The following section presents the list of equipment used to create this Ubuntu Linux tutorial.
Every piece of hardware listed above can be found at Amazon website.
Ubuntu Playlist:
On this page, we offer quick access to a list of videos related to Ubuntu Linux.
Don’t forget to subscribe to our youtube channel named FKIT.
Ubuntu Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Ubuntu linux.
Tutorial – Creating a Swap file on Ubuntu Linux
On the Linux console, use the following commands to create the swap file and enable it on Ubuntu Linux.
# dd if=/dev/zero of=/mnt/linux.swap bs=1M count=4096
# chmod 0600 /mnt/linux.swap
# mkswap /mnt/linux.swap
# swapon /mnt/linux.swap
In our example, we created a 4 GB swap file.
Use the free command to check if your swap file is already available to the system.
# free -m
If you wish to enable the swap file during boot time, you need to edit the fstab file and add the following configuration at the bottom.
# vi /etc/fstab
/mnt/linux.swap none swap sw 0 0
Now, let’s reboot the computer.
# reboot
As the last step, use the free command to check if the system mounted the swap file automatically.
# free -m
If the system mounted your swap file automatically, this means that you followed all the steps correctly.