Wikula » SwapFile
Increase swap space temporarily with a swap file
Sometimes your RAM and swap partition are not enough, and you might not want to touch your partition sizes. The solution is to create a swap file instead, which performs almost the same as your swap partition. For a 2Gb swap file e.g. do:
dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
to create it. Now format it and make it active:
mkswap /swapfile1 && swapon /swapfile1
If you decide to keep this active after your next re-boot, simply add to your /etc/fstab:
/swapfile1 none swap sw 0 0
Where do you use a swap file?
a) On a server where where you expect massive traffic and can not afford to turn it off for the time needed to re-partition and/or RAM upgrades.b) On older hardware with a small HDD before installing aptosid, where you do do not want to keep a large swap partition, but need a swapfile while installing.
c) On a workstation where you want to do nasty stuff with huge memory needs.
Note:
swap is no final solution if your hardware suffers from having not enough RAM. Always consider to upgrade RAM, all above is intended as a temporary solution.CategorySysadmin