• 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

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

Passwordless SSH 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 passwordless ssh in Linux between two Linux servers so that you don't have to en

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis