Create a swap file

If you do not have a swap partition, you can create a file until we deliver the swap automatically.

Here's how:

dd if =/dev /zero of=/file.swap bs=1M count=512 sync
mkswap -c /file.swap
chmod -v 600 /file.swap
swapon /file.swap
  • bs: block size copied
  • count: number of blocks copied

Warning: the block is copied in memory, so if you copy a 512 MB, you need 512 MB memory, which is not usually the case when there is a lack of memory.

Here you copy 512 times 1 MB So what does a mega store.

That you now have 512 MB of additional swap.

To deactivate the swap file, use the command:

swapoff /file.swap

Attention must never delete a file swap service.

Last modified: 03/03/2011 at 11:03 by Emerick M. (Gandi)