To prevent unnecessary IO (and to extend life), instead of making a swap file on the OS's SD card, I went ahead and created a swap file on a dedicated USB drive. This USB drive will always be connected and it's only purpose in life is to serve as a swap "container".
sudo mkfs.ext4 /dev/sda1
sudo mkswap /dev/sda1 -L Swap-USB1
sudo swapon /dev/sda1
- The fist problem is that after a reboot the pi goes back to not using a swap!
- According to some sources, I need to edit
/etc/dphys-swapfile. However the Zero 2W does not have a swap config file (Ubuntu)
- Then some report having issues with
/etc/dphys-swapfilebecause it is loaded before the USB
How can I setup the swap file to be in use AFTER the USB has been loaded and to stay in use even after reboot?