I'm not sure that's the problem because when I try swapoff and on with the -a attribute (I believe that re-reads the /etc/fstab config) it doesn't work.
root@LEDE:~# swapoff -a
root@LEDE:~# free -k
total used free shared buffers cached
Mem: 513600 488220 25380 18100 2664 416484
-/+ buffers/cache: 69072 444528
Swap: 0 0 0
but when I try
root@LEDE:~# swapon -a
root@LEDE:~# free 0k
total used free shared buffers cached
Mem: 513600 488452 25148 18328 4216 412944
-/+ buffers/cache: 71292 442308
Swap: 0 0 0
You have configured the device at "/etc/config/fstab", and the swap at "/etc/fstab"... I would try to configure both on the same file, preferably at "/etc/config/fstab".
I'm not sure why it's not mounting at boot, but fwiw i added my swap through Luci and it only shows up in /etc/config/fstab, my /etc/fstab is empty. Here's what my swap looks like in /etc/config/fstab -
The file "/etc/fstab" belongs to the standard Linux utils, and the "/etc/config/fstab" belongs to LEDE/OpenWrt's "uci" system; to avoid problems, I would use just one of them; if you want to use the LuCi interface, you have to use the "/etc/config/fstab" file.
@mike pointed out a method to config the swap, but notice that you are using a file inside "/dev/sda1", and not the whole partition.
That makes sense. How do I config Luci's swap file at /etc/config/fstab to recognize a file as a swap?
In my system log it has this:
[ 7.415461] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[ 7.424005] block: extroot: not configured
[ 7.461952] mount_root: switching to ubifs overlay
Good point. I run transmission-daemon as well as an Apple File Server (for Time Machine backup). I routinely have less than 10% total available memory on my status page when all things are running.
I've always used partitions rather than files for swap so i'm not sure, my guess would be that you would just make the swap file and point to it with option device in /etc/config/fstab, but i've never tried with a file so i just don't know for sure.
Fwiw i added swap for that reason too (transmission), but on my wrt1200 with 512mb ram i can run transmission and minidlna at the smae time and never use more than 1-2% swap, so you may not even need it as @tmomas pointed out.
The advice is written for the usual routers, which used to have 32 or 64 MB of RAM.
Your 512 MB practically guarantees that you do not need swap. Most likely transmission and your Apple thing just try to use all free memory that they can get, as a buffer, but you can likely limit that amount in its settings.
And most likely some of the "used" memory is soft-grabbed cache (or buffers) e.g. for disk handling, not really used. Transmission can be disk intensive, so it is likely that Linux allocated large disk buffers when there is lots of disk activity and you are not needing the RAM for any other actual usage.
Example from my router, notice the difference of LuCI's hard/pure free 387M and the actual "soft" free with temporary buffers and cache included is 410M as displayed on the second line of "free" output. The difference is not that big, as there is nothing disk intensive going on:
Gotcha. The only other rub here is that I installed rclone (https://rclone.org/) on the router and sometimes use that to sync my Download drive from transmission on the router with the cloud (OpenWrt is awesome!). I'll monitor the usage when that's going on but I think you're right for now I might not need the swap.
@ryrhrbhdd Have a look at GParted (but I would always have a back-up copy of all important information on the drive, so you need another drive anyways).
uci set fstab.@global[0].anon_swap='1'
uci set fstab.@global[0].auto_swap='1'
CLEAN HOUSE:
while uci -q delete fstab.@swap[-1]; do :; done
AUTOSTART ENTRY 1 WITH A FAKE LABEL:
uci add fstab swap
uci set fstab.@swap[-1].enabled='1'
uci set fstab.@swap[-1].device='/mnt/sda1/swapfile'
uci set fstab.@swap[-1].label='foo'
AUTOSTART ENTRY 2 WITH A FAKE LABEL:
uci add fstab swap
uci set fstab.@swap[-1].enabled='1'
uci set fstab.@swap[-1].device='/mnt/sdb1/swapfile'
uci set fstab.@swap[-1].label='bar'
COMMIT AND REBOOT FOR PROOF:
uci commit fstab
reboot
AND WE HAVE SUCCESS:
free
Swap: 524280
w00h00!
Now you can plug and unplug hard drives as either sda1 or sdb1 while the power is off, and as long as one of them contains a swapfile file then it'll mount at bootup.