Swapfile
From KlavoWiki
Jump to navigationJump to search
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