50

Is there any way to disable the "the disk was not ejected properly" message?

I use a KVM and need to switch between two systems and have a memory stick that is in the KVM. The problem is that it's very annoying to get the message every time I switch from one computer to the other. I know, I can unmount it (and probably should), but I switch all the time, so it's a inconvenience to unmount, and there is nothing sensitive on the memory stick.

11
  • 3
    Sorry, I have no answer. However keep in mind, that message is to remind you that data is held in memory and not yet written to the disk. Which is particularly important when you switch often.
    – DerMike
    Jan 7, 2011 at 14:01
  • 5
    I've done this a long time and I have never lost anything. I'm not saying it won't happen, but I'm willing to take the risk. Jan 7, 2011 at 15:19
  • 2
    Okay, I have to ask: anyone know why we got three near-identical questions within 10 hours—this one, 6090, and 6108 (and yes, the latter two have been closed as dupes).
    – Dori
    Jan 8, 2011 at 1:38
  • 1
    @Dori It's the time after Christmas, so new Macs or Cameras with SD Cards :) Although I would like to point out that my question specifically was asking about the Write Cache, which is what the warning is usually about (ignoring issue like Symlinks/open system files on the drive)
    – Michael Stum
    Jan 8, 2011 at 7:08
  • 1
    I hear what you are saying, that you would rather take the chance on losing the memory stick, I just thought I would let you know that it does happen; I found this forum because I didn't eject my memory stick before disconnecting and wasn't able to access the 1.8gb worth of movies that I just took. Luckily Disk Utility was able to fix it, this time.
    – cate
    Jan 8, 2011 at 14:09

6 Answers 6

13

updated new better method

As mentioned by Russel in comments:

sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.DiskArbitration.diskarbitrationd.plist DADisableEjectNotification -bool YES && sudo pkill diskarbitrationd
8
  • 1
    Unloading a launchctl plist persists across restart, so I believe so. That said, I hardly ever reboot, so haven't tested it yet!
    – James
    Apr 23, 2011 at 19:15
  • 2
    (I rebooted, and it has persisted fine :)
    – James
    Apr 29, 2011 at 10:27
  • 3
    That solution has a negative side effect: It will also hide those "xy-application would like access to your contacts" popups. To revert it: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.UserNotificationCenter.plist
    – user52466
    Jul 2, 2013 at 1:08
  • 8
    Yeah this is very dangerous. It will most likely stop you from getting notifications from the system. In 2011, notifications were not a big deal but they kind of are today in 2015. Feb 10, 2015 at 1:32
  • 1
    I think it would be better if you just disable the USB device notification instead of disabling the entire notification ?! sudo rm /usr/libexec/USBAgent
    – Lano
    Jun 4, 2021 at 9:01
18

This applescript will close them for you. Paste it into Script Editor and then Save as an application. Then grant access to that application in (System Preferences > Security & Privacy > Accessibility) Then you can use an application like ControlPlane https://www.controlplaneapp.com/ to run the application on wake thus closing them all automatically! ** Note: You will need to grant Accessibility access to ControlPlane as well.

tell application "System Events"
tell process "NotificationCenter"
    set numwins to (count windows)
    repeat with i from numwins to 1 by -1
        tell window i
            set temp to value of static text 1
        end tell
        if temp contains "Disk Not Ejected Properly" then
            click button "Close" of window i
        end if
    end repeat
end tell
end tell
4
  • 1
    Beautiful, I prefer this to completely disabling Notification Center. Apr 12, 2018 at 15:11
  • Thanks. On Catalina I added a workflow in Automator, then selected AppleScript from the list of possible actions and pasted in your script and it worked, though I had to run it multiple times. Sep 26, 2020 at 12:34
  • thank you so much. I can go to bed tonight feeling like this world is a better place than it was at the start of the day. May 14, 2021 at 3:28
  • Any alternative to ControlPane now that it’s kind of old and not maintained anymore?
    – anonymous
    Sep 5, 2021 at 3:05
10
+25

Certainly not an elegant answer but, you can disable UserNotificationCenter.app found in /system/library/coreservices - replace it with another app or file with the same name. It will stop any warnings popping up (including that your drive is full) so watch out for that, but in my experience it does what you are looking for.

I actually did this to my mac a long time ago, and forgot about it until you asked you question. Credit to Macpadawon at http://macosx.com/forums/mac-os-x-system-mac-software/297194-disable-device-removal-message.html for the answer - same place I found my answer a couple of years back.

3
  • Wow. Nice catch. I certainly wouldn't do this to my own system, but it's nice to know it can be done. I suppose the app could be replaced with an empty file.
    – Harv
    Jan 18, 2011 at 1:42
  • I've done it on three different macs with no issues, although most of the time I just unmount things as well.
    – Ciaocibai
    Jan 18, 2011 at 22:23
  • 2
    At least you did not notice any issues, right? Sorry, couldn't resist. :-)
    – DerMike
    Jan 21, 2011 at 11:20
1

Works with macOS Big Sur

This AppleScript dismisses all notifications about the disk not being ejected properly.

