Systemd turn off USB backup drive on boot

January 4, 2021 - Reading time: ~1 minute

Need to turn off the USB backup drive to stop it needlessly spinning
Source of info here --> https://www.howtogeek.com/687970/how-to-run-a-linux-program-at-startup-with-systemd/

The bash script to turn off the USB drive in /usr/local/bin/

#!/bin/bash
echo -n '2-1' | tee /sys/bus/usb/drivers/usb/unbind

The service file called disable-USB-backup.service in /etc/systemd/system/

[Unit]
Description=Turn off USB backup drive on boot

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/disable_USB_backup.sh
Restart=on-failure
KillMode=process

[Install]
WantedBy=multi-user.target

LazyCoderOZ

I am a Linux guy, been around for 20+ years using Linux as my daily driver.
This is my blog on my discoveries and notes so I don't forget how I have done things :)