Automatically fix mount on systemd unit failure due to bad mount
1
vote
0
answers
392
views
For quite some time, I've been fighting a problem with my Raspberry Pi having difficulty to maintain a connection to my external HDD. Sometimes it just randomly throws I/O error, and when that happens, my rtorrent service unit fails with it. Now I tried many things, this is the solution that I have now:
[Unit]
Description=rTorrent
After=network.target
[Service]
User=root
Type=forking
KillMode=none
ExecStartPre=/home/pi/mount_media.sh
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent
WorkingDirectory=/home/pi
Restart=on-failure
[Install]
WantedBy=default.target
Where mount_media.sh simply remounts the directory.
Stuff I also tried but didn't work:
- OnFailure start different unit which remounts the directory
- Start the unit with a script, which remounts the drive and then starts rtorrent
Right now, this approach has left me with "
cannot access 'Media': Transport endpoint is not connected
"
Forgot to add: /media/Media is my mount point
So how should I take care of a moot point randomly disconnecting?
Asked by Meowxiik
(95 rep)
Feb 18, 2018, 06:33 PM