I need to start/stop an external hard drive (USB) from a shell or python script. Actually the external hard drive automatically stops when ejected. So, is it possible to programmatically eject / start an external hard drive? Something like USBDeview does for Windows :-)


My intended use case: I want to run a nightly backup to the external drive. As the drive is quite loud and to save on energy, I only want it to be active during the backup. I likely won't use Time Machine, but my own backup script.

  • 1
    Can you explain the wider scope of the problem, and what you mean by 'start/stop'? You can mount and unmount the drive in the shell very easily with mount and umount. – benwiggy Mar 2 '20 at 9:32
  • Thanks, good question - I updated my question with the use case :-) – stefan.at.wpf Mar 2 '20 at 12:35
  • 1
    Long story short..you can't. However, a "noisy" hard drive is a red flag for me. Whether it's a well used drive on it's last legs or a new drive with poor quality components, you shouldn't have noisy drives in this day and age. Spend the money and get a new one - after all, you're backing up your data. I always ask my clients the same thing when they try to justify sketchy hardware..."How much is your data worth?" I'll bet it's worth orders of magnitude more than a new USB drive ($70-100USD) – Allan Mar 2 '20 at 13:51
  • I'm with Allan: a noisy drive is a worrisome drive. Also, a mechanical drive's power consumption is between 5 and 7 watts. While energy saving is commendable, you're looking at c. 1 watt difference by spinning down. An SSD will run at around 2W continuously, and be silent. – benwiggy Mar 2 '20 at 14:37
  • Thanks for your comments, but the hard drive is technically fine. It's a 3,5" disk and with noisy I mean I hear them, which is normal. Sorry if this lead to confusion. It's a 6 TB disk, so replacing it by an SSD is not an option for me. – stefan.at.wpf Mar 2 '20 at 15:02

You could use pmset disksleep TIME to set a timeout for the disk to go into standby mode. This way, you wouldn't have to mount/unmount the disk every time you want to access it. TIME is the time in minutes.

If you set the time to 0, the timeout is disabled, so if you want to keep it spinning you can set it to that.

  • Thank you, but it sounds like this would affect all external drives. Is something like that possible for only a specific drive? – stefan.at.wpf Mar 2 '20 at 12:36
  • I correct myself, as this if not "stopping disk" but sending disk to sleep when inactive, this could maybe work. I will give it a try. – stefan.at.wpf Mar 2 '20 at 15:05
  • did that work out for you? – Ant Mar 9 '20 at 11:03

Not the answer you're looking for? Browse other questions tagged .