Tuesday, April 21, 2020

Adding swap space in Linux

Adding swap space in Linux


[root@ip-anurag grid]#
[root@ip-anurag grid]#
[root@ip-anurag grid]# free -g
              total        used        free      shared  buff/cache   available
Mem:              3           0           0           0           2           2
Swap:             0           0           0
[root@ip-anurag grid]#
[root@ip-anurag grid]# dd if=/dev/zero of=/swap_file bs=2G count=1
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 29.8424 s, 72.0 MB/s
[root@ip-anurag grid]# chmod 600 /swap_file
[root@ip-anurag grid]# mkswap /swap_file
Setting up swapspace version 1, size = 2097144 KiB
no label, UUID=9bd76b65-4abe-4ffb-a580-d4e9283daac2
[root@ip-anurag grid]#
[root@ip-anurag grid]# swapon /swap_file
[root@ip-anurag grid]#
[root@ip-anurag grid]# vi /etc/fstab
[root@ip-anurag grid]#

[root]# swapon --show
NAME       TYPE SIZE USED PRIO
/swap_file file   2G   0B   -2
[root@ip-10-0-1-12 ~]#


/swap_file               swap                    swap    defaults        0 0



[root@ip-anurag grid]#
[root@ip-anurag grid]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3787         655        2274          16         857        2898
Swap:          2047           0        2047
[root@ip-anurag grid]#
[root@ip-anurag grid]#

3 comments:

About the Author : Anurag Pandey | Database cloud Architect | Oracle | SQL Server | PostgreSQL | AI and Data Platform Enthusiast

Anurag Pandey is a Database Architect with expertise in Oracle, PostgreSQL, SQL Server, Linux, and enterprise database platforms and specializes in database architecture, performance tuning, high availability, disaster recovery, cloud modernization, and operational excellence. With extensive experience in enterprise-scale environments, Anurag is passionate about leveraging AI, automation, and modern data platforms to improve reliability, scalability, and business outcomes. He actively contributes to technical communities through knowledge sharing, architecture guidance, and thought leadership in database and data engineering domains.

Follow more articles at

Visit Blog

PostgreSQL Process Architecture Diagram and Details

PostgreSQL Process Architecture Diagram                            +------------------+                            |    POSTMASTER    |     ...