If you are using a small VPS instance.
Like an instance with half a Gig or one Gig of the RAM.
You probably need to configure the
swapfile on that instance in order to
increase the performance.
So let’s see how to configure the
swapfile on those instances.
Let’s say you have
512MB of RAM available and you want to make
The process goes like this.
Create a file of size
fallocateis the tool for that.
$ sudo fallocate -l 1G /swapfile
Fill that file with
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
Change the permissions so that only
rootcan change the file.
$ sudo chmod 600 /swapfile
Make this file a
$ sudo mkswap /swapfile
Enable this swap partition (start using it).
$ sudo swapon /swapfile
Now you can check in
htop if you have a
swap partition and
and if you are making use of it.
Remember these changes you have just made to the system are temporary.
So after restart you won’t see the
swap space of
In order to make it persitiant. You need to edit the file
Add following entry to
/swapfile swap swap defaults 0 0
Let’s see what this entry does.
/swapfileis the file that we will be using.
swapis the device mount point.
swapspecifies the file system type.
defaultsthis is the filed for mount options.
0specifies the option to be used by the dump program.
0specifies the fsck command option.
Once you have this entry for
/etc/fstab you can
reboot the system and check if the
swap space is being used or not.