Today, I noticed that my server's RAM and swap space usage is above 50%. That's bother me, I don't want my server goes down like before due to high usage of memory. I want to doubled my swap space since I don't have any money yet to upgrade my RAM (+$20/mo.).
Since this is done without rebooting, we will add more swap space by creating one swap file (not swap partition -- partitioning need server reboot/remount). My initial swap space is 1024MB (1GB) and I want to add more 1GB.
So, here's a simple step to add a swap space:
[1] create a new zeros file using
dd command, since I'm adding more 1GB, the count parameter on
dd should be 1024*1024=1048576 , here's the
dd command (I named new swap file to
/swapfile1):
[root@ns1 /]# dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB) copied, 45.5356 seconds, 23.6 MB/s
[2] zeros file has been created, now we make it as swap file:
[root@ns1 /]# mkswap /swapfile1
Setting up swapspace version 1, size = 1073737 kB
[3] make it on!
[root@ns1 /]# swapon /swapfile1
[4] check it using
free[root@ns1 /]# free
total used free shared buffers cached
Mem: 1026788 940420 86368 0 4096 363916
-/+ buffers/cache: 572408 454380
Swap: 2097136 803060 1294076
Yup, it's activated now.. you may add entry on your
/etc/fstab so it will automounted when your server is rebooted, add this line
/swapfile1 swap swap defaults 0 0
That's it! Have fun with your server!
Read rest of these entry>>>