DanMa
Posts: 6
Joined: Tue Aug 06, 2019 5:39 pm

mounted external Hard Drive is not spinning

Tue Aug 06, 2019 6:00 pm

Hello together,

i have a external Hard Drive which i want to sent in spin down after 20 minutes.
I do this via hdparm and this is working perfectly if the drive is not mounted.

I can execute it manually as well:

Code: Select all

sudo hdparm -y /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
/dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355:
 issuing standby command
but then directly after (if the drive is mounted):

Code: Select all

sudo hdparm -C /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355

/dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355:
 drive state is:  active/idle
How could i get it working that my system will not try to hold the hard drive active while its still mounted.

Here is an output which checks what is actually trying to access the ext hard drive:

Code: Select all

sudo fuser -mv /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
                     BEN.        PID ZUGR.  BEFEHL
/dev/sdb:            root     kernel mount /mnt/ext-hdd
Greetings

Daniel
Last edited by DanMa on Thu Aug 08, 2019 7:21 am, edited 3 times in total.

User avatar
default_user8
Posts: 678
Joined: Mon Nov 18, 2013 3:11 am

Re: mounted external Hard Drive is not spinning

Tue Aug 06, 2019 9:21 pm

Daniel,
You are using the wrong option, -y forces the drive into a low power state, try using -S which tells the drive to spin down after a specified amount of time of inactivity. If you were to use -Y option your drive would work as your expecting it to act, but the result is an immediate spindown. I use this for my mirror drive on my home NAS and it works like a charm.
The command you want would look like this:

sudo hdparm -S 240 /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355

Here is the description of the option:
-S Put the drive into idle (low-power) mode, and also set the
standby (spindown) timeout for the drive. This timeout value
is used by the drive to determine how long to wait (with no
disk activity) before turning off the spindle motor to save
power. Under such circumstances, the drive may take as long
as 30 seconds to respond to a subsequent disk access, though
most drives are much quicker. The encoding of the timeout
value is somewhat peculiar. A value of zero means "timeouts
are disabled": the device will not automatically enter standby
mode. Values from 1 to 240 specify multiples of 5 seconds,
yielding timeouts from 5 seconds to 20 minutes. Values from
241 to 251 specify from 1 to 11 units of 30 minutes, yielding
timeouts from 30 minutes to 5.5 hours. A value of 252
signifies a timeout of 21 minutes. A value of 253 sets a
vendor-defined timeout period between 8 and 12 hours, and the
value 254 is reserved. 255 is interpreted as 21 minutes plus
15 seconds. Note that some older drives may have very
different interpretations of these values.

and the page where i found it is here:
http://man7.org/linux/man-pages/man8/hdparm.8.html
Two heads are better than one, unless one's a goat head.

DanMa
Posts: 6
Joined: Tue Aug 06, 2019 5:39 pm

Re: mounted external Hard Drive is not spinning

Thu Aug 08, 2019 3:03 pm

Hello default_user8,

thanks, but this is not my issue.

My issue is that my external hard drive goes not in spin down while its mounted, or better said it tries to go in spin down (you can hear it) but it wakes up directly.

If i unmount the drive its working.

So also with your command

Code: Select all

sudo hdparm -S 240 /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
Is it going to sleep for 1 second and then waking up directly.

The only process which is trying to access is the mount process:

Code: Select all

fuser -mv /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
                     BEN.        PID ZUGR.  BEFEHL
/dev/sda:            root     kernel mount /mnt/ext-hdd
Greetings
Daniel

swampdog
Posts: 246
Joined: Fri Dec 04, 2015 11:22 am

Re: mounted external Hard Drive is not spinning

Thu Aug 08, 2019 9:30 pm

There needs to be some enforcement of standards in the usb/external area of computing.

I have..
  • 3 esata caddies.
    6 usb caddies.
    4 unpowered usb/sata adapters.
..where one of the above is a dual usb/esata caddy.

