Swap File

July 26, 2008 at 9:45 pm (macbook)

Rather than create an extra partition for swap space, I’m going to create a swap file on the main root partition as described on the Ubuntu Community Wiki. Run the following commands in a terminal to create the swapfile:

$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=3145728
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

Note that the first step will take a while and I used 1.5 times my 2GB of RAM which is 3GB. To get the ‘count’, I multiply my block size times the size in MB of my swapfile, that is, 1024 * 3072 MB = 3,145,728. Then edit the fstab file:

$ sudo gedit /etc/fstab

Add the line

/swapfile swap swap defaults 0 0

Verify the swap file is active:
$ free -m

Post a Comment