Greetings!
I have a 1TB external drive plugged into my pi and tried installing hdparm to get it to spin down when not in use but I believe "write cache is not possible for the drive". I was following a guide here https://www.htpcguides.com/spin-down-an ... pberry-pi/
Any suggestions? I wasn't even aware that I had to worry about spinning down the drive but I came across that article recently and started to wonder.
Re: Spin down external hard drive
Hdparm is slowly falling into obsolescence.
Of the modern USB drives I've used with a Pi, none were supported by hdparm.
But they would spin down by themselves when not in use. The best way IMHO to tell a modern drive it is no longer in use is to unmount it. It will spin down shortly after.
You can automate that with an automounter or scripts.
HTH
Of the modern USB drives I've used with a Pi, none were supported by hdparm.
But they would spin down by themselves when not in use. The best way IMHO to tell a modern drive it is no longer in use is to unmount it. It will spin down shortly after.
You can automate that with an automounter or scripts.
HTH
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel
Re: Spin down external hard drive
Subject: Spin down external hard drive
epoch1970 wrote:
Hdparm is slowly falling into obsolescence.
Of the modern USB drives I've used with a Pi, none were supported by hdparm.
But they would spin down by themselves when not in use. The best way IMHO to tell a modern drive it is no longer in use is to unmount it. It will spin down shortly after.
You can automate that with an automounter or scripts.
HTH
The problem is I have an IP camera recording to it over FTP whenever it detects motion so I can't unnmount it since I need it on standby.
Will I really shorten its life if I don't spin it down?
epoch1970 wrote:
Hdparm is slowly falling into obsolescence.
Of the modern USB drives I've used with a Pi, none were supported by hdparm.
But they would spin down by themselves when not in use. The best way IMHO to tell a modern drive it is no longer in use is to unmount it. It will spin down shortly after.
You can automate that with an automounter or scripts.
HTH
The problem is I have an IP camera recording to it over FTP whenever it detects motion so I can't unnmount it since I need it on standby.
Will I really shorten its life if I don't spin it down?
- InsulationTape
- Posts: 37
- Joined: Sun Jul 09, 2017 1:27 pm
- Location: armed with a glue gun
Re: Spin down external hard drive
IME keeping hard drives on gives them life, it is the power cycling that finishes them off.
I back up my "research" with the anecdote lots of people will have heard about hard drives, "it was OK last time I used it".
A spun-down hard drive might save battery life, if applicable (ie laptops, and not most Pis), but to keep a drive going for years I think keeping them powered-up and spinning is best. If an HDD is being run flat-out most of the time and is insulated then power control might extend its life, but just dealing with the heat is probably a better aim.
I had a USB HDD for a while and I couldn't get it to stay powered on. In the end I set up a cron'd script to just tickle the drive frequently enough that it wouldn't spin down. As it happened the drive did die anyway, some cheap Samsung 1.5T IIRC from a computer fair.
It might be worth looking at smartd and have the drive test itself periodically, and send a notification if the drive looks to be failing. I say this with an HDD here like this:
I manually keep an eye on this 40gig drive as smartd would likely moan far too much. The HDD was originally in a Tosh laptop I bought in ~2006. It is now in a first gen Mac Mini, which is a firewall for a shoddy IoT camera, and some other general network tasks (rsyslog for the router, etc.). But the total power on time for the HDD is over 10 years! The test log has all "Completed without error".
I know some story on the internet does not prove much, but frankly that blog post is just one rung above a forum post
I am shamelessly advocating sleep-depriving that drive like a tasteless Guantanamo joke.
These are the settings for the Mac's HDD:
I back up my "research" with the anecdote lots of people will have heard about hard drives, "it was OK last time I used it".
A spun-down hard drive might save battery life, if applicable (ie laptops, and not most Pis), but to keep a drive going for years I think keeping them powered-up and spinning is best. If an HDD is being run flat-out most of the time and is insulated then power control might extend its life, but just dealing with the heat is probably a better aim.
I had a USB HDD for a while and I couldn't get it to stay powered on. In the end I set up a cron'd script to just tickle the drive frequently enough that it wouldn't spin down. As it happened the drive did die anyway, some cheap Samsung 1.5T IIRC from a computer fair.
It might be worth looking at smartd and have the drive test itself periodically, and send a notification if the drive looks to be failing. I say this with an HDD here like this:
Code: Select all
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 100 100 046 Pre-fail Always - 184533
2 Throughput_Performance 0x0005 100 100 030 Pre-fail Offline - 10420380
3 Spin_Up_Time 0x0003 100 100 025 Pre-fail Always - 1
4 Start_Stop_Count 0x0032 098 098 000 Old_age Always - 6181
5 Reallocated_Sector_Ct 0x0033 100 100 024 Pre-fail Always - 0 (2000 0)
7 Seek_Error_Rate 0x000f 100 100 047 Pre-fail Always - 3381
8 Seek_Time_Performance 0x0005 100 100 019 Pre-fail Offline - 0
9 Power_On_Seconds 0x0032 001 001 000 Old_age Always - 89116h+20m+03s
10 Spin_Retry_Count 0x0013 100 100 020 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 4015
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 237
193 Load_Cycle_Count 0x0032 057 057 000 Old_age Always - 869830
194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 44 (Min/Max 6/56)
195 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age Always - 455
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0 (0 6906)
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x000f 100 100 060 Pre-fail Always - 9807
203 Run_Out_Cancel 0x0002 100 100 000 Old_age Always - 429595295995
I know some story on the internet does not prove much, but frankly that blog post is just one rung above a forum post

