Automatically fix mount on systemd unit failure due to bad mount

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












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?







share|improve this question
















  • 1




    Have you got a strong enough transformer to keep up with an HDD?
    – Rui F Ribeiro
    Feb 18 at 18:36










  • I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
    – Meowxiik
    Feb 18 at 19:01










  • Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
    – Meowxiik
    Feb 18 at 19:35














up vote
1
down vote

favorite












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?







share|improve this question
















  • 1




    Have you got a strong enough transformer to keep up with an HDD?
    – Rui F Ribeiro
    Feb 18 at 18:36










  • I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
    – Meowxiik
    Feb 18 at 19:01










  • Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
    – Meowxiik
    Feb 18 at 19:35












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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?







share|improve this question












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?









share|improve this question











share|improve this question




share|improve this question










asked Feb 18 at 18:33









Meowxiik

61




61







  • 1




    Have you got a strong enough transformer to keep up with an HDD?
    – Rui F Ribeiro
    Feb 18 at 18:36










  • I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
    – Meowxiik
    Feb 18 at 19:01










  • Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
    – Meowxiik
    Feb 18 at 19:35












  • 1




    Have you got a strong enough transformer to keep up with an HDD?
    – Rui F Ribeiro
    Feb 18 at 18:36










  • I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
    – Meowxiik
    Feb 18 at 19:01










  • Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
    – Meowxiik
    Feb 18 at 19:35







1




1




Have you got a strong enough transformer to keep up with an HDD?
– Rui F Ribeiro
Feb 18 at 18:36




Have you got a strong enough transformer to keep up with an HDD?
– Rui F Ribeiro
Feb 18 at 18:36












I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
– Meowxiik
Feb 18 at 19:01




I think so, I connect it through USB hub, which is power by a 5V, 2A adapter.
– Meowxiik
Feb 18 at 19:01












Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
– Meowxiik
Feb 18 at 19:35




Also no other device is connected to the hub so the 5V, 2A are going directly to the HDD
– Meowxiik
Feb 18 at 19:35















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f425003%2fautomatically-fix-mount-on-systemd-unit-failure-due-to-bad-mount%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f425003%2fautomatically-fix-mount-on-systemd-unit-failure-due-to-bad-mount%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)