Are there any particular reasons not putting the swap file in the external usb hard drive, but in /var/swap?
The swapfile has a swapiness setting of 1. This means the swapfile is only used if you run out of RAM. Think of it as an emergency only usage.
So unless your system is constantly running out of available RAM, the swapfile will never be used.
Regardless, you have a valid point and i’ll add your feature to v104:
This will be available for v104 and new installations only.
If you want to move your swapfile on your current installation to USB, do the following:
You will need to change the swapfile size if required. Either in the code below, or dietpi-config > advanced after.
dphys-swapfile swapoff rm /var/swap echo -e "CONF_SWAPSIZE=100" > /etc/dphys-swapfile echo -e "CONF_SWAPFILE=/mnt/usb_1/.swapfile" >> /etc/dphys-swapfile dphys-swapfile setup dphys-swapfile swapon
Yes, I did change the swap file into the usb drive manually. My pi runs out of memory often.
An option to choose either on sd card or usb drive would be good. Because if I unplug the drive, it will throws me an error if I have swap on usb drive. so an option to move swap into usb drive.
I realize this is an old thread, so I just thought I’d ask if this is still the way to go?