Tuesday, January 4, 2011

Increase Linux Swap space

Add more Linux Swap with Swap File

a) Login as the root user

b) Type following command to create 1GB swap file (1024 * 1MB = 1GB)

# dd if=/dev/zero of=/extraswap bs=1M count=1024

c) Set up a Linux swap area:

# mkswap /extraswap

d) Activate /extraswap swap space immediately:

# swapon /extraswap

e) To activate /extraswap after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:

# vi /etc/fstab

Append following line:

/extraswap swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?

Simply use free command:
#free -m

#swapon -s


Procedure to Remove a swap file
#NOTE: Do not delete swap file directly from the system, first you should do swapoff .

a. At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file):

#swapoff /extraswap

b. Remove its entry from /etc/fstab.

c. Remove the actual file:

#rm /extraswap

No comments:

Post a Comment