tell application "System Events"
    tell process "Notification Center"
        set group_index to 1
        repeat
            try
                set the_window to group group_index of UI element 1 of scroll area 1 of window "Notification Center"
                set notification to value of static text of the_window
                set notification_title to item 1 of notification
                if notification_title = "DISK NOT EJECTED PROPERLY" then
                    set the_actions to actions of the_window
                    repeat with the_action in the_actions
                        if description of the_action is "Close" then
                            tell the_window
                                perform the_action
                            end tell
                        end if
                    end repeat
                    # Wait for the notification to disappear so that the indexes of the remaining notifications are updated accordingly.
                    delay 0.25
                    # Do not increment `group_index` because all remaining notifications have their index decremented by 1 since this notification was dismissed. We do not need to worry about the notifications before the one just dismissed because we already know that they are not notifications about disk ejection.
                else
                    # This is not a disk ejection notification, so skip it and look at the next notification.
                    set group_index to group_index + 1
                end if
            on error error_message
                # There are no more notifications to process.
                exit repeat
            end try
        end repeat
    end tell
end tell

You can run this AppleScript every 10 seconds with the launchd PLIST below. Be sure to modify it to work with your own setup. Then place the PLIST in ~/Library/LaunchAgents and run launchctl load ~/Library/LaunchAgents/file.plist (replacing file.plist with the name of the file) in Terminal.

What's really cool about launchd is that if a job does not run because the computer is asleep (e.g., when your laptop is closed), launchd will run the job as soon as the computer wakes up again (and if the job was supposed to run multiple times while the computer was asleep, the multiple runs will be coalesced into one run upon wakeup). This is really useful when unplugging a closed laptop from a home dock with a hard drive attached and then using the laptop on-the-go.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.YourName.DismissNotifications</string>
    <key>ProgramArguments</key>
    <array>
      <string>osascript</string>
      <string>/path/to/script</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>10</integer>
  </dict>
</plist>
0
-3

your answer is here. Just replace a file with the one mentioned at the end of this article and jobs done. Nothing has changed in Sierra or High Sierra.

Disabling OS-X Device Removal Warnings In Yosemite

0
-3

UPDATE!

OMG! QuantumG is a genius! Here is a hack (and I mean a real life hack) for disabling just this annoying message and leaving the rest of the notification system intact...

http://quantumg.blogspot.com/2015/04/disabling-os-x-device-removal-warnings.html

Warning: This is a pro-tip and not for the faint of heart! It requires hacking your Mac OSX system files and could result in you breaking your Mac.

Edited for clarity.

The issue with flash drives or other USB drives is this; whenever you write data to a drive... ANY drive on your system, the data is first written to a buffer in memory. Later, when the computer gets around to it, it will flush the buffers to the device (hard drive, SSD, or any USB device). That may be instantaneous (at least to us mere mortals) or it may take a few seconds. The possible delay means that if you yank a USB device before the buffers have flushed you may end up with a corrupted drive, or a set of corrupted files on the drive.

If you only read from a device, then there is NO NEED to flush the write buffers before you yank to your heart's content because they are empty and don't need to be flushed to the device.

So... The annoying MAC OS X warning is most probably NOT relevant. It is only important to do so if you have recently written to the device, and haven't given it enough time to flush the buffers (a few seconds, max). It is NEVER necessary to wait for the buffers to flush if you are only reading from the USB device.

Therefore Apple NEEDS to provide a way to disable individual messages for power users. Don't treat everyone as a n00b who can't be relied on to know how their computer works.

And to those who complain that I'm wrong, and there is a way to disable the messages by disabling the ENTIRE NOTIFICATION SUBSYSTEM are just plain wrong. Disabling the entire notification subsystem isn't an acceptable solution, just as removing the battery from your cell phone is NOT an acceptable solution to receiving too many telemarketing calls. The notification subsystem is important and shouldn't be disabled just because the OP finds one of the many myriad of messages to be annoying.

This is a problem that can only be adequately solved by Apple providing a way for users to opt out of specific messages.

5
  • 1
    So, I'm not sure this ramble really qualifies as an answer to the question... however an answer was already provided that does exactly what you are rambling can't be done - the messages can be disabled. However, as this does not attempt to provide any answer to the question, I'm going to flag this for deletion.
    – Charlie74
    Jan 4, 2016 at 23:54
  • @Charlie74 It's an attempt to make a point, so I'm not deleting it. I will edit out the vague chit chat towards the end. If OP wants to be clear, feel free to provide a positive explanation of why OS X is POSIX certified - en.wikipedia.org/wiki/POSIX#POSIX-certified and not POSIX-based.
    – bmike
    Jan 12, 2016 at 17:35
  • @Charlie74 I clarified my answer, but to defend myself I never said it couldn't be done. I merely suggested that disabling the notification subsystem in order to stop one of the maybe hundreds of issues of which your mac may need to notify you, isn't an acceptable solution. It's only slightly better than "Stop using your Mac and the silly message won't bother you anymore". Only Apple can offer an acceptable solution, and they haven't yet. Oct 29, 2018 at 22:49
  • This approach does not work due to binaries needing to be signed. Disabling code signing would be worse than disabling the notification system. Nov 29, 2018 at 12:35
  • I agree with Edward. So there is still NOT A VIABLE SOLUTION. Mar 1, 2019 at 20:45

You must log in to answer this question.

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