X
    Categories: Linux

5 simple steps to increase the swap space on Linux.

Steps to increase the swap space on Linux.

Introduction:

Swap in the addition space allocate on the hard disk of the system which will acts as extension to the RAM on the system. Hence Swap space plays an important role in performance of the system.

This post describes steps to increase the swap space on Linux . Hence using this information you can able to increase the swap space on Linux which will boost the performance.

1. Create file using dd commands as below: (Note here we are adding 10MB swap to system.)

[root@kalwa1 tmp]# dd if=/dev/zero of=testswap bs=10M count=1
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.0115516 s, 908 MB/s

2. Now change the permission so that nobody can delete it.

[root@kalwa1 tmp]# chmod 0 testswap

3. Now setup the swap area on the newly created file using mkswap command.

[root@kalwa1 tmp]# mkswap testswap
mkswap: testswap: warning: don't erase bootbits sectors
 on whole disk. Use -f to force.
Setting up swapspace version 1, size = 10236 KiB
no label, UUID=703cadb4-5d2f-44e8-8ed7-eb76f71998cb

4. Now enable the swap area on newly created file using swapon command.

[root@kalwa1 tmp]# swapon -v testswap
swapon on testswap
swapon: /tmp/testswap: found swap signature: version 1, page-size 4, same byte o
rder

5. Now test if the swap space is increased by 10MB with following commands

[root@kalwa1 tmp]# cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-1 partition 4128760 0 -1
/tmp/testswap file 10232 0 -2
[root@kalwa1 tmp]# free -m
 total used free shared buffers cached
Mem: 2003 213 1789 0 13 77
-/+ buffers/cache: 122 1880
Swap: 4041 0 4041

Or you can use top command

 

View Comments (1)

Related Post