Tuesday, October 23, 2012

Linux: Short on Virtual Memory?

If your Linux box is short on RAM, you can create additional swap space on the fly without even rebooting.

Within one of your partition (assuming enough hard disk space), e.g., into /var, create a new file of the desired swap space size - here: 100MB

You ought better be logged in as root in order to perform such manipulation.
Mind that such a partition will be less effective (read: swift) than a real swap partition as accessing the file system induces a latency.

dd if=/dev/zero of=/var/swap bs=1025k count=1000
mkswap /var/swap
swapon /var/swap

That's it! 




For a more permanent change, amend /etc/fstab


/var/swap   none   swap   sw 0 0


No comments:

Post a Comment