Skip to content

This script will check and disable default swap location and create a new swap file in a given mounted volume.

Notifications You must be signed in to change notification settings

lolostt/coSwapperd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

coSwapperd

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.

Motivation

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.

Getting Started

Prerequisites

Software

  1. Raspberry Pi OS. Only tested on Debian 11 (bullseye). Other OS may work.
  2. Superuser privileges.

Installing

  1. Place script somewhere. Give execution permission with chmod +x coSwapperd.sh
  2. Run coSwapperd.sh -e to enable start at boot.

Usage

Just execute like a regular script. Options are required. coSwapperd.sh -s

Available options

-i | --initcheck Initial check. Mount point reachable check.

-e | --enable Enable at boot using crontab.

-s | --start Disable default swap and create new one.

Script behaviour

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.

Authors

License

This project is licensed under the Zero Clause BSD license.

About

This script will check and disable default swap location and create a new swap file in a given mounted volume.

Resources

Stars

Watchers

Forks

Languages