Hello.
I have a problem creating a swap file on an external drive, on a similar board, OrangePi Lite with 512MB of RAM.
Following the guide I tried all ways to replace the swap file location by editing /storage/.config/swap.conf without success.
I don't know how to change the SWAPFILE="$HOME/.cache/swapfile" entry so that it creates the file on a USB drive connected to the board.
If I try for example "SWAPFILE="$HOME/var/media/DISK_LABEL/swapfile", which is the location where the USB drive is mounted from LE, actually the swapfile is created in a new folder on the SD card and not on the external drive.
Can anyone help me find where I'm wrong?
Display More
You describe situation with USB media not mounted when swap file is created.
Disk IO performance is about 100 times slower than memory performance. You would not want to have any memory read or write operations in file based swap.
Please note that you are not running out of memory if free column in Linux free command has very small number. Your actual free memory is in last 'available' column. You will be running out of memory only when Linux starts killing running processes.
Original poster was almost right about the way to activate swap manually. They only missed mkswap command and did not realize that swapon can activate individual swaps.
1. dd to create file in writable location. Preferably not on SD card or SSD with limited write counters.
dd if=/dev/zero of=/var/media/DISK_LABEL/swapfile bs=1M count=256
2. format that file with mkswap
mkswap /var/media/DISK_LABEL/swapfile
3. swapon that file
swapon /var/media/DISK_LABEL/swapfile
those are main steps from LibreElec code responsible for stuff in swap.conf. Other steps only ensure that parent directory exists and secure swap file permissions.