* Usually, people associate swap with a swap partition, maybe
because they've been proposed to create a swap partition on install.
In fact any file can be used as a swapping device, be it a partition
or a conventional file. If you're considering responsiveness, my
advice: add more RAM. Swapping to a partition or a file won't change
anything.
* We will add more swap by adding a swap file.
Adding more swap is a four-step process :
o a- Creating a file the size you want.
o b- Formatting that file to create a swapping device.
o c- Adding the swap to the running system.
o d- Making the change permanent.
We will consider (as an example) a 512 Mb swap need.
a- Creating a file the size you want :
We will create a /mnt/512Mb.swap swap file.
sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512
What is important here is count=512, which means we want our file to
contain 512 blocks of bs=1M, which means block size = 1 MegaBytes.
Be careful *not* to do this dd of=/mnt/512Mb.swap bs=1M seek=512 count=0
Though the file grows to 512Mb immediately,it will have holes that
makes it unusable.
b- Formatting that file to create a swapping device :
sudo mkswap /mnt/512Mb.swap
c- Adding the swap to the running system :
sudo swapon /mnt/512Mb.swap
You can see with "cat /proc/meminfo" that your additionnal swap is
now available.
d- Making the change permanent :
edit your /etc/fstab:
sudo gedit /etc/fstab
and add this line at the end of the file:
/mnt/512Mb.swap none swap sw 0 0
save and reboot
No hay comentarios:
Publicar un comentario