1

I have an external drive, a "Western Digital My Passport for Mac". I usually leave it connected and walk away from my MacBook Pro. The Mac often went to slumber and many times the "not properly ejected" message pops up. Being used to Windows I just clicked it away. Windows often gives errors that have no consequences. Until at one time the disc stopped mounting. I can't help but think that that is connected to the error and lack of ejecting properly.

Is there a way to have the Mac eject USB drives safely when it goes to sleep? Either of it's own accord or even when I have it go to slumber or close the lid?

It's just very cumbersome to have to eject the drive every time I walk away. Having a very chaotic nature doesn't help with that sort of thing.

BTW, just yesterday I got the drive to mount read-only through the macOS Disc Uility app. So I salvaged my files. Would still rather not have that again, because the drive contained some photo's that weren't yet backed up. BTW, the error it displays is with the volume selected (disk passes the first test):

Schijf-EHBO uitvoeren op 'My Passport for Mac' (disk2s2)

Bestandssysteem herstellen.
Het volume is al gedeactiveerd.
fsck_hfs -fy -x /dev/rdisk2s2 uitvoeren
Eindcode bestandssysteem is 8.
De oorspronkelijke status wordt teruggezet naar gedeactiveerd.
Controle of herstel van bestandssysteem mislukt.

Bewerking mislukt…

A Google Translate, in English, of the message above:

Perform disk first aid on 'My Passport for Mac' (disk2s2)

Restore file system.
The volume has already been deactivated.
Run fsck_hfs -fy -x / dev / rdisk2s2
File code final code is 8.
The original status is reset to deactivated.
File system check or restore failed.

Operation failed ...
  • Is something using a file on the drive, preventing it from auto-unmounting? I don't receive this error when my machine running 10.10.5 goes to sleep & wakes up. – Scottmeup Jun 21 at 14:17
  • Hey, I started having this disconnection issue also recently. I can't recall ever having this issue before on a Mac in the last 5 years. So I am hoping that is a temporary bug. – n1000 Jun 21 at 14:22
  • Actually this happened two years ago. I think this drive was used as a time machine backup disk, which is why I had it connected all the time. i have since bought a home NAS where I have the time machine backup to now. Still often goes wrong, disconnects, suddenly I see that it hasn't been making backups for a couple of weeks. Anyway. Thanks for all the answers! Jettison is a cheap enough program I guess, but still surprised MacOS doesn't have anything built in. – dDutch Jun 23 at 21:18
1

There's a 3rd party app available for exactly this purpose. Jettison app automatically ejects your external drives when you put your MacBook to sleep.

It is a paid app with 15 days of free trial available.

0

There may be a native way to accomplish your goal; however I do not know how and why I use EventScripts, which among the events it can react to, Computer will sleep and Computer wakes could be use to unmount/remount an attached USB Drive using AppleScripts, shell scripts and or Automator workflows.

You can download the demo version from the developers web site. The app costs $3.99 USD in the App Store in the USA.


Note that I am a paid customer and have no other affiliation with Mousedown Software, the developer of EventScripts.

0

Jettison is an excellent recommendation, and probably the one I would make for most people.

However, if you want to get into all sorts of Mac automation, you'll definitely want to checkout Keyboard Maestro. You can create a macro that will run when the system goes to sleep, and have that macro run a simple shell script like this:

#!/bin/zsh -f 

MNTPNT='/Volumes/Western Digital My Passport for Mac'

COUNT='0'

while [[ -e "$MNTPNT" ]]
do

     /usr/sbin/diskutil unmount "$MNTPNT"

     ((COUNT++))

     [ "$COUNT" -ge "10" ] && exit 0

done

exit 0

that will check to see if the drive is mounted, and if it is, it will try to unmount it.

In fact, it will keep trying if it doesn't succeed.

Keyboard Maestro says that it will only delay sleep for a maximum of 30 seconds, but I added a counter that will give up after 10 tries, because if it hasn't worked by then, it probably isn't going to work.

Anyway, just to show that there are other ways of doing it.

I assume there's a way to try with AppleScript as well, which Keyboard Maestro could also do, but I know shell scripting better than AppleScript.

You must log in to answer this question.

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