Forum

Notifications
Clear all

Automated unmount of external drive


Allison Sheridan
(@podfeet)
Trusted Member
Joined: 6 years ago
Posts: 85
Topic starter  

I have this vague memory that the boys talked about an automation to unmount external drives on bootup or login. I'm hoping I didn't dream it, and that someone has an idea how to do this.

I have a laptop that when plugged into my dock, automounts the backup drive that's plugged into the dock.  I only want this drive mounted when Carbon Copy Cloner runs. I have it mount and unmount the drive programmatically already.

The problem to be solved is that I want it to be faster/easier to just yank the USB-C cable out and grab my laptop instead of having to wake up my Mac, wait for it to log in with my watch or my fingerprint, invariably move some windows to see if the backup drive is mounted, then click the Eject app icon from Parallels Toolbox in my menu bar, wait for the drive to be ejected (not just when it looks ejected, but when it says it’s ejected). Only then can I close the lid and unplug the Mac.

I've been noodling how to have the disk only mount for CCC but I haven't been able to formulate in my head a structure for how this automation would work at the right time only. For example, I need to be able to manually mount it to recover data, and I wouldn't want the automation to immediately unmount it.

So did I dream the guys talked about this problem, or does someone remember how it was done, or does anyone have an idea how it could be automated?


Quote
dealtek
(@dealtek)
Active Member
Joined: 6 months ago
Posts: 7
 

Hi Allison - how about this?

https://www.macobserver.com/link/eject-clone-improve-spotlight-search/


ReplyQuote
Allison Sheridan
(@podfeet)
Trusted Member
Joined: 6 years ago
Posts: 85
Topic starter  

@dealtek That was it!!! Good to know I didn't hallucinate it, and now all I have to do is figure out how to attach that script for when I want it.

thank you!


ReplyQuote
dealtek
(@dealtek)
Active Member
Joined: 6 months ago
Posts: 7
 

You are most welcome!


ReplyQuote
cpragman
(@cpragman)
Trusted Member
Joined: 3 years ago
Posts: 59
 

You can also add a line to /etc/fstab to prevent that disk from auto mounting at startup 


ReplyQuote
Heatherann123
(@heatherann123)
Active Member
Joined: 6 months ago
Posts: 18
 

@cpragman 

That is need and helpful,,,, Thanks.


ReplyQuote
cpragman
(@cpragman)
Trusted Member
Joined: 3 years ago
Posts: 59
 

To edit /etc/fstab, you need to create the file with admin prove ledges.  For example, 

$sudo vi /etc/fstab

if the file doesn't exist, it will be created.  Each line in the file contains the UUID of a drive you want to control the mounting of.  Here is an example from my fstab file.  Note that there is no space between rw, the comma, and noauto.  If your disk is HFS instead of apfs, then change the "apfs" term with "hfs".

 

For any disks not listed in the fstab file, macOS will follow it's default behavior (typically auto-mount at boot).

 

UUID=680FE0A0-D026-4448-AB41-EB85406CF27D none apfs rw,noauto


ReplyQuote
Share: