Wednesday, December 1, 2010

Swap Space

1. To setup swap space on a newly created partition :
# mkswap /dev/sdb3

2. To enable the swap partition :
# swapon /dev/sdb3

3. To enable the above swap device at boot time, add the below line to /etc/fstab

/dev/sdb3 swap swap defaults 0 0

4 To create a swap file:

a. Create an empty file
# dd if=/dev/zero of=/swapfile bs=1024 count=65536

b. Create swap space on the file
# mkswap /swap-file

c. Enable the swap file
# swapon /swap-file

d. Add the below line to /etc/fstab
/swap-file swap swap defaults 0 0

5. To remove a swap file

a. Disable swap on the file
# rmswap /swap-file
b. Remove the corresponding entry in /etc/fstab
c. Delete the file
# rm /swap-file

No comments: