Difference between revisions of "Swap"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 1: Line 1:
 
Swapping is when a computer exchanges the location of memory pages between physical RAM and harddisk space.
 
Swapping is when a computer exchanges the location of memory pages between physical RAM and harddisk space.
  
  tweedleburg:~/Downloads # swapon -s
+
= add swap space =
Filename                                Type            Size    Used    Priority
+
If you want to add swap space to your running system
  tweedleburg:~/Downloads # swapon /tmp/swap  
+
* 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.
 
;Note: This command did not work with Knoppix 7.02.
  tweedleburg:~/Downloads # swapon -s
+
* verify it has been added to your swap devices:
 +
  # swapon -s
 
  Filename                                Type            Size    Used    Priority
 
  Filename                                Type            Size    Used    Priority
  /tmp/swap                              file            1048572 0      -1
+
  /tmp/swap                              file            1023996 0      -1

Revision as of 11:31, 10 June 2012

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