• 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)

below command will create 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


42 views

Recent Posts

See All

Important Linux Commands

This article describes important Linux commands that you must know as a system or database administrator. Check CPU Cores in Linux Use one of the below commands to find number of CPUs in Linux includi

Manage 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

Setup Passwordless Connectivity in Linux

Every time you ssh from one Linux server to another, you need to enter target server user's password. We can also setup password less ssh login between two Linux servers so that you don't have to ente

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis

Feedback