How to add swap space on the linux server?

root@server12:/var/tmp> free -m
   total               used       free     shared    buffers     cached
Mem:                32186      32024     161          0        248       6086
-/+ buffers/cache:25690       6496
Swap:               4094       4094          0

root@server12:/var/tmp> dd if=/dev/zero of=/var/tmp/swap/swap0 bs=4096 count=1048576
1048576+0 records in
1048576+0 records out
4294967296 bytes (4.3 GB) copied, 33.6008 seconds, 128 MB/s

root@server12:/var/tmp>  mkswap /var/tmp/swap/swap0
Setting up swapspace version 1, size = 4294963 kB

root@server12>  swapon /var/tmp/swap/swap0

root@server12> free -m
             total       used       free     shared    buffers     cached
Mem:         32186      31942        244          0         99       6225
-/+ buffers/cache:     25617       6569
Swap:         8190       4094       4095

root@server12> swapon -s
Filename                                Type            Size        Used        Priority
/dev/sda5                               partition       4192924  4192924    -1
/var/tmp/swap/swap0                  file           4194296   0             -2
root@server12>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s