]>
code.delx.au - refind/blob - mountesp
3 # Mac OS X script to locate and mount an EFI System Partition (ESP)
9 # This program is copyright (c) 2012-2015 by Roderick W. Smith
10 # It is released under the terms of the GNU GPL, version 3,
11 # a copy of which should be included in the file COPYING.txt.
15 # 0.9.3 -- Initial release (with rEFInd 0.9.3)
17 # Mount the ESP at /Volumes/ESP or determine its current mount
20 # Identify the ESP. Note: This returns the FIRST ESP found;
21 # if the system has multiple disks, this could be wrong!
22 Temp
=$
(mount |
sed -n -E "/^(\/dev\/disk[0-9]+s[0-9]+) on \/ \(.*$/s//\1/p")
24 Temp
=$
(diskutil list |
grep " EFI " |
grep -o 'disk.*' |
head -n 1)
26 echo "Warning: root device doesn't have an EFI partition"
29 echo "Warning: root device could not be found"
32 Temp
=$
(diskutil list |
sed -n -E '/^ *[0-9]+:[ ]+EFI EFI[ ]+[0-9.]+ [A-Z]+[ ]+(disk[0-9]+s[0-9]+)$/ { s//\1/p
37 echo "Could not find an EFI partition. Aborting!"
42 echo "The ESP has been identified as $Esp; attempting to mount it...."
43 # If the ESP is mounted, use its current mount point....
44 Temp
=`df -P | grep "$Esp "`
45 MountPoint
=`echo $Temp | cut -f 6- -d ' '`
46 if [[ "$MountPoint" == '' ]] ; then
47 if [[ $UID != 0 ]] ; then
48 echo "You must run this program as root or using sudo! Exiting!"
51 MountPoint
="/Volumes/ESP"
52 mkdir
/Volumes
/ESP
&> /dev
/null
53 mount
-t msdos
"$Esp" $MountPoint
54 # Some systems have HFS+ "ESPs." They shouldn't, but they do. If this is
55 # detected, mount it as such and set appropriate options.
56 if [[ $?
!= 0 ]] ; then
57 mount
-t hfs
"$Esp" $MountPoint
58 if [[ $?
!= 0 ]] ; then
59 echo "Unable to mount ESP!\n"
64 echo "The ESP is mounted at $MountPoint"
68 # Main part of script....
76 echo "This script is meant to be run under OS X *ONLY*! Exiting!"