Skip to content

Monitors the state of an autofs share and puts USB hubs into standby mode whenever possible

License

Notifications You must be signed in to change notification settings

passuf/autofs-standby

Repository files navigation

autofs-standby

Monitors the state of an autofs share and puts USB hubs into standby mode whenever possible.

⚠️ Please note: This is an experimental prototype for my very specific setup (Raspberry Pi 4 + Fantec QB-35US3R (4 x 3.5") RAID). If you inted to use this with your own setup, make sure not to power-off any USB devices while performing critical operations.

Installation

Prerequisites

  1. Download and install https://github.com/mvp/uhubctl (make sure you can turn the correct USB hub on and off)
  2. Install autofs: sudo apt install autofs

Configure AutoFS

  1. Create the directory where the share is mounted: sudo mkdir /autofs
  2. Adjust the uuid of the drive to ./auto.vault.sh (can be checked with sudo lsblk -f)
  3. Copy the files ./auto.vault and ./auto.vault.sh to /etc and chown them to root
  4. Add the following line to /etc/auto.master: /autofs program:/etc/auto.vault.sh --timeout=300 --ghost (make sure there is an empty line at the end of the config, otherwise the daemon will not load properly)
  5. Restart autofs: sudo service autofs restart

Create a Standby Watchdog Service

  1. Copy standby_watchdog.service to /etc/systemd/system/: sudo cp standby_watchdog.service /etc/systemd/system/
  2. Start the service: sudo systemctl start standby_watchdog
  3. Start the service on boot: sudo systemctl enable standby_watchdog
  4. Register a service to run standby_watchdog.py in the background

Testing / Troubleshooting

  1. Check if USB can be powered on and off using uhubctl:
    1. power on: sudo uhubctl -l 1-1 -a on
    2. power off: sudo uhubctl -l 1-1 -a off
  2. Access the share: ls -la /autofs/vault
  3. Monitor standby_watchdog.service to see if the mounted share is detected.
  4. Wait the timeout specified in auto.vault.sh and try to access the share again.
  5. Wait the timeout specified in standby_watchdog.py (SLEEP_DURATION * STANDBY_COUNT seconds) to check if USB is automatically powered off.

About

Monitors the state of an autofs share and puts USB hubs into standby mode whenever possible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published