How to increase RAM using a USB as RAM memory?

First run this command to find the name of your pendrive from root access in terminal.

fdisk -l

For my case my pendrive is /dev/sdb1. Make sure you get the right drive name then run this to unmount the drive. Change /dev/sdb1 to your pendrive name.

sudo umount /dev/sdb1

Then run this to create the swap file on the pendrive.

mkswap /dev/sdb1

Now to turn on the swap file, run this, remember my pendrive is 2GB so I gave swap 2GB (15000). Give yours according to what yours have.

swapon -p 15000 /dev/sdb1

Done! To see whether it worked, type in this command.

cat /proc/swaps

This is how mine looks like:

This is how mine looks like