MacOS – Customize external HDD spindown timeout

hard drivemacospowersoftware-recommendation

It's possible to enable spinning down of mechanical hard drives using the "Put hard disks to sleep when possible" option in Energy Saver, and it's possible to customize the timeout period with sudo pmset -a disksleep MIN.

However, if I understand the man pages correctly, this applies to all hard drives connected to the system. Is it possible to only target one HDD (ideally, by UUID)? I have no objection to installing a 3rd party app to accomplish this functionality.

Best Answer

The Terminal command diskutil eject <disk_identifier> is what you are looking for. <disk_identifier> can take the UUID of the drive as an argument.

To get the disk identifier of all mounted disks, execute the mount command.

On my Mac, the mount command gives this:

/dev/disk3 on / (hfs, local, journaled)    
/dev/disk4s2 on /Volumes/iTunes (hfs, local, nodev, nosuid, journaled, noowners)    
/dev/disk5s2 on /Volumes/TM_Backup (hfs, local, nodev, nosuid, journaled) 

To spin down /Volumes/iTunes, I'd execute either one of the commands

diskutil eject /dev/disk4

or

diskutil eject /Volumes/iTunes.

To spin up /Volumes/iTunes, I need to execute the command:

diskutil mountDisk /dev/disk4. mountDisk only works with /dev/disk* disk identifiers.

See man diskutil for more information.