These are the settings for the Mac's HDD:
Code: Select all
/dev/disk/by-id/ata-FUJITSU_MHV2040AH_NT43T6329P59 {
spindown_time = 0
acoustic_management = 254
apm = 255
}
Re: Spin down external hard drive
That makes a lot of sense. I think I wil just leave it be and make sure I have a backup but you are right, keeping it spinning definetely makes more sense.
What would be the best way to test this drive for errors? Is it possible to get it done in the pi itself? I use OSX as my daily computer so I may also be able to plug it into that?
What would be the best way to test this drive for errors? Is it possible to get it done in the pi itself? I use OSX as my daily computer so I may also be able to plug it into that?
- startrek.steve
- Posts: 390
- Joined: Thu Aug 30, 2012 7:19 pm
Re: Spin down external hard drive
I always thought you couldnt run SMART on a USB Attached drive? I could never get SMART to see it?
Pi 2 running LibreElec Krypton, Pi 2 running Wheezy Desktop, Pi 1 headless Wheezy, downloading Radio, Pi 1 running Picore headless Media Server, Pi Zero to be an Old Time Radio Project. Pi 3 testing. Pi Zero W downloading Radio shows headless.
Re: Spin down external hard drive
Sometimes you need to add extra options to support the controller. I've used SMART and hdparm on USB attached drives to control and check them. I used to have a USB HDD that was dedicated for backups and was spun up automatically once a week for that purpose.startrek.steve wrote:I always thought you couldnt run SMART on a USB Attached drive? I could never get SMART to see it?
- InsulationTape
- Posts: 37
- Joined: Sun Jul 09, 2017 1:27 pm
- Location: armed with a glue gun
Re: Spin down external hard drive
Ah yes, I've seen that. IIRC some USB-SATA bridges simply don't support what's necessary. Maybe even some USB-PATA ones, too. I'm sure I've seen this problem right back when PATA was more common.startrek.steve wrote:I always thought you couldnt run SMART on a USB Attached drive? I could never get SMART to see it?
One of the bajillion projects revolving around my Pi is some CCTV hackery. I've got a webcam and video grade HDD in a USB enclosure (originally from a Sky+ box or similar, I think) plugged into my Pi. I'm eye-balling zoneminder....
I can confirm that smartctl can query the drive connected to my Pi, using one of these:
Code: Select all
Bus 001 Device 005: ID 1bcf:0c31 Sunplus Innovation Technology Inc. SPIF30x Serial-ATA bridge
These two options didn't work (though I did not try every hdparm feature):
-Z Disable Seagate auto-powersaving mode
-i Display drive identification
I do have a Seagate drive beyond the USB bridge, so -Z is not outside the realm of possibility. It looks like with my USB-SATA bridge I can do things like set drive power otherwise, the performance test. I'm not sure I believe the -C option, "Check drive power mode status".
Code: Select all
root@sentry:~$ touch /mnt/vid/scratch/delme ; sync
root@sentry:~$ rm /mnt/vid/scratch/delme ; sync
root@sentry:~$ hdparm -C /dev/sda
/dev/sda:
drive state is: standby
Last edited by InsulationTape on Mon Jul 17, 2017 3:50 pm, edited 1 time in total.
- InsulationTape
- Posts: 37
- Joined: Sun Jul 09, 2017 1:27 pm
- Location: armed with a glue gun
Re: Spin down external hard drive
I'm pretty sure this is the right package name for the command line program.junior466 wrote:What would be the best way to test this drive for errors? Is it possible to get it done in the pi itself? I use OSX as my daily computer so I may also be able to plug it into that?
Code: Select all
apt-get install smartmontools
Code: Select all
smartctl --all /dev/sda | less
Code: Select all
smartctl --test=long /dev/sda
Code: Select all
smartctl --all /dev/sda | less
Code: Select all
#1 Extended offline Self-test routine in progress 90% 430 -
Code: Select all
# 2 Extended offline Completed without error 00% 243 -
Re: Spin down external hard drive
Excellent! Thank you so much for your help!
Re: Spin down external hard drive
So it appears that my drive doesn't support testing. Here's the output of sudo smartctl -a /dev/sda2
and then:
sudo smartctl --test=long /dev/sda2
So I guess I'm out of luck?
Code: Select all
=== START OF INFORMATION SECTION ===
Vendor: SAMSUNG
Product: HD103SI
Revision:
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Logical block size: 512 bytes
Device type: disk
Local Time is: Tue Jul 18 20:22:01 2017 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Disabled or Not Supported
=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK
Error Counter logging not supported
Device does not support Self Test logging
sudo smartctl --test=long /dev/sda2
Code: Select all
smartctl 6.4 2014-10-07 r4002 [armv7l-linux-4.9.35-v7+] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
Long (extended) offline self test failed [unsupported scsi opcode][/size]
- InsulationTape
- Posts: 37
- Joined: Sun Jul 09, 2017 1:27 pm
- Location: armed with a glue gun
Re: Spin down external hard drive
I think that'll be your bridge not passing things through properly, rather than the drive itself. smartctl says SMART is supported by the drive, but then fails to get the SMART data. And then you can't tell it to run a test. IMHO the "unsupported scsi opcode" is due to what's controlling the drive rather than the drive itself.
Try another USB-SATA adapter if you have one. Or if not you could hook the drive up to a normal PC for a while to test it. Smartmontools is available for Windows, https://www.smartmontools.org/wiki/Down ... owspackage , but you could use a Linux live CD/DVD/USB and run smartctl in that. Debian's LXDE live CD is likely very similar to using a Pi, the default username and password for Debian live CDs is user and live. https://www.debian.org/CD/live/
Having a Google there is evidence that the drive's SMART does work, this bug report contains smartctl reading SMART data from a HD103SI https://sourceforge.net/p/smartmontools ... /26399651/ . This screenshot from a German forum looks exactly like SMART data https://www.computerbase.de/forum/attac ... 1266023150 .
But those Samsung green drives had a terrible reputation, or at least one manufacturer's green product line. They are so keen on powering down they heat/cool far too much and just kill themselves. IIRC trying to reign in their keenness to spin-down is either impossible or very tricky. By all means use the drive, but have good backups!
Try another USB-SATA adapter if you have one. Or if not you could hook the drive up to a normal PC for a while to test it. Smartmontools is available for Windows, https://www.smartmontools.org/wiki/Down ... owspackage , but you could use a Linux live CD/DVD/USB and run smartctl in that. Debian's LXDE live CD is likely very similar to using a Pi, the default username and password for Debian live CDs is user and live. https://www.debian.org/CD/live/
Having a Google there is evidence that the drive's SMART does work, this bug report contains smartctl reading SMART data from a HD103SI https://sourceforge.net/p/smartmontools ... /26399651/ . This screenshot from a German forum looks exactly like SMART data https://www.computerbase.de/forum/attac ... 1266023150 .
But those Samsung green drives had a terrible reputation, or at least one manufacturer's green product line. They are so keen on powering down they heat/cool far too much and just kill themselves. IIRC trying to reign in their keenness to spin-down is either impossible or very tricky. By all means use the drive, but have good backups!
- DougieLawson
- Posts: 42176
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Spin down external hard drive
Try running sudo smartctl -a /dev/sda as that's more likely to work.junior466 wrote:Here's the output of sudo smartctl -a /dev/sda2
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.