Swapfile: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
(Created page with "I've written this based on my experience of Bananian which is Debian based. = Deleting Swap File = <pre> swapoff /swapfile1 </pre> <pre> rm -f /swapfile1 </pre> = Creating...")
 
No edit summary
Line 41: Line 41:
<pre>
<pre>
/swapfile1 swap swap defaults 0 0
/swapfile1 swap swap defaults 0 0
</pre>
= swapiness =
<pre>
vi /etc/sysctl.conf
</pre>
vm.swappiness Values
{|
|Value
|Strategy
|-
|0
|The kernel will swap only to avoid an out of memory condition, when free memory will be below vm.min_free_kbytes limit. See the "VM Sysctl documentation".
|-
|1
|Kernel version 3.5 and over, as well as Red Hat kernel version 2.6.32-303 and over: Minimum amount of swapping without disabling it entirely.
|-
|10
|This value is sometimes recommended to improve performance when sufficient memory exists in a system.
|-
|60
|The default value.
|-
|100
|The kernel will swap aggressively.
|}
After reboot check current value
<pre>
cat /proc/sys/vm/swappiness
</pre>
</pre>


[[Category : Banana Pi]]  [[Category : Linux]]
[[Category : Banana Pi]]  [[Category : Linux]]

Revision as of 03:08, 22 June 2016

I've written this based on my experience of Bananian which is Debian based.

Deleting Swap File

swapoff /swapfile1
rm -f /swapfile1


Creating Swap File

Hard Disk Partition

The parition needs to be created as a swapfile and not ext3, ext4 or something else.

mktemp /dev/sda1

File

Create a file of 1GB

dd if=/dev/zero of=/swapfile1 bs=512 count=2048
chmod 600 /swapfile1
mkswap /swapfile1
swapon /swapfile1

fstabs

vi /etc/fstab

Add an entry or change the existing one

/dev/sda1 swap swap defaults 0 0

or

/swapfile1 swap swap defaults 0 0


swapiness

vi /etc/sysctl.conf

vm.swappiness Values

Value Strategy
0 The kernel will swap only to avoid an out of memory condition, when free memory will be below vm.min_free_kbytes limit. See the "VM Sysctl documentation".
1 Kernel version 3.5 and over, as well as Red Hat kernel version 2.6.32-303 and over: Minimum amount of swapping without disabling it entirely.
10 This value is sometimes recommended to improve performance when sufficient memory exists in a system.
60 The default value.
100 The kernel will swap aggressively.

After reboot check current value

cat /proc/sys/vm/swappiness