Swap or not swap on an SDcard?


There are a lot of yunohost instance without swapfile, it could be dangerous during installation/remove operation (or simply could create service instability).

Swapfile of 1GB can be added really simply:

dd if=/dev/zero of=/swapfile bs=1024 count=1048576
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab

On hard drive disk no doubt you should add it, but on SDcard (like in the internetcube) the swapfile could accelerates the end of life of your SDcard.

Any idea how we should properly manage this in YunoHost ?

I suggest to add it automatically (during the yunohost upgrade) if it’s an hard drive or if the device has less than 1GB RAM. What’s your point of view.

Note: if your / is on a sdcard the better will be to put your swap file on a small usb disk (1GB)


I think on SDcard we can reduce the swappiness of swap. Lesser the value,system will put less data on swam and use up the ram first.

I think setting swappiness to 10 is ok.

Edit /etc/sysctl.conf
nano /etc/sysctl.conf

and add this in the last line of /etc/sysctl.conf


for the first 3 commands I can (have to) use sudo, but the last command didn’t work with sudo for me ("permission denied).
So I’ve added this at the end of /etc/fstab with sudo nano …

/swapfile swap swap defaults 0 0