• Arun Kumar

Add Swap Space in Linux

In case you are falling short of swap space on a linux server, follow below steps to add more swap space.

Create swap file

Use linux dd command to create a swap file under root directory (/swapfile1)

Add 4gb swap file
dd if=/dev/zero of=/swapfile1 bs=1024 count=4194304

Add 20gb swap file
dd if=/dev/zero of=/swapfile1 bs=1024 count=20971520

Note: formula to calculate count = 1024 * (swap size in MB)

  • For 1 GB of swap. count = 1024 * 1024 = 1048576

  • For 2 GB of swap. count = 2048 * 1024 = 2097152

  • For 4 GB of swap. count = 4096 * 1024 = 4194304

Give permissions

chmod 0600 /swapfile1
mkswap /swapfile1
swapon /swapfile1

Add to /etc/fstab

vi /etc/fstab

/swapfile1 swap swap defaults 0 0

Check swap space

cat /proc/swaps


Recent Posts

See All

Oracle 19c Installation on Linux

Oracle 19c adds more features to Oracle database and this article demonstrates Oracle 19c installation on Linux 7. We will be using Oracle Linux 7 and Oracle Database 19.3 softwares for this activity.

Basic Linux Commands

This article describes basic Linux commands that you must know as a system or database administrator. Below commands in Linux help you manage any Linux server fast and smoothly. Linux Command List Che

Linux Firewall with iptables and firewalld

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside ipt