Linuxtipstricks – Just another /linux/blog

May 2, 2009

How to use a swap file to increase temporarily your swap memory

Filed under: user tipstricks — Antonio Portuesi @ 11:04 pm
Tags: , , , , ,

Sometimes, it can be very useful to increase the available swap memory using a file, so we could have a memory boost in a snap without prepare a dedicated swap partition.
Let’s do it!

The following line would create a swapfile of 4 gigabytes using a blocksize of a megabyte (1048576).
user@pc:~$ dd if=/dev/zero of=/swapfile bs=4194304 count=1000

Then make the file as a swapfile
user@pc:~$ mkswp /swapfile

Now we have to activate the swapfile…
user@pc:~$ swapon /swapfile

…and verify that the same has been activated.
user@pc:~$ swapon -s

That’s all!

Create a free website or blog at