corpnewt/MountEFI

Mount EFI mounts internal EFI even if external disk is selected if both volumes have the same name

5T33Z0 opened this issue · 16 comments

5T33Z0 commented

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.

Bildschirmfoto 2023-08-11 um 17 15 54

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…
Bildschirmfoto 2023-08-11 um 17 16 03

…it actually mounts the EFI of the internal "Big Sur" volume:

Bildschirmfoto 2023-08-11 um 17 26 31

Since the "Untitled" contains Windows Install, I tried that next…

Bildschirmfoto 2023-08-11 um 17 16 44

… and then it mouted the EFI of the external disk:

Bildschirmfoto 2023-08-11 um 17 26 00

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

5T33Z0 commented

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:
image

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.

5T33Z0 commented

I installed the quick action (replacing the old one). But now I can't mount any EFI:

Bildschirmfoto 2023-08-11 um 19 38 36

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:
image

But it's not actually selected - so it fails to resolve. However, left clicking to select, then right clicking to mount works:
image

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

5T33Z0 commented

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:
image

image

And the mounted ESPs reflect the correct disks.

5T33Z0 commented

Okay. This is what the .command sees:

Bildschirmfoto 2023-08-11 um 20 06 14

This is the path the action shows for the orange Big Sur volume:

Bildschirmfoto 2023-08-11 um 20 09 21

This is the path when selecting "Untitled":

Bildschirmfoto 2023-08-11 um 20 11 17

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

5T33Z0 commented

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

5T33Z0 commented

That didi it! Great!

I selected the organe Big Sir volume:

Bildschirmfoto 2023-08-11 um 22 12 35

And it mounts the correct EFI:

Bildschirmfoto 2023-08-11 um 22 14 03

Perfect - the change is... well... dumb. All I'm doing is intercepting the paths that were originally sent to the AppleScript with bash, and cating 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

5T33Z0 commented

Glad I could be of service. Thanks for the fix.