nielsmouthaan / ejectify-macos

Ejectify automatically unmounts external volumes when your Mac starts sleeping, and mounts them again after it wakes up.
https://ejectify.app
Other
370 stars 50 forks source link

Add support for encrypted volumes #34

Open jajoho opened 2 years ago

jajoho commented 2 years ago

When Ejectify is unmounting all my volumes but not mounting all of them again. May be this is the same issue than this (#25)?

I have an SSD with two different partitions (each of them in APFS). Im using one of them for TimeMachine backups, the other is for other data. Ejectify is unmounting them when my display goes to sleep. This works perfectly. But after wakeup only the TimeMachine partition is mounted again. I tried it through a hub and directly. This made no difference. I've also tried to use the delay function. This also made no difference. When using disk utility I'm able to see both partitions and can manually mount the missing one.

gagarine commented 2 years ago

Same issue with a WD external spinning disk connected in USB-C. I use this disk for time machine only and it has only one APFS volume. It unmount fine, but ejectify is not able to mount it back.

nielsmouthaan commented 2 years ago

Can you check the Console app for any errors related to Ejectify or the โ€œmountโ€ keyword?

jajoho commented 2 years ago

The logs below seem to be related to mounting the volumes. /dev/disk5s2 is the identifier of the volume not mounting. I thought this is related to a problem unlocking it. So I deleted it and created a new APFS volume with a different password and stored it in Keychain Access with no change. After that I tried it again without encryption of the volume. Now it is working. This is strange because my TimeMachine volume is also encrypted. On that one it works every time without any problems.

standard    09:29:37.935491+0100    kernel  nx_mount:1460: disk5 checkpoint search: largest xid 533, best xid 533 @ 151
standard    09:29:37.936528+0100    kernel  apfs_mount:26528: disk5s2 Failed to unwrap metadata crypto state: 22
standard    09:29:37.936785+0100    kernel  apfs_vfsop_mount:2162: disk5 apfs_mount failed, err: 1
standard    09:29:37.936789+0100    kernel  apfs_vfsop_mount:2418: apfs_vfsop_mount failed, err: 1
fehler      09:29:37.976233+0100    fseventsd   handle_vfs_event: mount_point(<private>) dev(16777243) will be completely ignored
standard    09:29:37.976717+0100    kernel  spaceman_iterate_free_extents_internal:2760: disk5 nx_unmount detected while processing dev=0 cib=1 out of 15 cibs
standard    09:29:37.977705+0100    kernel  nx_mount:1184: disk5 initializing cache w/hash_size 8192 and cache size 32768
standard    09:29:38.009279+0100    kernel  nx_mount:1460: disk5 checkpoint search: largest xid 533, best xid 533 @ 151
standard    09:29:38.012486+0100    kernel  nx_mount:1184: disk5 initializing cache w/hash_size 8192 and cache size 32768
standard    09:29:38.045186+0100    kernel  nx_mount:1460: disk5 checkpoint search: largest xid 533, best xid 533 @ 151
standard    09:29:38.046006+0100    diskarbitrationd    unable to mount /dev/disk5s2 (status code 0x0000004D).
fehler      09:29:38.046015+0100    diskarbitrationd    unable to mount /dev/disk5s2 (status code 0x0000004D).
nielsmouthaan commented 2 years ago

Thanks for the logs and good to read it now works for you.

I'm wondering if running Ejectify using administrator rights would also have solved this: sudo /Applications/Ejectify.app/Contents/MacOS/Ejectify

jajoho commented 2 years ago

Yes, that solves the problem! Now also encrypted volumes that are not TM-volumes are mounted automatically

nielsmouthaan commented 2 years ago

That's good to know. I will check if I can make Ejectify run as administrator by default.

johncoxon commented 2 years ago

I am having this problem and running sudo /Applications/Ejectify.app/Contents/MacOS/Ejectify & does not appear to fix it.

nielsmouthaan commented 2 years ago

Have you tried the suggestions described here here?

johncoxon commented 2 years ago

Connecting it directly (well, via USB-C to USB-A dongle) did not change anything: I started the logging on Console and got the following which mentioned Ejectify:

default 20:48:55.223309+0100    Ejectify    AppleInterfaceThemeChangedNotification
default 20:48:55.223408+0100    Ejectify    System appearance change
default 20:48:55.224003+0100    Ejectify    Current system appearance, (HLTB: 2), (SLS: 1)
default 20:48:55.224039+0100    Ejectify    Invalidate NSApp effectiveAppearance
default 21:20:24.414335+0100    runningboardd   Acquiring assertion targeting [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] from originator [daemon<com.apple.WindowServer(88)>:424] with description <RBSAssertionDescriptor| "AppVisible" ID:432-424-2624 target:1051 attributes:[
    <RBSDomainAttribute| domain:"com.apple.appnap" name:"AppVisible" sourceEnvironment:"(null)">,
    <RBSAcquisitionCompletionAttribute| policy:AfterApplication>
    ]>
default 21:20:24.414485+0100    runningboardd   Assertion 432-424-2624 (target:[app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051]) will be created as active
default 21:20:24.413780+0100    authd   Succeeded authorizing right 'system.volume.external.mount' by client '/Applications/Ejectify.app' [1051] for authorization created by '/Applications/Ejectify.app' [1051] (13,0) (engine 168)
default 21:20:24.425932+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring jetsam update because this process is not memory-managed
default 21:20:24.426183+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring suspend because this process is not lifecycle managed
default 21:20:24.426436+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring GPU update because this process is not GPU managed
default 21:20:24.427913+0100    runningboardd   Calculated state for app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>: running-active (role: UserInteractive)
default 21:20:24.526832+0100    runningboardd   Acquiring assertion targeting [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] from originator [daemon<com.apple.WindowServer(88)>:424] with description <RBSAssertionDescriptor| "FUSBProcessWindowState: visible" ID:432-424-2636 target:1051 attributes:[
    <RBSDomainAttribute| domain:"com.apple.fuseboard" name:"Visible" sourceEnvironment:"(null)">,
    <RBSAcquisitionCompletionAttribute| policy:AfterApplication>
    ]>
default 21:20:24.527043+0100    runningboardd   Assertion 432-424-2636 (target:[app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051]) will be created as active
default 21:20:24.528225+0100    runningboardd   Calculated state for app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>: running-active (role: UserInteractive)
default 21:20:24.528116+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring jetsam update because this process is not memory-managed
default 21:20:24.528513+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring suspend because this process is not lifecycle managed
default 21:20:24.528791+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring GPU update because this process is not GPU managed
default 21:20:24.529762+0100    runningboardd   Invalidating assertion 432-424-1655 (target:[app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051]) from originator [daemon<com.apple.WindowServer(88)>:424]
default 21:20:24.651465+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring jetsam update because this process is not memory-managed
default 21:20:24.651702+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring suspend because this process is not lifecycle managed
default 21:20:24.652244+0100    runningboardd   [app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>:1051] Ignoring GPU update because this process is not GPU managed
default 21:20:24.655754+0100    runningboardd   Calculated state for app<application.nl.nielsmouthaan.Ejectify.269663095.269663106(501)>: running-active (role: UserInteractive)
default 21:20:24.716203+0100    authd   Succeeded authorizing right 'system.volume.external.mount' by client '/usr/libexec/diskarbitrationd' [383] for authorization created by '/Applications/Ejectify.app' [1051] (2,0) (engine 169)
default 21:20:24.759164+0100    authd   Succeeded authorizing right 'system.volume.external.mount' by client '/Applications/Ejectify.app' [1051] for authorization created by '/Applications/Ejectify.app' [1051] (13,0) (engine 170)
default 21:20:24.847357+0100    authd   Succeeded authorizing right 'system.volume.external.mount' by client '/usr/libexec/diskarbitrationd' [383] for authorization created by '/Applications/Ejectify.app' [1051] (2,0) (engine 171)

These are the bits which mention the drive name:

default 21:13:10.734203+0100    kernel  007356.303270 AppleUSB30HubPort@02142000: AppleUSBHostPort::terminateDevice: destroying 0x0bc2/2038/1801 (Expansion HDD): reset API call
default 21:13:10.790589+0100    icdd               [Removed] | [USB][       Expansion HDD ] ( 0, 0, 0) @ 0x2142000 |
default 21:13:10.790719+0100    icdd               [Removed] | [USB][       Expansion HDD ] ( 8, 6,62) @ 0x2142000 |
default 21:13:10.792022+0100    kernel  USB device 0BC2203802142000 - Seagate, Expansion HDD - detected termination of interfaceNub, currentPowerState 1, provider is IOUSBMassStorageResource
default 21:13:10.798599+0100    kernel  007356.367656 AppleUSB30HubPort@02142000: AppleUSBHostPort::enumerateDeviceComplete_block_invoke: enumerated 0x0bc2/2038/1801 (Expansion HDD) at 5 Gbps
default 21:13:10.882057+0100    icdd                   Added | 0x10000122 - [USB][       Expansion HDD ] ( 0, 0, 0) @ 0x2142000 |
default 21:13:10.882556+0100    icdd                Inferior | 0x10000123 - [USB][       Expansion HDD ] ( 8, 6,62) @ 0x2142000 |
johncoxon commented 2 years ago

When Carbon Copy Cloner wants to mount the volume, it needs the password for the encryption to be put in its keychain before it can mount it โ€“ I strongly suspect you need to have a keychain in Ejectify for encryption passwords to fix this issue, and it won't work with encrypted drives until Ejectify can host the encryption passwords.

nielsmouthaan commented 2 years ago

That's a good point, thanks. I'll look into this when I have time!

johncoxon commented 2 years ago

No worries! Let me know if there's anything I can do to help โ€“ it's a lovely app and the unmounting and Time Machine bits work like a charm, so I'm keen to support the project ๐Ÿ˜„

ursetto commented 1 year ago

Same remount failure with TM drive here even with sudo, Failed to unwrap metadata crypto state.

miharekar commented 7 months ago

Is there a permanent solution to have it auto start as admin? That's the only way to get it to re-mount encrypted volumes. Which are all of my external volumes ๐Ÿ˜…

nielsmouthaan commented 7 months ago

I haven't tested it myself, so use it cautiously, but ChatGPT came up with this approach.