The following steps have been tested on Raspberry Pi 3.
When using Raspberry Pi as a file server, it would save energy and extend an external drive's life if it spins down on idle.
For example, if the drive is /dev/sda, use the command to see its hard drive configuration
sudo hdparm -I /dev/sda
Where advanced power management is default to 254. It means to no speed and no spinning down. Now do an experiment with the following commands. They set the advanced power management and spin down time.
sudo hdparm -B 60 /dev/sda
sudo hdparm -S 60 /dev/sda
Check if the external drive spins down after idling a while. Most of popular external hard drives should works with these commands. However, this is temporary. If the computer reboots, the settings are gone. They should be set in the configuration file /etc/hdparm.conf. Append the following lines to the file.
/dev/sda { apm = 60 spindown_time = 60 }
Be careful if more drives are plugged in or USB ports are switched, The drive names sda, sdb or sdc could be switched also.