Mount EFI mounts internal EFI even if external disk is selected if both volumes have the same name
5T33Z0 opened this issue · 16 comments
Not really an issue, just an interesting observation. I noticedd this when trying to mount the EFI of an external disk that was connected to my system via USB.
As you can see, there's an internal as well as an external volume called "Big Sur".
If I try to mount the EFI of the external "Big Sur" Volume…
…it actually mounts the EFI of the internal "Big Sur" volume:
Since the "Untitled" contains Windows Install, I tried that next…
… and then it mouted the EFI of the external disk:
Thanks for bringing this to my attention. I wonder if this is a limitation of Automator, or some oversight on my part? I'll give it a look when I have some time (hopefully this weekend).
-CorpNewt
If I use the .command instead of the quick action, it mounts the correct EFI for the selected disk.
So it's probably related to Automator. Can it look for the UUIDs of a disk? Then there would be no confusion about the selected disk, even if they have the same name in Finder, I guess.
This appears to be an Automator bug - which is unfortunate as that's what gives the script the paths to check.
I updated the AppleScript that gets the folders from the quick action to print what it gets - and it resolves the paths incorrectly. You can see in the image below that the external "Streamintosh" drive is highlighted - but the path passed to the AppleScript from Automator is just "/", which implies it's sending my boot drive instead:
It looks like I should be able to work around this by getting the Finder selection directly, instead of relying on the info passed from Automator. I'll see if I can get something whipped up for testing.
-CorpNewt
When you get a second, can you try this Mount EFI Automator Quick Action.zip? I adjusted the beginning of the script to include the following instead of relying on the passed folders:
set passed_paths to ""
# Due to a bug in Automator, selecting a disk with the same
# name as the startup disk defaults to the startup disk
# itself instead. So, to work around that, we query the
# Finder selection directly - and filter the results to only
# include «class sdsk» (startup disk) and «class cdis»
# (disk) to ensure we have the correct pathing.
tell application "Finder"
set diskSelection to (get selection)
repeat with d in diskSelection
if class of d is startup disk or class of d is disk then
set the_text to quoted form of POSIX path of (d as alias) as string
set passed_paths to passed_paths & " " & the_text
end if
end repeat
end tell
This should hopefully resolve the issue - and it explicitly filters input only to disks.
-CorpNewt
In continuing to test - I get intermittent complaints that no disks with ESPs were selected. I'll have to see what that's about.
Yeah - getting selection this way means that the item has to be selected in order to work. Simply right clicking and choosing "Mount EFI" doesn't actually select it in Finder. This is quite a pain.
When right clicking, the item is outlined as follows:
But it's not actually selected - so it fails to resolve. However, left clicking to select, then right clicking to mount works:
I'm honestly not sure of a clean solution to this.
I may have actually fixed it - seems I was working through the input paths and saving each as a text
, which doesn't resolve disks named the same as the startup disk (for whatever reason). Changing it to use alias
instead as follows seems to work, and uses the paths passed via Automator - which should also fix the need to select first, then right click:
repeat with the_path in input
set the_text to quoted form of POSIX path of (the_path as alias) as string
set passed_paths to passed_paths & " " & the_text
end repeat
Please test this Mount EFI Automator Quick Action.zip and let me know if that fixes the issue for you.
-CorpNewt
Right-clicking to select works again, but if I select the external "Big Sur" disk it still mounts the internal EFI. Only if I select the "Untitled" disk, it mounts the external EFI.
Hmm - it's working here for external disks named the same as the boot disk. I've added a line to display the final path it gets in a dialog window before attempting to mount for verification in this copy:
Mount EFI.zip
It does seem to properly report on my end though:
And the mounted ESPs reflect the correct disks.
I reformatted my USB drive to APFS and I can recreate that behavior - it was HFS+ before. I'll see if there's any other tricks I can work into this to resolve that properly.
-CorpNewt
My external disk has 3 volumes: 2 APFS for macOS and one NTFS for Windows. Unfortunately, I need this drive, so I can't format it
Mind testing this one? Mount EFI.zip
Perfect - the change is... well... dumb. All I'm doing is intercepting the paths that were originally sent to the AppleScript with bash, and cat
ing them out to the AppleScript instead of using Finder aliases
. I'll push the change to the main repo (without the dialog box). Thanks for testing!
-CorpNewt
Glad I could be of service. Thanks for the fix.