Swapfile: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
= Raspberry Pi =
== Remove Swapfile ==
<pre>
dphys-swapfile swapoff
dphys-swapfile uninstall
</pre>
Remove dphys-swapfile application and dependency
<pre>
apt-get purge -y dphys-swapfile dc
</pre>
= Banana Pi =
I've written this based on my experience of Bananian which is Debian based.
I've written this based on my experience of Bananian which is Debian based.


= Deleting Swap File =
== Deleting Swap File ==
<pre>
<pre>
swapoff /swapfile1
swapoff /swapfile1
Line 11: Line 25:




= Creating Swap File =
== Creating Swap File ==


== Hard Disk Partition ==
=== Hard Disk Partition ===
The parition needs to be created as a swapfile and not ext3, ext4 or something else.
The parition needs to be created as a swapfile and not ext3, ext4 or something else.
<pre>
<pre>
Line 19: Line 33:
</pre>
</pre>


== File ==
=== File ===
Create a file of 1GB
Create a file of 1GB
<pre>
<pre>
Line 28: Line 42:
</pre>
</pre>


= fstabs =
== fstabs ==
<pre>
<pre>
vi /etc/fstab
vi /etc/fstab
Line 44: Line 58:




= swapiness =
== swapiness ==
<pre>
<pre>
vi /etc/sysctl.conf
vi /etc/sysctl.conf
Line 75: Line 89:
</pre>
</pre>


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

Revision as of 10:04, 20 August 2016

Raspberry Pi

Remove Swapfile

dphys-swapfile swapoff
dphys-swapfile uninstall

Remove dphys-swapfile application and dependency

apt-get purge -y dphys-swapfile dc

Banana Pi

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