Auto Eject External Drives on Mac: Full Guide
This guide shows you how to automatically eject external drives from your Mac when they are idle, when the Mac sleeps, or when you log out. You will learn several built-in methods and a free third-party option, so you can choose the one that fits your workflow and avoid the risk of data corruption from unplugging drives without ejecting.
What You’ll Need
- A Mac running macOS Catalina (10.15) or later for the built-in methods. Older versions may lack some settings, but the Automator and AppleScript methods work on most versions.
- An external drive (USB, Thunderbolt, SD card, etc.) that you want to auto-eject.
- Administrator access to your Mac if you want to use scheduled tasks or system-wide settings.
- For the third-party option, an internet connection to download the app (we’ll mention one that’s free and widely used).
Step-by-Step
Method 1: Eject When Mac Sleeps (Built-in)
- Open System Settings (or System Preferences on older macOS) from the Apple menu.
- Click Battery (or Energy Saver on older versions).
- Click the Options tab (or look for a checkbox labeled “Put hard disks to sleep when possible”).
- Check the box for “Put hard disks to sleep when possible”. This makes the Mac spin down internal and external hard drives when idle, but it does not fully eject them. To fully eject, use Method 2 or 3.
- Note: This method only puts the drive to sleep, not eject it. For a true eject, use the next method.
Method 2: Automator Application (Eject on Demand or via Keyboard Shortcut)
- Open Automator (found in Applications > Utilities).
- Choose File > New and select Application.
- In the left sidebar, search for “Get Specified Finder Items” and drag it into the workflow area.
- In the action, click Add and select your external drive(s). You can also leave it empty to eject all external drives.
- Search for “Eject Disk” and drag it below the first action.
- Go to File > Save and give it a name like “Eject External Drives”. Save it to your Desktop or Applications folder.
- Now you can double-click the app to eject all specified drives. To make it automatic, you can:
- Create an Alarm in the Clock app (macOS Ventura and later) that runs the app at a specific time. Or use Calendar to schedule an alarm that opens the app.
- For a keyboard shortcut, go to System Settings > Keyboard > Keyboard Shortcuts > App Shortcuts, click +, and add the app with a shortcut like Cmd+Shift+E.
Method 3: AppleScript (Eject on Logout or Shutdown)
- Open Script Editor (in Applications > Utilities).
- Paste this script:
tell application "Finder" eject (every disk whose local volume is true and not startup disk) end tell - Save it as an application (File > Export, format: Application). Name it “Eject All”.
- To run it automatically on logout, go to System Settings > General > Login Items & Extensions (or Users & Groups on older macOS).
- Click the + and add the app you just created.
- Now, when you log out, the app will run and eject all external drives. However, this only works if the app is allowed to run at logout; you may need to check the box “Hide” or set it to run.
- For shutdown, there is no built-in hook, but you can create a Calendar event that runs the script before you shut down.
Method 4: Third-Party App (Eject on Idle or Sleep)
- Download a free app like Ejector or Jettison (both are free and popular). We’ll describe Jettison because it’s widely used.
- Install the app and open it. It will appear in the menu bar.
- In the app’s preferences, enable the option to “Eject all external disks on sleep”.
- You can also set it to eject when the Mac is idle for a certain number of minutes.
- The app will automatically eject your drives before the Mac sleeps, and remount them when you wake the Mac (if you choose that option).
Common Mistakes
- Relying on “Put hard disks to sleep”: This does not eject the drive, it just spins it down. You can still unplug it and cause corruption.
- Not saving the Automator app properly: If you save it as a workflow instead of an application, it won’t run as a standalone app.
- Forgetting to add the drive to the Automator list: If you use “Get Specified Finder Items” and don’t add any drives, it will eject all external drives, which might be what you want, but if you intended only one, it will eject all.
- Using the wrong AppleScript syntax: A typo can cause the script to fail. Use the exact script provided.
- Not granting permissions: In newer macOS, Automator and AppleScript apps need permission to control the Finder. You may see a prompt; allow it.
Tips
- Test your Automator or AppleScript app manually before scheduling it.
- If you use a third-party app like Jettison, enable the “remount on wake” feature to automatically reconnect your drives after the Mac wakes.
- For a quick manual eject, use the keyboard shortcut Cmd+E after selecting the drive in Finder, or drag the drive icon to the Trash.
- If you have multiple drives, you can eject them all at once by holding Option and clicking the eject icon in Finder’s sidebar.
- Consider using a smart power strip that cuts power to the drive after the Mac shuts down, but only if the drive is already ejected.
Troubleshooting
- Automator app doesn’t eject anything: Check that the drive is not in use (e.g., a file is open). Also, make sure the app has permission to control Finder (System Settings > Privacy & Security > Automation).
- AppleScript says “Finder got an error: Can’t get every disk”: This happens if you run the script from Script Editor without proper permissions. Save it as an app and run it from Finder.
- Third-party app doesn’t eject on sleep: Some Macs with Apple Silicon may not trigger the app’s sleep notification correctly. Try updating the app or using the Automator method instead.
- Drive ejects but doesn’t remount after wake: This is normal if you didn’t enable remount. If you did, check the drive’s connection; some docks don’t re-initialize properly.
- The drive is still listed after ejection: Wait a few seconds, or check if the drive is still mounted in Disk Utility. If it is, eject again.
Frequently Asked Questions
Can I auto-eject a specific drive only?
Yes. In the Automator method, add only the specific drive to the “Get Specified Finder Items” list. The AppleScript can be modified to eject only a drive with a specific name, but the easiest is to use Automator.
Will auto-eject damage my external drive?
No, ejecting is safe. It ensures all writes are flushed and the drive is unmounted properly. The risk is only if you unplug without ejecting.
Does the “Put hard disks to sleep” option eject the drive?
No, it only spins down the drive. The drive remains mounted and can be accessed (it will spin up again). To fully eject, use one of the methods above.
Can I schedule an eject at a specific time?
Yes, you can use the Calendar app to create an event that runs the Automator app, or use the Clock app’s alarm feature (macOS Ventura and later) to run the app.
Is there a way to eject when the Mac’s screen locks?
Not built-in, but you can use a third-party app like Jettison, which can be configured to eject on screen lock (if the app supports it). Otherwise, use a keyboard shortcut to run the Automator app.
Will these methods work with APFS or exFAT drives?
Yes, ejection is filesystem-agnostic. The Mac will eject any mounted volume, regardless of format.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.