ejectify-macos icon indicating copy to clipboard operation
ejectify-macos copied to clipboard

Eject disk when power source switch from AC to battery

Open YangJianchong opened this issue 3 years ago • 10 comments
trafficstars

Hi,

I'm using a Mac mini with an APC backup UPS at home.

I'm a bit worried about that when I'm not at home and there's a power outage, after the UPS battery drained out, or due to Energy Saver schedule, Mac just shuts down hard without safely ejecting all my external drive.

I hope ejectify can listen to some sort of 'power source switching to UPS' system event and safely eject all my external drives.

Hope I expressed myself clearly.

YangJianchong avatar Aug 02 '22 13:08 YangJianchong

How is your disk connected to your Mac? Directly or via a hub (which can also be an external display)?

nielsmouthaan avatar Aug 02 '22 17:08 nielsmouthaan

How is your disk connected to your Mac? Directly or via a hub (which can also be an external display)?

Both. Some are connected directly to the Mac and the others connected via hub(which has its own power source also connected to the UPS).

YangJianchong avatar Aug 04 '22 16:08 YangJianchong

Ejectify needs to be able to unmount the volumes before the (external) disks lose power. That will be the case for those connected directly to your Mac. I cannot say whether that's also the case for those connected to the hub. If the hub or disks loses power before your Mac (because the UPS is empty), Ejectify won't have unmounted the volumes. Somehow the UPS should notify your Mac that its power is critically low so that your Mac can safely unmount (external) volumes. Do you know whether your UPS supports such a notification mechanism?

nielsmouthaan avatar Aug 05 '22 06:08 nielsmouthaan

Thank you for replying.

I forgot to tell you that my UPS has a USB cable which connects to my Mac so the Mac can read the UPS's battery percentage (shown as images below). Is this the mechanism you are talking about?

Screen Shot 2022-08-06 at 1 16 55 Screen Shot 2022-08-06 at 1 23 53 Screen Shot 2022-08-06 at 1 22 48

YangJianchong avatar Aug 05 '22 17:08 YangJianchong

So your Mac shuts down when the UPS battery is critically low? In that case, you should be good: connected volumes will be unmounted safely as part of the shutdown process of macOS.

nielsmouthaan avatar Aug 08 '22 18:08 nielsmouthaan

So your Mac shuts down when the UPS battery is critically low? In that case, you should be good: connected volumes will be unmounted safely as part of the shutdown process of macOS.

TL;DR: I did some test yesterday. I'm afraid that Energy Saver cannot control the the Mac to perform a normal shutdown process as it's scheduled.

I scheduled my Mac to shutdown when time remaining on UPS is 5min and when UPS battery level is below 5% and I pull off the UPS's power cable from the wall to simulate a power outage situation and let the Mac use UPS's power, with an external disk connected directly to it. Then I found out that the battery percentage reading of the UPS is inaccurate and not reliable, and even though the battery percentage become 0% the Mac is still running. Finally the Mac shutdown suddenly and I heard the sound by external hard drive's actuator arm returning to the position immediately. That indicates the hard drive is still spinning and working.

YangJianchong avatar Aug 10 '22 16:08 YangJianchong

That's odd; something is wrong with your Mac starting to sleep based on the UPS having a critically low battery level? I would suggest contacting the manufacturer of your UPS to receive support regarding this matter.

nielsmouthaan avatar Aug 12 '22 07:08 nielsmouthaan

Thank you, I'll reach for manufacture's help about the UPS. But will Ejectify be able to take action before the Mac shuts down on its own because of the power source changing? Since the change itself can be detected by macOS everytime.

YangJianchong avatar Aug 15 '22 17:08 YangJianchong

So unmount when switching from AC to battery?

nielsmouthaan avatar Aug 16 '22 07:08 nielsmouthaan

Yes exactly.

YangJianchong avatar Aug 17 '22 14:08 YangJianchong