Wednesday, May 5, 2010

Make swap partition

1. First, create an empty file which will serve as a swap file by issuing the following command:
dd if=/dev/zero of=/swap bs=1024 count=1048576
where /swap is the desired name of the swap file, and count=1048576 sets the size to 1024 MB swap (for 512 MB use 524288 respectively).

2. Set up a Linux swap area with:
mkswap /swap
Old versions of mkswap needed the size of the swap file/partition, but with newer ones it’s better not to specify it at all since a small typo can erase the whole disk.

3. It’s wise to set the permissions as follows:
chmod 0600 /swap

4. The last thing – add the new swap file to /etc/fstab:
/swap swap swap defaults,noatime 0 0
This way it will be loaded automatically on boot.

5. To enable the new swap space immediately, issue:
swapon -a

No comments:

Post a Comment