Two of the esata caddies work (on PC) as designed. The dual usb3/esata caddy does not work with esata (on PC). Two of the six usb caddies are usb2 and never power down (PC or Pi, mounted or not). Three of the six usb caddies are usb3 and do nothing but power down (mounted or not) - usually so quickly it isn't practical to use one on a pi (for booting off of). Of the unpowered usb/sata adapters, at least one works flawlessly on PC but not on a pi, one caused a kernel panic (even with no ssd plugged in) on a pi (not about to plug that into my PC) and I just can't be bothered to test the other two unpowered ones on my PC at this time.

Most of them purport to be made by the same few manufacturers. I'm sure you're aware there's a "grey" clone industry.

I've come to the conclusion the only sure way to power cycle one of these devices is to hit its power button so I'll be buying one of those HAT's with relays in. It isn't a raspberry pi problem btw, just that the rpi can solve it.

User avatar
default_user8
Posts: 678
Joined: Mon Nov 18, 2013 3:11 am

Re: mounted external Hard Drive is not spinning

Thu Aug 08, 2019 9:42 pm

DanMa wrote:
Thu Aug 08, 2019 3:03 pm
Hello default_user8,

thanks, but this is not my issue.

My issue is that my external hard drive goes not in spin down while its mounted, or better said it tries to go in spin down (you can hear it) but it wakes up directly.

If i unmount the drive its working.

So also with your command

Code: Select all

sudo hdparm -S 240 /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
Is it going to sleep for 1 second and then waking up directly.

The only process which is trying to access is the mount process:

Code: Select all

fuser -mv /dev/disk/by-uuid/f702eda2-2ebe-4aa6-bad8-da80e5f2b355
                     BEN.        PID ZUGR.  BEFEHL
/dev/sda:            root     kernel mount /mnt/ext-hdd
Greetings
Daniel
While mounted if it's spinning down and immediately spinning back up something is reading from or writing to the drive, your statement that it works while unmounted supports that since while unmounted whatever is trying to read or write to the drive cannot access the drive. Your primary drive may never spin down depending on what you are using that drive for.
Two heads are better than one, unless one's a goat head.

DanMa
Posts: 6
Joined: Tue Aug 06, 2019 5:39 pm

Re: mounted external Hard Drive is not spinning

Fri Aug 09, 2019 11:31 am

Hello together,

@swampdog thanks for you conclusion. But my external hard drive has the ability to go in spin down.

@default_user8 thanks for your explanation, thats the reason why iam using

Code: Select all

fuser -mv /mountpoint
which shows me what is trying to get access to the external hard drive. The only thing is what i can see, is the mount point itself. I already tried to kill every access with

Code: Select all

fuser -kim /mountpoint
To be sure that really nothing else is on my raspberry which could try to get access to the external hard drive, i installed the raspberry pi completly new.
But same situation.

Could it be the way how i mount it as the reason why the mountpoint tries to hold it everytime?
I mount it so

Code: Select all

mount /dev/sda /mnt/ext-hdd
I had to format my external hard drive from NTFS to extfat4, since this time iam facing this issue.

Greetings

Daniel

epoch1970
Posts: 3794
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: mounted external Hard Drive is not spinning

Fri Aug 09, 2019 12:09 pm

You should not spin down a mounted file system. The OS or file system driver might want to access it, not only applications.
If you can unmount, then the drive should spin down (on its own usually) and will not spin up until you remount.

Use an automounter to automate mount/dismount if needed.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

DanMa
Posts: 6
Joined: Tue Aug 06, 2019 5:39 pm

Re: mounted external Hard Drive is not spinning

Sun Aug 11, 2019 6:13 pm

@epoch1970 its normally not needed that i have to umount it first.

I found an article how i can prepare everything to let my ext hdd go in spindown.
https://www.gargi.org/index.php?title=Z ... d_Spindown

After this, everything works fine.

Hope this helps also someone else.

epoch1970
Posts: 3794
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: mounted external Hard Drive is not spinning

Sun Aug 11, 2019 7:38 pm

DanMa wrote:
Sun Aug 11, 2019 6:13 pm
@epoch1970 its normally not needed that i have to umount it first.
Yes it is. A mounted file system is available to the system. Same as removing a mounted USB key, trying to spin down a mounted drive is a bad idea.
Your link proposes removing journaling from ext4. That is hardly a “normal” setup.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Beginners”