Search code examples
linuxraspberry-piraspbianraspberry-pi3swapfile

Swap file returns to original size after reboot


I am trying to increase swapfile size on my raspberry pi 3. I'm following this guide here on DigitalOcean.

After successfully increasing the file and setting it up using mkswap and swpon commands everything works fine. I even tried filling my ram with random data to see if it is going to use the new swap space and it works perfectly.

However after I reboot my raspberry, swap file returns to the previous (default) size of 100MB. Is there any way to make this change permanent?

I'm running Raspberry pi 3 on Raspbian Jessie.


Solution

  • I figured it out.

    Modifying /etc/dphys-swapfile solves all problems.

    I just changed CONF_SWAPSIZE=100 to CONF_SWAPSIZE=2000

    dphys-swapfile is responsible for setting up, mounting/unmounting and deleting swap files.

    In the configuration file you can also specify the location of the swap file as well as few other parameters.