I have a laptop with a ssd for primary OS drive, and a large Spinning disk for storage. I currently have an alias I use for manually spinning down the drive when I'm not using it (after umount of course):
sudo hdparm -y /dev/disk/by-id/ata-WDC_WD7500BPKX-80HPJT0_WD-WX31AB3N6985
Is this safe to use? Will hdparm
refuse to do this if the drive has yet to sync or if I forget to umount it?
If not, is there a way to use hdparm
(or another util) to check if it is safe to do this?
UPDATE --
As much as I appreciate both of your answers, they don't help me at all, because I've tried countless different value combinations for the APM and Spin-down time settings, with no results aside from a) less than 10 seconds before spin-down b) no spin-down but random parking, or c) no spin-down or parking. I've also tried to search the web for my specific drive model and its respective APM values, to no avail.
So, the direction I'd like to go in is this:
I need to figure out a way to see if the disk is in use so I can write a systemd service. The closest I can come to so far is lsof | grep /mnt/data
, or some such nonesense. But, as you can see, that is far less than ideal. I'd like a method of attaining this that doesn't depend on a predetermined mount point, or the cpu greedy multiple invocations of lsof +D mntpoint in the answer I provided myself.
Check out my answer below for an idea of what I'm trying to do
-S
option to set a short timeout, that way the device will decide on its own when to spin down.