7

I recently got a LaCie 2TB Thunderbolt bus-powered USB external rugged drive. I am using it with the Raspberry Pi 2 and it works fine. It's being used as a remote backup via rsync.

However, I am use to not leaving a rugged drive powered up all the time. I see no way to power down the LaCie drive when it's not needed for extended periods of time. My experience with self-powered LaCie rugged drives (larger in physical size) is that they run hot to the touch if left on all day even if there is no activity to the drive.

Does the Raspberry Pi 2 put external USB hard disks to sleep after a certain period of inactivity? If so, can this timer(?) be controlled? What is the default?

2
  • Why don't you use hdparm to control this? Jul 7 '15 at 17:29
  • I'm not familiar with using hdparm. I did a search and couldn't find an example of how you might be referring to use it. How can hdparm be used to put the drive to sleep and then to wake it up? Thanks. Jul 7 '15 at 17:44
10

On the Raspberry (I am assuming you use Rasbian), hdparm must be installed,

   sudo apt-get install hdparm

and then you must reboot the RPI in order to allow hdparm to interface itself correctly with udev.

    sudo hdparm -I /dev/sda

will print all of the known characteristics of the device. It is long, and unwieldy, but very thorough.

You are searching for the properties related to Power Management. The ever helpful Arch Linux Wiki says:

-B

Set the Advanced Power Management feature. Possible values are between 1 and 255, low values mean more aggressive power management and higher values mean better performance. Values from 1 to 127 permit spin-down, whereas values from 128 to 254 do not. A value of 255 completely disables the feature.

-S

Set the standby (spindown) timeout for the drive. The timeout specifies how long to wait in idle (with no disk activity) before turning off the motor to save power. The value of 0 disables spindown, the values from 1 to 240 specify multiples of 5 seconds and values from 241 to 251 specify multiples of 30 minutes.

You query the current value of (for instance) B as:

         sudo hdparm -B /dev/sda

and you set it as

         sudo hdparm -B 255 /dev/sda

and likewise for -S.

Once again the ever-helpful states:

Warning: Too aggressive power management can reduce the lifespan of your hard drive due to frequent parking and spindowns.

This should allow you to configure power management to your liking.

0

I've installed hdparm like this:

sudo apt install hdparm
sudo hdparm -y /dev/sda   # Legt HDD sofort schlafen
sudo nano /etc/hdparm.conf

START_HD_IDLE=true
/dev/sda {
  spindown_time = 240
}

sudo hdparm -B 127 -S 240 /dev/sda
sudo hdparm -W 0 /dev/sda1
sudo /usr/lib/pm-utils/power.d/95hdparm-apm resume

I still didn't get the spindown. So I've added hd-idle:

sudo apt-get install build-essential fakeroot debhelper -y
cd Downloads/
wget http://sourceforge.net/projects/hd-idle/files/hd-idle-1.05.tgz
tar -xvf hd-idle-1.05.tgz && cd hd-idle
dpkg-buildpackage -rfakeroot
sudo dpkg -i ../hd-idle_*.deb
sudo nano /etc/default/hd-idle

START_HD_IDLE=true
HD_IDLE_OPTS="-i 1200 -l /var/log/hd-idle.log"

sudo systemctl restart hd-idle

Roughly following the guide from - https://www.htpcguides.com/spin-down-and-manage-hard-drive-power-on-raspberry-pi/

Monitoring

I've monitored the spindowns with:

less +F /var/log/hd-idle.log

I still didn't get the spindowns. Looking at the HDD-LED I could see and hear that something accessed the drive and thus keep it spinning. So I've added two monitoring tools.

Inotify

sudo apt-get install inotify-tools
inotifywait -m /mnt/backup/

and Blktrace

sudo apt install blktrace
sudo btrace /dev/sda

Disable Daemons

Btrace showed lines with "... [smartd]", so I disabled it.

sudo systemctl stop smartd
sudo systemctl disable smartd

and "... [pool]", which is part of the udisk2 crypt-mounting stuff.

sudo systemctl stop udisks2
sudo systemctl disable udisks2

After disabling both daemons I got my spindown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.