Saturday, August 9, 2008

How to add Swap on Running system (Linux Slackware)

Swap needed by our system even not recomended for better runnings. Sometimes we have not enough our SWAP for some reason, so we need add more space SWAP for our Linux Box. The Question is "how to add swap on Running System without shutdown or restart?"

Tidak sedikit kita menemukan kasus dimana Linux Box kita yang sedang running kehabisan SWAP. Saya tidak akan menjelaskan kenapa itu terjadi, namun akan mencoba membagi informasi mengenai penambahan swap pada system linux yang sedang running (hasil pencarian dari google.com).

Tested on Slackware 12.0 and working properly.

That is :

1. Check your swap capacity

root@dianseh:~# free -m
total used free shared buffers cached
Mem: 2025 2021 4 0 158 453
-/+ buffers/cache: 1942 83
Swap: 3988 3988 0

2. Make sure the system have enough space Hardisk

root@dianseh:~# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 21G 2.1G 19G 10% /
/dev/hda3 56G 949M 55G 2% /home

3. We'll alocated 1GB for SWAP from directory /home

root@dianseh:/home# dd if=/dev/zero of=swapfile bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB) copied, 30.0159 s, 35.8 MB/s

4. Please check swapfile in directory /home

root@dianseh:/home# ls -l
total 1049600
drwxr-x--- 18 root root 464 2008-07-07 17:57 /master
-rw-r--r-- 1 root root 1073741824 2008-07-10 14:19 swapfile

5. You need change swapfile's
privilages for security reason

root@dianseh:/home# chmod 600 swapfile

6. Now, make swapfile active on your system

root@dianseh:/home# mkswap swapfile
Setting up swapspace version 1, size = 1073737 kB
no label, UUID=58de3638-3a1d-4a3d-a559-fcf40054367

7. This time how to get swapfile running on Linux Box.

root@dianseh:/home# swapon swapfile

8. We have 1GB added on system.

root@dianseh:~# free -m
total used free shared buffers cached
Mem: 2025 2021 4 0 158 453
-/+ buffers/cache: 1942 83
Swap: 3988 3988 1024

9. Finishing, need add one line entry to /etc/fstab :

/home/swapfile swap swap defaults 0 0

10. Done, Good Luck

What about your steps?

"Google search can help you find something"



reference :

1. Linux Howto

2. www.slackware.org

3. www.netadmintools.com

No comments: