Creating a swap file
Written by Mahmoud Ahmadinejad on 9:16 AMSometimes there is a case you can't make a swap partition in linux. Perhaps you've got a tiny size partition on your linux box because of that greedy vista in size. Now we're going to make just a swap file, like windows do.
Swapping on file is easy, but it has one lack. It is slower than swap partition. But if don't care about the calculation, read on.
First, make a file on your own. 256 M, 300 M, 512 M or whatever. Feel free to decide.
sudo dd if=/dev/zero of=/mnt/500Mb.swap bs=1M count=512
a little explanation : if means input file, since we create a file from nothing then we look for zero device under directory /dev . While of means output file.
format the file as a swap filesystem by using command :
sudo mkswap /mnt/500Mb.swap
That's it. You already have an active swap filesystem. Issue a free command if you find yourself curious.
One last trick, in order your linux automatically read it at boot time is to put a line in your /etc/fstab file.
gksudo gedit /etc/fstab ( use your prefered editor )
add this line below to your /etc/fstab file
/mnt/500Mb.swap swap swap defaults 0 0
0 komentar: Responses to “ Creating a swap file ”