Swap

From Linuxintro

Swapping is when a computer exchanges the location of memory pages between physical RAM and harddisk space.

add swap space

If you want to add swap space to your running system

  • create a file (in this example /tmp/swap with a size of 1GB)
# dd if=/dev/zero of=/tmp/swap bs=1024k count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 4.35241 s, 241 MB/s
  • make it swap space
# mkswap /tmp/swap 
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=107e7939-e839-4a0e-b8fb-a50c9e0b96d5
  • tell the kernel to use it for swapping
# swapon /tmp/swap 
Note
This command did not work with Knoppix 7.02.
  • verify it has been added to your swap devices:
# swapon -s
Filename                                Type            Size    Used    Priority
/tmp/swap                               file            1023996 0       -1

remove swap space

To remove swap space from your system again, use the command swapoff, e.g.

# swapoff /tmp/swap