Jump to content

Applescript to one-click mount EFI-Partition


KWS
 Share

24 posts in this topic

Recommended Posts

I have two HDD (seagate and WD) and want to mount ESP on Seagate.

But I don't know if it is disk0 or disk1 now. It is random.

Can you do something for this case?

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS MacHD                   270.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS LionHD                  118.9 GB   disk0s4
   5:                        EFI NO NAME                 104.9 MB   disk0s5
   6:       Microsoft Basic Data Data                    109.7 GB   disk0s6
/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *200.0 GB   disk1
   1:                        EFI NO NAME                 209.7 MB   disk1s1
   2:                  Apple_HFS ElCapitan               137.9 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
   4:                        EFI NO NAME                 104.9 MB   disk1s4
   5:                        EFI NO NAME                 104.9 MB   disk1s5
   6:         Microsoft Reserved                         133.2 MB   disk1s6

Link to comment
Share on other sites

 

I have two HDD (seagate and WD) and want to mount ESP on Seagate.

But I don't know if it is disk0 or disk1 now. It is random.

Can you do something for this case?

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS MacHD                   270.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS LionHD                  118.9 GB   disk0s4
   5:                        EFI NO NAME                 104.9 MB   disk0s5
   6:       Microsoft Basic Data Data                    109.7 GB   disk0s6
/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *200.0 GB   disk1
   1:                        EFI NO NAME                 209.7 MB   disk1s1
   2:                  Apple_HFS ElCapitan               137.9 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
   4:                        EFI NO NAME                 104.9 MB   disk1s4
   5:                        EFI NO NAME                 104.9 MB   disk1s5
   6:         Microsoft Reserved                         133.2 MB   disk1s6

 

The "working" line in this applescript is:

 

 

         --set hier to do shell script "diskutil mount /dev/disk0s1"

set hier to do shell script "diskutil mount EFI"

 

so i think you know more about shellscripts than i ...  ^_^ 

 

  • Like 1
Link to comment
Share on other sites

 

I have two HDD (seagate and WD) and want to mount ESP on Seagate.

But I don't know if it is disk0 or disk1 now. It is random.

Can you do something for this case?

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS MacHD                   270.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS LionHD                  118.9 GB   disk0s4
   5:                        EFI NO NAME                 104.9 MB   disk0s5
   6:       Microsoft Basic Data Data                    109.7 GB   disk0s6
/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *200.0 GB   disk1
   1:                        EFI NO NAME                 209.7 MB   disk1s1
   2:                  Apple_HFS ElCapitan               137.9 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
   4:                        EFI NO NAME                 104.9 MB   disk1s4
   5:                        EFI NO NAME                 104.9 MB   disk1s5
   6:         Microsoft Reserved                         133.2 MB   disk1s6

This working good till now https://github.com/RehabMan/Gigabyte-BRIX-s-DSDT-Patch/blob/master/mount_efi.sh

Link to comment
Share on other sites

But this script ask me what to choose while I want it to do automatically

if [ "$1" == "" ]; then
    DestVolume=/
else
    DestVolume="$1"
fi

The "working" line in this applescript is:

 

 

         --set hier to do shell script "diskutil mount /dev/disk0s1"

set hier to do shell script "diskutil mount EFI"

 

so i think you know more about shellscripts than i ...  ^_^ 

Sorry, I am C++ programmer knowing few about scripts.

Link to comment
Share on other sites

Hello @KWS, maybe we can learn together.. please take a look this script

Not bad, but i am in the moment very busy with my work. It's (a little) difficult for me - believe it or not - to really understand all lines of the autosleep-script i created some years ago ...  :) 

It needs time which i currently do not have ...

Link to comment
Share on other sites

This is what I use in my GA-Z77X.sh script (excerpt). Should autodetect the EFI partition automatically, even if it's /dev/disk1s1, disk2s1, etc. There seems to a small bug though: CoreStorage volumes won't work with this (yet, working on fixing this).

 

Update: Here's a fixed version which should work with Core Storage logical volumes.

function _mountEFI()
{
	# Find the BSD device name for the current OS disk
	osVolume=$(df / | awk '/disk/ {print $1}')

	# Find the EFI partition of the disk
	efiVolume=$(diskutil list "$osVolume" | awk '/EFI/ {print $6}')

	# Make sure the EFI partition actually exists
	if [ -z $efiVolume ]; then
		## Check if the OS is installed on a Core Storage (CS) logical volume
		if [ ! -z $(diskutil info "$osVolume" | grep "Core Storage") ]; then ## CS volume detected
			## We can find the recovery volume in the diskutil output, and then use that to find the EFI partition
			recoveryVolume=$(diskutil info "$osVolume" | awk '/Recovery Disk:/ {print $3}')
			efiVolume=$(diskutil list "$recoveryVolume" | awk '/EFI/ {print $6}')
		else ## No CS volume present, so assume no EFI partition
			_printError "No EFI partition present on OS volume ($osVolume)!"
		fi
	fi

	# Check if the EFI partition is already mounted; if not, mount it
	if [ -z $(mount | awk '/'$efiVolume'/ {print $1}') ]; then
		diskutil mount "$efiVolume" > /dev/null
		gEFIMount=$(diskutil info "$efiVolume" | awk '/Mount Point/ {print $3}')
		echo "EFI system partition ($efiVolume) mounted at $gEFIMount."
	else
		gEFIMount=$(diskutil info "$efiVolume" | awk '/Mount Point/ {print $3}')
		echo "EFI system partition ($efiVolume) is already mounted at $gEFIMount."
	fi
}

Obviously you'll need to change _printError to something like echo "ERROR: No EFI partition present on OS volume ($osVolume)!" && exit 1, as _printError is a part of the script.

Link to comment
Share on other sites

  • 3 months later...

 

Hi all, I have made a small utility that mounts a EFI partition on the selected hard drive or usb flash drive

This is a simple (Cocoa NSTask) wrapper for the terminal diskutil +some buttons  :)  :)  :)

 

Great tools I like it  :thumbsup_anim: For me its a  best EFI Mounter I ever used and see :wink_anim:

  • Like 1
Link to comment
Share on other sites

 

Hi all, I have made a small utility that mounts a EFI partition on the selected hard drive or usb flash drive

This is a simple (Cocoa NSTask) wrapper for the terminal diskutil +some buttons  :)  :)  :) 

 

 

 

Very nice ...   :rolleyes:  seems that you won the small utility's challenge ...  :thumbsup_anim:

Link to comment
Share on other sites

 

whats wrong with existing small utility that is found in every version of os x and doesnt need to be installed ?

 

ie

diskutil mount /dev/disk0s1

With 1 EFI-Partition you can also use "diskutil mount EFI" ...

 

BTW, open Terminal, write "diskutil mount EFI" and hit enter is not much, but a little morte effort than one (double)click .... 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
 Share

×
×
  • Create New...