edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

USB drive auto-reconnect

Mon Oct 26, 2015 11:28 am

Hi Guys

I have literally enough of things not working correctly :D ;)
Don't know if it's me - a newbie in Linux world, or just being unlucky, however I do have an issue which keeps bothering me so badly, that I am almost going mad with it ;)

Anyway - I do have Raspberry Pi 1 model B (700MHz, 512MB RAM) to which I have a lot of USB hard drives connected through powered USB hubs. I have managed to resolve issues with backpower feed and power issues, my raspberry Pi runs flawleslly in the point of view of stability and being a reliable piece of hardware.

The problem is that from time to time, some of my USB hard drives go into the sleep mode (?), which means that once per week, or once per month, I do have an USB drive which becomes unavailable for the NAS share.

My smb.conf file is more or less like this:

Code: Select all


[Archive]
comment = Archive
path = /media/Archive
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no
with additional entries in /etc/fstab :

Code: Select all

UUID=2298CD8598CD5845   /media/Archive  ntfs-3g defaults        0       0
Of course /media/Archive is set for full permission for everyone (chmod 777)
Also ntfs-3g is installed and my samba share works fine, until this particular HDD will decide that "I am tired and I am going to sleep".

I am not 100% sure if Raspberry Pi (debian/linux) is capable of auto-mounting the ntfs drives on a re-connect, I was under impression that Ubuntu does it this way, however I don't know about any official solutions for this.

And now what I have done so far.
All my script files are being held on external HDD called "Intenso" which doesn't go offline because in 99% of time is in use.

Using crontab -e I have scheduled a task which runs every hour.
Script has been set to be executable and checks if directories do exist and if don't, it will run command sudo mount -a and next should send me a text message with a python script file.

Code: Select all

DIRECTORY1=/media/MSI/Karaoke
DIRECTORY2=/media/Archive/Kindle



if [ ! -d "$DIRECTORY1" ]; then
        sudo mount -a
        sudo python /media/Intenso/Raspberry_Pi/Send_SMS.py 'MSI drive reconnected'

fi


if [ ! -d "$DIRECTORY2" ]; then
        sudo mount -a
        sudo python /media/Intenso/Raspberry_Pi/Send_SMS.py 'Archive drive reconnected'

fi
And now my trouble is:

a) is there any better way to keep those disks alive? What I mean, anyone know if there is any auto - mounted back feature?
b) anyone could help me out why the script does not work? I have a feeling that I have missed something elementary and the script does not execute the "sudo python /media/Intenso/Raspberry_Pi/Send_SMS.py 'Archive drive reconnected'" part

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: USB drive auto-reconnect

Mon Oct 26, 2015 11:30 am

Have you disabled the low power mode on your hard drives with sudo hdparm -B 255 /dev/sdX?
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: USB drive auto-reconnect

Mon Oct 26, 2015 11:47 am

This actually - might be a great idea.
I will add it to my Raspberry Pi, however probably won't be able to reply with results in even a month time :D

Anyway - thank you.
Unless there won't be any other suggestions - I will stick to this idea :) :)

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: USB drive auto-reconnect

Mon Nov 16, 2015 12:10 pm

DougieLawson wrote:Have you disabled the low power mode on your hard drives with sudo hdparm -B 255 /dev/sdX?
Hi Dougie

One more time, thank you for looking into it.
Unfortunately, I am in a middle of a different trouble.

I have installed hdparm and found as following:

Code: Select all

/dev/sda1: LABEL="Intenso" UUID="CCE42D8CE42D79BA" TYPE="ntfs"
/dev/sdb1: LABEL="Archive" UUID="2298CD8598CD5845" TYPE="ntfs"
/dev/sdc1: LABEL="MSI" UUID="48DAC8E27AA8D6FF" TYPE="ntfs"
and with hdparm, those are the results for those 3 drives (most trouble I have is the Archive and MSI, so /dev/sdb and /dev/sdc)

Code: Select all

/dev/sda:
 issuing standby command
That one is ok

Code: Select all

/dev/sdb:
 issuing standby command
^[[A HDIO_DRIVE_CMD(standby) failed: Invalid argument
This one is no go with hdparm

Code: Select all

/dev/sdc:
 issuing standby command
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
And this one is also no go.


I will try with hd-idle or sd-parm and see if I can achieve anything using those other power management programs.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: USB drive auto-reconnect

Mon Nov 16, 2015 5:59 pm

You'll need to read the manufacturer's data sheet for your drives, hdparm is supposed to drive a standard SMART function to control drive parameters. If your drive doesn't react correctly that's either a feature that's not implemented or a firmware bug.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: USB drive auto-reconnect

Mon Nov 16, 2015 6:22 pm

I suppose it's because the hdd is in a cheap China usb enclosure. HDDs are capable of smart but not the USB enclosures

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: USB drive auto-reconnect

Mon Nov 16, 2015 8:57 pm

edmun wrote:I suppose it's because the hdd is in a cheap China usb enclosure. HDDs are capable of smart but not the USB enclosures
That's unlikely to be true. The USB stuff should simply pass the SATA commands straight through.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: USB drive auto-reconnect

Tue Nov 17, 2015 8:51 am

I know :) Anyway - I am hoping to book some time in this week to solve the issue, no matter how much time I will have to spend :)

Return to “Beginners”