Difference between revisions of "Creating Swap File"
From PrgmrWiki
m (added a Category tag) |
Inphektion (talk | contribs) |
||
Line 14: | Line 14: | ||
/var/swap2 none swap sw 0 0 | /var/swap2 none swap sw 0 0 | ||
</pre> | </pre> | ||
+ | |||
+ | '''To expand existing swap space after memory upgrade:''' | ||
+ | <ul> | ||
+ | <li>Turn off existing swap: <code>swapoff -a</code> | ||
+ | <li>Remove old swap: <code>rm /var/swap</code> | ||
+ | <li>Create new larger swap, in this example we are going from the 500mb above to 1024mb: <code>dd if=/dev/zero of=/var/swap bs=1024k count=1024</code> | ||
+ | <li>Make it swap: <code> mkswap /var/swap</code> | ||
+ | <li>Turn it back on <code>swapon -a </code> | ||
+ | <li> run the free command to confirm its there with the size you want. | ||
+ | </ul> | ||
[[Category:for Users]] | [[Category:for Users]] | ||
[[Category:Getting Started]] | [[Category:Getting Started]] |
Revision as of 15:29, 18 April 2011
To add a swap file to your vps run the following as root
To add a 500mb swap file change count=500 to another number for a smaller or bigger swap file
# dd if=/dev/zero of=/var/swap2 bs=1024k count=500 # chown root:root /var/swap2 # chmod 700 /var/swap2 # mkswap /var/swap2 # swapon /var/swap2
To have the swap file used by the kernel after a reboot, add the following to /etc/fstab (its the same as running swapon)
/var/swap2 none swap sw 0 0
To expand existing swap space after memory upgrade:
- Turn off existing swap:
swapoff -a
- Remove old swap:
rm /var/swap
- Create new larger swap, in this example we are going from the 500mb above to 1024mb:
dd if=/dev/zero of=/var/swap bs=1024k count=1024
- Make it swap:
mkswap /var/swap
- Turn it back on
swapon -a
- run the free command to confirm its there with the size you want.