Also assuming that the title and the first half of the question is your actual question, there's more magic to be done through hdparm. If you can live with the disks spinning up and then shutting down, you can use hdparm to instruct the disk to spin down after a short period of inactivity. This is done through its -S
(upper case S
) parameter.
Setting a spindown timeout means the disk still spins up normally during the power-on, but then spins down at some reasonably determinate time thereafter. This is usually safer than setting the disk to power up in standby.
Note that, as stated in the man page:
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.
Hence, if you want to spin down the disk /dev/sdb and sets its idle spindown time to one minute, you'd use:
sudo hdparm -S12 /dev/sdb
You could add such hdparm commands to a late boot script like /etc/init.d/rc.local, or your distribution may offer a specific init script configuration file to do it. For example, on Debian, you'd edit /etc/hdparm.conf to include:
/dev/sdb { spindown_time = 12 }
I would suggest using an appropriate name from one of the /dev/disk/by-* directories (/dev/disk/by-id might be easiest to read as the names there include both the disk model number and serial number) rather than the /dev/sdX name, particularly in a boot script or configuration file referenced from a boot script such as hdparm.conf. (Any disk changes could cause those names to change, but the /dev/disk/by-* names will remain the same.)
In order to prevent the file systems from being mounted, add the noauto
option to the relevant /etc/fstab entries. You will still be able to mount the file systems normally by manually running sudo mount /some/mount/point
and not mounting the file systems unless/until they are needed will usually reduce the probability of unexpected disk activity (which would cause those noisy disks to spin up, then spin down again after reaching the spindown timeout).