This is an example how you to set the hard drive into a standby or hibernate mode after a defined time. This saves power and protects the hard drive in continuous or server use.
Requirements:
- A mounted USB hard drive (Tutorial)
- As a first step we need to update the package lists of Raspbian. We further need to install hdparm.
sudo apt-get update && sudo apt-get -y install hdparm
- To figure the name under which the hard drive is mounted in the system we need to use the following command. In this example, it is
/dev/sda
sudo fdisk -l
- We check the current power mode status. In case it returns the status unknown, it is impossible to set the hard drive to a standby mode. Your HDD does not support spin down/hd-idle.
sudo hdparm -C /dev/sda
“-C shows the current “Power-Mode-Status” of an IDE hard drive. The return value can have the following states:- “unknown” – The hard drive does not support the command
- “active”/”idle” – Standard operation
- “standby” – Low power mode, the hard drive does not spin or even sleeps completely
The options -S, -y, -Y and -Z can be used to change the IDE power mode. wiki.debianforum.de
- We use the parameter
-y
to set the hard drive to the standby mode. The hard drive should now be completely quiet. The commandsudo hdparm -C /dev/sda
can be used to check if the hard drive is in standy mode. As soon as the hard drive is accessed it should start to spin again.sudo hdparm -y /dev/sda
- Now we need the UUID of the hard drive. Type the following command into the console and note the UUID of the hard drive.
sudo blkid
- Open the hdparm config file with the text editor Nano.
sudo nano /etc/hdparm.conf
Replace yourUUID with the previously noted UUID and add the text shown below at the end of the file. Exit the Nano text editor afterwards with
Strg
+x
(Win)ctrl
+x
(Mac) and confirm the changes withy
orj (
depending on your language settings)./dev/disk/by-uuid/yourUUID { spindown_time = 240 }
The number behind spindown_time tells after what time the hard drive will be set to its standby mode. Choose the time not to short as a continuous start-up of the hard drive will harm its motor and mechanics.0 = Standy activated
60 = 5Min (60*5Sec=300Sec=5Min)
240 = 20Min (240*5Sec=1200Sec=20Min)
From 240 the calcuation changes
241 = 30Min (1*30Min)
242 = 60Min (2*30Min) - Now restart the system with the command shown below. After that the hard drive will automatically go into standby mode after the time you have set.
sudo reboot