Difference between revisions of "Swap"

From Linuxintro
imported>ThorstenStaerk
(Created page with "Swapping is when a computer exchanges the location of memory pages between physical RAM and harddisk space. <pre> tweedleburg:~/Downloads # swapon -s Filename ...")
 
imported>ThorstenStaerk
 
(2 intermediate revisions by the same user not shown)
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.
  
<pre>
+
= add swap space =
tweedleburg:~/Downloads # swapon -s
+
If you want to add swap space to your running system
Filename                                Type            Size    Used    Priority
+
* create a file (in this example /tmp/swap with a size of 1GB)
tweedleburg:~/Downloads # swapon /tmp/swap  
+
# dd if=/dev/zero of=/tmp/swap bs=1024k count=1000
tweedleburg:~/Downloads # swapon -s
+
1000+0 records in
Filename                                Type            Size    Used    Priority
+
1000+0 records out
/tmp/swap                              file            1048572 0      -1
+
1048576000 bytes (1.0 GB) copied, 4.35241 s, 241 MB/s
</pre>
+
* 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

Latest revision as of 11:35, 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

remove swap space

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

# swapoff /tmp/swap