<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2FSwap</id>
	<title>Linux/Swap - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2FSwap"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/Swap&amp;action=history"/>
	<updated>2026-05-08T23:02:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/Swap&amp;diff=3363&amp;oldid=prev</id>
		<title>Kenneth: /* Linux Swap Space */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/Swap&amp;diff=3363&amp;oldid=prev"/>
		<updated>2016-05-09T14:13:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Linux Swap Space&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Linux Swap Space ==&lt;br /&gt;
&lt;br /&gt;
See active swap partitions:&lt;br /&gt;
 swapon -s&lt;br /&gt;
 cat /proc/swaps&lt;br /&gt;
&lt;br /&gt;
Create swap space:&lt;br /&gt;
 mkswap /dev/[device]&lt;br /&gt;
 mkswap -L [label] /dev/[device]&lt;br /&gt;
&lt;br /&gt;
Turn swap space on/off:&lt;br /&gt;
 swapon /dev/[device]&lt;br /&gt;
 swapoff /dev/[device]&lt;br /&gt;
 swapon -a    # turn on all in /etc/fstab&lt;br /&gt;
 swapoff -a   # turn off all in /etc/fstab&lt;br /&gt;
&lt;br /&gt;
Swap usage:&lt;br /&gt;
 free -m&lt;br /&gt;
 top&lt;br /&gt;
&lt;br /&gt;
Swappiness:&lt;br /&gt;
 /proc/sys/vm/swappiness&lt;br /&gt;
&lt;br /&gt;
/etc/fstab:&lt;br /&gt;
 LABEL=/swap1        swap                  swap    defaults,pri=1 0 0&lt;br /&gt;
 LABEL=/swap2        swap                  swap    defaults,pri=1 0 0&lt;br /&gt;
 LABEL=/swap3        swap                  swap    defaults,pri=1 0 0&lt;br /&gt;
&lt;br /&gt;
Swap in a file:  # WON&amp;#039;T WORK ON NFS MOUNT!&lt;br /&gt;
 dd if=/dev/zero of=/swap.img bs=1M count=1000&lt;br /&gt;
 chmod 600 /swap.img&lt;br /&gt;
 mkswap /swap.img&lt;br /&gt;
 swapon -v /swap.img&lt;br /&gt;
&lt;br /&gt;
Note: if you try to mount a swap file on NFS you will get this error: &amp;quot;swapon: /swap.img: Invalid argument&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== How large should my space space be ===&lt;br /&gt;
&lt;br /&gt;
Select right size for your setup.&lt;br /&gt;
&lt;br /&gt;
Here is my rule for normal server (Web / Mail etc):&lt;br /&gt;
   1. Swap space == Equal RAM size (if RAM &amp;lt; 2GB)&lt;br /&gt;
   2. Swap space == 2GB size (if RAM &amp;gt; 2GB)&lt;br /&gt;
&lt;br /&gt;
My friend who is a true Oracle GURU recommends something as follows for heavy duty Oracle server with fast storage such as RAID 10:&lt;br /&gt;
   1. Swap space == Equal RAM size (if RAM &amp;lt; 8GB)&lt;br /&gt;
   2. Swap space == 0.50 times the size of RAM (if RAM &amp;gt; 8GB)&lt;br /&gt;
&lt;br /&gt;
Suspend&lt;br /&gt;
&lt;br /&gt;
If you are going to suspend to disk, then you need swap space more than actual RAM. For example, my laptop has 1GB RAM and swap is setup to 2GB. This only applies to Laptop or desktop but not to servers.&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
*[http://www.cyberciti.biz/tips/linux-swap-space.html Linux: Should You Use Twice the Amount of Ram as Swap Space?]&lt;br /&gt;
*[http://tldp.org/HOWTO/Partition/requirements.html#SwapSize How large should my swap space be?]&lt;br /&gt;
*[http://tldp.org/HOWTO/Swap-Space-7.html Linux Swap Space Mini-HOWTO: A couple of notes]&lt;br /&gt;
*[http://www.faqs.org/docs/Linux-mini/Partition.html Linux Partition HOWTO]&lt;br /&gt;
*[http://linux.about.com/od/linux101/l/blnewbie4_2_13.htm Linux Newbie Administrator FAQ: Accessing Drives]&lt;br /&gt;
*[http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/s1-swap-adding.html Adding Swap Space]&lt;br /&gt;
*[http://www.lissot.net/partition/partition-04.html What Partitions do I need?]&lt;br /&gt;
&lt;br /&gt;
=== Swappiness ===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The Linux 2.6 kernel added a new kernel parameter called swappiness to let administrators tweak the way Linux swaps. It is a number from 0 to 100. In essence, higher values lead to more pages being swapped, and lower values lead to more applications being kept in memory, even if they are idle. Kernel maintainer Andrew Morton has said that he runs his desktop machines with a swappiness of 100, stating that &amp;quot;My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don&amp;#039;t want hundreds of megabytes of BloatyApp&amp;#039;s untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
One downside to Morton&amp;#039;s idea is that if memory is swapped out too quickly then application response time drops, because when the application&amp;#039;s window is clicked the system has to swap the application back into memory, which will make it feel slow.&lt;br /&gt;
&lt;br /&gt;
The default value for swappiness is 60. You can alter it temporarily (until you next reboot) by typing as root:&lt;br /&gt;
&lt;br /&gt;
 echo 50 &amp;gt; /proc/sys/vm/swappiness&lt;br /&gt;
&lt;br /&gt;
If you want to alter it permanently then you need to change the vm.swappiness parameter in the /etc/sysctl.conf file.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Source: [http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space All about Linux swap space]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>