Make Mac eject external drives when going to slumber or sleep/wake

external-diskhard drivesleep-wakeusb

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 ...

Best Answer

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.