Sometimes we need to add extra swap space in our Linux machine, so in this article, I’m going to show you how to add swap space to a Linux server.
We have two ways to adding swap space in Linux environment.
- Create swap space using the file.
free -m
swapon -s
dd if=/dev/zero of=/swap_file bs=1G count=1
chmod 600 /swap_file
mkswap /swap_file
vi /etc/fstab
/swap_file swap swap defaults 0 0
swapon /swap_file
2. Use Hard disk to adding swap space.
#fdisk -l
#swapon /dev/sdb1
#vi /etc/fstab
dev/sdb1 swap swap defaults 0 0
cat /etc/fstab swapon -s free -k