]>
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) 2015 by Roderick W. Smith
11 # This program is licensed under the terms of the GNU GPL, version 3,
12 # or (at your option) any later version.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # 0.9.3 -- Initial release (with rEFInd 0.9.3)
20 # Mount the ESP at /Volumes/ESP or determine its current mount
23 # Identify the ESP. Note: This returns the FIRST ESP found;
24 # if the system has multiple disks, this could be wrong!
25 Temp
=$
(mount |
sed -n -E "/^(\/dev\/disk[0-9]+s[0-9]+) on \/ \(.*$/s//\1/p")
27 Temp
=$
(diskutil list |
grep " EFI " |
grep -o 'disk.*' |
head -n 1)
29 echo "Warning: root device doesn't have an EFI partition"
32 echo "Warning: root device could not be found"
35 Temp
=$
(diskutil list |
sed -n -E '/^ *[0-9]+:[ ]+EFI EFI[ ]+[0-9.]+ [A-Z]+[ ]+(disk[0-9]+s[0-9]+)$/ { s//\1/p
40 echo "Could not find an EFI partition. Aborting!"
45 echo "The ESP has been identified as $Esp; attempting to mount it...."
46 # If the ESP is mounted, use its current mount point....
47 Temp
=`df -P | grep "$Esp "`
48 MountPoint
=`echo $Temp | cut -f 6- -d ' '`
49 if [[ "$MountPoint" == '' ]] ; then
50 if [[ $UID != 0 ]] ; then
51 echo "You must run this program as root or using sudo! Exiting!"
54 MountPoint
="/Volumes/ESP"
55 mkdir
/Volumes
/ESP
&> /dev
/null
56 mount
-t msdos
"$Esp" $MountPoint
57 # Some systems have HFS+ "ESPs." They shouldn't, but they do. If this is
58 # detected, mount it as such and set appropriate options.
59 if [[ $?
!= 0 ]] ; then
60 mount
-t hfs
"$Esp" $MountPoint
61 if [[ $?
!= 0 ]] ; then
62 echo "Unable to mount ESP!\n"
67 echo "The ESP is mounted at $MountPoint"
71 # Main part of script....
79 echo "This script is meant to be run under OS X *ONLY*! Exiting!"