Jump to content
2 posts in this topic

Recommended Posts

I would like to provide my own version of opening the EFI section, which I have been using for a long time.
How it differs from others:
This is a button, in one click you can open and close the EFI section that you previously entered into the script. You will also have to enter the administrator password into the script (if you are afraid of this, do not use it).

#!/bin/bash
# OpenEFI
# By Sergey_Galan (Serhii Halaniuk)
# Copyright (c) 2018-2025, Sergey_Galan (Serhii Halaniuk). All Right Reserved
#######################
pass=1234
name='Macintosh HD'
#######################

Incorrect_password () {
echo "ALERT:Incorrect password|"
exit 1
}

# All Volume EFI force-unmounted
mountPoint=/Volumes/"$name"
if [[ -e /Volumes/EFI ]]; then
     echo "$pass" | sudo -S echo "Ok" || Incorrect_password
    for efi in /Volumes/EFI*; do
    if [[ -e "$efi" ]]; then
        echo "NOTIFICATION: $(sudo -S umount -fv "$efi")"
    fi
    sleep 0.5
    done

# Volume EFI mounting
# HFS
elif diskutil list | grep -m 1 "$name" | grep "Apple_HFS"; then
    part=$(diskutil info "$mountPoint" | grep "Device Node:" | awk '{print $3}')
    disk=$(printf $part | sed 's/s[0-9]*$//')
    disk="$disk"s1
    echo "$pass" | sudo -S echo "Ok" || Incorrect_password
    sudo -S umount -f $disk >/dev/null 2>/dev/null
    sudo -S fsck_msdos -fy $disk >/dev/null 2>/dev/null
    sudo -S diskutil mount $disk || sudo -S diskutil mount $disk && echo "NOTIFICATION: Volume EFI on $disk mounted"

# APFS
elif diskutil list | grep -m 1 "$name" | grep "APFS Volume"; then
    part=$(diskutil info "$mountPoint" | grep "APFS Physical Store:" | awk '{print $4}')
    part=/dev/"$part"
    disk=$(printf $part | sed 's/s[0-9]*$//')
    disk="$disk"s1
    echo "$pass" | sudo -S echo "Ok" || Incorrect_password
    sudo -S umount -f $disk >/dev/null 2>/dev/null
    sudo -S fsck_msdos -fy $disk >/dev/null 2>/dev/null
    sudo -S diskutil mount $disk || sudo -S diskutil mount $disk && echo "NOTIFICATION: Volume EFI on $disk mounted"
fi
exit

You must replace the pass value with your administrator password.

pass=1234

Replace Macintosh HD with the name of the disk partition with the EFI partition you want to open (leave the quotes alone).
name='Macintosh HD'

 

For editing, the script is located here:

 

Screenshot2025-02-09at12_42_30.png.d8e1c1bf53cd826275dcb1e09b15092c.png

 

Watch the video of me using the button

 

 

 

OpenEFI.zip

 

 

Edited by Sergey_Galan
  • Like 2
  • Thanks 3
  • 4 months later...
×
×
  • Create New...