-
Notifications
You must be signed in to change notification settings - Fork 41
Add status files in /var/run/hd-idle #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @DocMAX |
|
I allready wrote in the PR what this change does. |
Updating the documentation is a way to enable other users to understand how to use the new feature. |
…testing disk filesystem types
Introduces a new configuration option, `SkipIfMounted`, to prevent hard drives from spinning down if they are currently mounted. This feature can be enabled globally or per-device. - Add `SkipIfMounted` boolean to `DefaultConf` and `DeviceConf`. - Implement `isDeviceMounted` function using `findmnt` to check mount status. - Modify `updateState` to check `SkipIfMounted` before initiating spindown. - Add `-M` command-line flag to enable this behavior. - Update usage instructions to reflect the new option. This prevents potential data corruption or issues that could arise from spinning down an actively used, mounted drive.
Introduce a `--dry-run` CLI flag to simulate disk spindown operations without executing actual commands, allowing for safe testing of configurations. Improve the `isDeviceMounted` function to reliably detect mounted devices, including Btrfs and ZFS filesystems, and to check for mounted partitions. This makes the `skip-if-mounted` feature more accurate and robust.
Add a new `verbose` flag (`-v`, `--verbose`) to provide more user-facing informational output. This flag is distinct from the `debug` flag, which is intended for more internal debugging details. Update various print statements to be conditional on `verbose` (or `debug` or `logFile` presence) for events like disk spindown/spinup, and reasons for skipping spindown (e.g., device mounted). Enhance messages for Btrfs and ZFS devices when spindown is skipped due to being mounted. Remove the `LastSpunDownAt` field from the detailed disk state debug output.
Here's a summary of the changes made to hd-idle:
Added creation of /var/run/hd-idle directory at startup
Added writing "0" to /var/run/hd-idle/sdX.status when a disk spins down
Added writing "1" to /var/run/hd-idle/sdX.status when a disk spins up
Error handling for file operations (only logged in debug mode)
The changes maintain all existing functionality while adding the requested status file feature. The status files will be created with:
Content "1" when the disk spins up
Content "0" when the disk spins down
File permissions 0644 (readable by all users)
The implementation is robust and handles cases where:
The directory doesn't exist (it will be created)
File writes fail (errors are logged in debug mode)
Multiple disks are being monitored (each gets its own status file)