Memory issues: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(init)
 
Line 1: Line 1:
== Adding temporary swap space in Linux ==
== Adding temporary swap space in Linux ==
''thanks to Gordon Keith''
''thanks to Gordon Keith for this tip''


<!-- http://grass.itc.it/pipermail/grassuser/2002-June/006700.html -->
<!-- http://grass.itc.it/pipermail/grassuser/2002-June/006700.html -->

Revision as of 10:12, 10 June 2007

Adding temporary swap space in Linux

thanks to Gordon Keith for this tip


To monitor your swap usage you can use utilities like top, xosview etc (they're the ones I use, but there are many others that will do the job).

If you are running out of swap space it is fairly easy to create a swap file and add it to your current swap area:

su
dd if=/dev/zero of=/var/swapfile bs=1024 count=2048000
mkswap /var/swapfile
swapon /var/swapfile

Will create a 2GB (approx) swapfile called /var/swapfile, format it as swapfile and add it to the swap space.

The file can reside anywhere on the local file system, so long as it it created using the preceding commands. On a faster disk is of course better for performance. Swapfiles bigger than 2GB only work on very recent kernels, so I'd recommend sticking with 2GB or less and use more than one if you want more than 2GB extra swap space. (I used 2x2GB swapfiles and a 1.5GB swap partition when I was playing with s.surf.idw).

If you no longer need the swap space but need the disk space you can free it with:

su
swapoff /var/swapfile
rm /var/swapfile

The swapoff command will only work when there are no pages currently in the swapfile. See man pages for mkswap, swapon and swapoff for details.