WHAT'S NEW?
Loading...

[SOLVED] How to create a Swap file on external hard drive connected to Raspberry Pi 3

Some programs requires, at peak, more than 1GB of RAM in order to run stable. To ensure a stabile behavior on a Raspberry Pi it is recommended to set a swapfile with 2048 MB to buffer these peaks.

To create a swapfile on your Raspberry Pi (Raspbian) you can use the following commands:

1) sudo su -c 'echo "CONF_SWAPSIZE=2048" > /etc/dphys-swapfile'

2) sudo dphys-swapfile setup

 After creating the swapfile, you have to activate it once by using this command:

3) sudo dphys-swapfile swapon

Now your Raspberry PI has enough SWAP in place if its needed, and will not go down because of RAM overload. You can set up swap space on an external HDD.

You can edit the /etc/dphys-swapfile config file to make the changes, then reboot.

Something like this (assuming you have created a partition and set your hdd to mount at /media/sda1 - change that to suit):

CONF_SWAPFILE=/media/sda1/swapfile
CONF_SWAPSIZE=2000

That will create and activate a swapfile called /media/sda1 of 2000MB at the next reboot.

0 comments:

Post a Comment