This script will:
- Check and disable if default swap exists in /var/swap.
- Create SWAP_FILENAME file in mounted STORAGE_NAME volume for enable new swap location. Its size will be SWAP_SIZE.
This script was created to try to prevent the aging of the flash memory in a Raspberry Pi. Using virtual memory on an SD card's flash memory can lead to excesive wear and premature aging. Using swap memory from a mechanical disk drive may be useful.
- Raspberry Pi OS. Only tested on Debian 11 (bullseye). Other OS may work.
- Superuser privileges.
- Place script somewhere.
Give execution permission with
chmod +x coSwapperd.sh - Run
coSwapperd.sh -eto enable start at boot.
Just execute like a regular script. Options are required.
coSwapperd.sh -s
-i | --initcheck Initial check. Mount point reachable check.
-e | --enable Enable at boot using crontab.
-s | --start Disable default swap and create new one.
You can set some variables to customize script behaviour:
- STORAGE_NAME [Mandatory edit]. Mounted volume name where swap file will be located.
- SWAP_SIZE. Sets swap file size in megabytes.
- SWAP_FILENAME. Sets swap file name.
- BOOT_WAIT_TIME. Sets time in seconds scripts waits for system to start.
- DISKOPS_WAIT_TIME. Sets time in seconds scripts waits for disk operations to finish. Prevents errors related to slow mechanical hard drives.
- lolost - sleepingcoconut.com
This project is licensed under the Zero Clause BSD license.