Wednesday, December 31, 2014

Create a SWAP partition on the Arduino Yun

This will create a 128MB (=2x RAM) swap partition on the Yun's SD card. I already have 2 partitions on the SD, this will be the 3th. First create an extra partition and format it as explained at

  After another reboot (maybe using mount command this reboot isn't needed?), df displays:
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 4183000    410916   3562372  10% /
/dev/root                 7680      7680         0 100% /rom
tmpfs                    30560       112     30448   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/sda1              4183000    410916   3562372  10% /
/dev/sda2              3138272    112080   2868908   4% /mnt/sda2
/dev/sda3               129267      7982    114732   7% /mnt/sda3
Next do:
root@Arduino:~# umount /dev/sda3
root@Arduino:~# mkswap /dev/sda3
Setting up swapspace version 1, size = 131068 KiB
no label, UUID=54a098ed-4e70-4392-8232-bd1f394df68a
root@Arduino:~# swapon /dev/sda3
Probably if I hadn't rebooted or so, the unmounting wasnt necessary... In /etc/config/fstab add:
config swap
        option device   /dev/sda3
        option enabled  1

swapiness can be controlled via:
sysctl -w vm.swappiness=10
echo 10 > /proc/sys/vm/swappiness
This will not remember the value across booting. For that edit /etc/sysctl.conf so that it contains:
vm.swappiness = 10

The free command or 'swapon -s' command can be given to get info about your swap.

No comments:

Post a Comment