This script automates hard drive power management on Linux-based systems (e.g., Raspberry Pi) by configuring drives to spin down when inactive, thereby extending drive lifespan.
- Drive Detection: Automatically detects connected drives and prompts the user for selection.
- Power Management Configuration:
- Installs and configures
hdparm
,hd-idle
, orsdparm
for automatic spin-down.
- Installs and configures
- System State Tracking: Captures the initial and final states of drives to verify configuration success.
- Rollback on Failure: Cleans up by uninstalling packages if configuration fails.
- Verification Tests: Ensures configurations are applied and provides a detailed summary.
- Root Access: Run the script with root privileges.
- Internet Connection: Required to install missing packages.
- Download the Script: Save the script to your desired location.
- Make the Script Executable:
chmod +x drive_manager.sh
- Run the Script with Root Privileges:
sudo ./drive_manager.sh
- Update Repositories: Ensures the latest package versions.
- Drive Detection and Selection: Detects drives and prompts the user for selection.
- Install and Configure
hdparm
:- Installs and configures
hdparm
for standby, spindown, and cache settings. Fallback tohd-idle
if incompatible.
- Installs and configures
- Install and Configure
hd-idle
:- Removes
hdparm
if installed by the script, then configureshd-idle
.
- Removes
- Install and Configure
sdparm
:- Uses
sdparm
as a last resort for spin-down configuration.
- Uses
- Verification and Summary: Verifies configurations and provides a summary with pre- and post-execution states.
- Spin-down Time: Customize spin-down times in the script functions.
- Drive Selection: Modify drive detection if using non-standard paths.
This script is free for personal and commercial use, modification, and redistribution.
If you found this project helpful, consider donating via PayPal: gopalasubramanium@gmail.com. Thank you for your support!