【Tutorial】Setup swap file for Zero


As we know, Zero is lack in DDR size.
If you want run desktop or other “big” software, you’d better setup swap file for Zero.
Zero have 64MB DDR, and 128MB swap size is fine.

Create&enable swap file

  1. Create a 128MB swap file:
    dd if=/dev/zero of=/swap bs=1M count=128
  2. Setup swap file:
    mkswap /swap
  3. Enable swap file:
    swapon /swap
  4. Write to /etc/fstab, and it will be auto enabled when boot up
    /swap swap swap defaults 0 0
  5. Make sure swap file is enable

root@Lichee:~# free
total used free shared buffers cached
Mem: 54672 50816 3856 0 3180 28864
-/+ buffers/cache: 18772 35900
Swap: 131068 12 131056

Delete swap file

  1. Disable swap file
    swapoff /swap
  2. Delete swap in /etc/fstab

Adjust swappiness

swappiness: 100, most likely to use virtual memory; 0, unlikely to use.
Temporary adjust:

#sysctl vm.swappiness=10
vm.swappiness = 10
#cat /proc/sys/vm/swappiness

Write to config: /etc/sysctl.conf:
Run sysctl -p to take effect.

【Tutorial】dd image for Zero (suit for windows&linux)