- The Refind Binary File Is Missing Aborting Installation Artifactory
- The Refind Binary File Is Missing Aborting Installation Article
- The Refind Binary File Is Missing Aborting Installation Art Definition
- System Registry File Is Missing Or Corrupt
- #
- #
- #
- #
- # '--notesp' to install to the OS X root filesystem rather than to the ESP.
- # '--usedefault {devicefile}' to install as default
- # (/EFI/BOOT/BOOTX64.EFI and similar) to the specified device
- # (/dev/sdd1 or whatever) without registering with the NVRAM.
- # '--ownhfs {devicefile}' to install to an HFS+ volume that's NOT currently
- # '--root {dir}' to specify installation using the specified directory
- # '--alldrivers' to install all drivers along with regular files
- # '--nodrivers' to suppress driver installation (default in Linux is
- # driver used on /boot; --nodrivers is OS X default)
- # '--shim {shimfile}' to install a shim.efi file for Secure Boot
- # '--localkeys' to re-sign x86-64 binaries with a locally-generated key
- # '--keepname' to keep refind_x64.efi name as such even when using shim
- # '--yes' to assume a 'yes' response to all prompts
- # The 'esp' option is valid only on Mac OS X; it causes
- # installation to the EFI System Partition (ESP) rather than
- # to the current OS X boot partition. Under Linux, this script
- #
- # This program is copyright (c) 2012-2015 by Roderick W. Smith
- # This program is licensed under the terms of the GNU GPL, version 3,
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- # Revision history:
- # 0.10.4 -- Improved handling of disks (other than /dev/[sh]d? disks).
- # 0.10.2 -- Improved Secure Boot detection in Linux, fixed --usedefault in OS X,
- # and fixed bug that could cause mountesp to be installed as a FILE
- # 0.10.1 -- Improve extraction of default kernel options from /proc/cmdline.
- # Add support for AMD64 (aka AARCH64, aa64) platform. Added
- # warning when --alldrivers used without --usedefault.
- # 0.10.0 -- Enable running under OS X's recovery system & add warning about
- # SIP & brief instructions on how to deal with it if SIP is
- # detected to be enabled. Also change way refind_linux.conf default
- # 0.9.2 -- Added --keepname option.
- # 0.8.7 -- Better detection of Secure Boot mode & fixed errors when copying
- # Shim & MokManager files over themselves; fixed bug that caused
- # inappropriate installation to EFI/BOOT/bootx64.efi
- # 0.8.6 -- Fixed bugs that caused misidentification of ESP on disks with
- # partition numbers over 10 on OS X and misidentification of mount
- # 0.8.5 -- Refinement/cleanup of new OS X ESP-as-default policy
- # 0.8.4 -- OS X default changed to install to ESP under /EFI/BOOT
- # 0.7.9 -- Fixed bug that caused errors if dmraid utility not installed
- # 0.7.7 -- Fixed bug that created mangled refind_linux.conf file; added ability
- # to locate and mount ESP on Linux, if it's not mounted
- # 0.7.6 -- Added --ownhfs {device-filename} option
- # 0.7.5 -- Fixed bug when installing to ESP on recent versions of OS X
- # 0.7.2 -- Fixed code that could be confused by use of autofs to mount the ESP
- # 0.6.12 -- Added support for PreLoader as well as for shim
- # 0.6.11 -- Improvements in script's ability to handle directories with spaces
- # 0.6.9 -- Install gptsync on Macs
- # 0.6.6 -- Bug fix: Upgrade drivers when installed to EFI/BOOT. Also enable
- # copying shim.efi and MokManager.efi over themselves.
- # 0.6.4 -- Copies ext2 driver rather than ext4 driver for ext2/3fs
- # 0.6.3 -- Support for detecting rEFInd in EFI/BOOT and EFI/Microsoft/Boot
- # directories & for installing to EFI/BOOT in BIOS mode
- # 0.6.2-1 -- Added --yes option & tweaked key-copying for use with RPM install script
- # 0.6.0 -- Changed --drivers to --alldrivers and added --nodrivers option;
- # changed default driver installation behavior in Linux to install
- # 0.5.1.2 -- Fixed bug that caused failure to generate refind_linux.conf file
- # 0.5.1.1 -- Fixed bug that caused script failure under OS X
- # 0.5.1 -- Added --shim & --localkeys options & create sample refind_linux.conf
- # 0.5.0 -- Added --usedefault & --drivers options & changed 'esp' option to '--esp'
- # 0.4.2 -- Added notice about BIOS-based OSes & made NVRAM changes in Linux smarter
- # 0.3.3.1 -- Fixed OS X 10.7 bug; also works as make target
- # 0.3.2.1 -- Check for presence of source files; aborts if not present
- #
- # Note: install.sh version numbers match those of the rEFInd package
- TargetDir=/EFI/refind
- ShimSource='none'
- KeepName=0
- TargetX64='bootx64.efi'
- LocalKeys=0
- AlwaysYes=0
- #
- #
- GetParams() {
- # Install the driver required to read Linux /boot, if it's available
- # Note: Under OS X, this will be installed only if a Linux partition
- # is detected, in which case the ext4fs driver will be installed.
- while [[ $# -gt 0 ]]; do
- --notesp) InstallToEspOnMac=0
- --ownhfs) OwnHfs=1
- TargetPart='$2'
- shift
- --usedefault) TargetDir=/EFI/BOOT
- TargetX64='bootx64.efi'
- shift
- --root) RootDir='$2'
- shift
- --localkeys) LocalKeys=1
- --shim | --preloader) ShimSource='$2'
- shift
- --keepname) KeepName=1
- --drivers | --alldrivers) InstallDrivers='all'
- --nodrivers) InstallDrivers='none'
- --yes) AlwaysYes=1
- * ) echo 'Usage: $0 [--notesp | --usedefault {device-file} | --root {dir} |'
- echo ' [--nodrivers | --alldrivers]'
- exit 1
- shift
- if [[ '$InstallToEspOnMac' 0 && '$RootDir' '/' && '$TargetDir' '/EFI/BOOT' ]] ; then
- echo 'You may use --notesp OR --usedefault, but not both! Aborting!'
- fi
- if [[ '$RootDir' != '/' && '$TargetDir' '/EFI/BOOT' ]] ; then
- echo 'You may use --root OR --usedefault, but not both! Aborting!'
- fi
- if [[ '$TargetDir' != '/System/Library/CoreServices' && '$OwnHfs' '1' ]] ; then
- echo 'If you use --ownhfs, you may NOT use --usedefault! Aborting!'
- fi
- if [[ '$KeepName' 1 && '$ShimSource' 'none' ]] ; then
- echo 'The --keepname option is meaningful only in conjunction with --shim'
- exit 1
- if [[ '$KeepName' 1 && '$OSTYPE' != 'linux' && '$OSTYPE' != 'linux-gnu' ]] ; then
- echo 'The --keepname option is valid only under Linux! Aborting!'
- fi
- if [[ '$KeepName' 1 && '$TargetDir' '/EFI/BOOT' ]] ; then
- echo 'The --keepname option is incompatible with --usedefault! Aborting!'
- fi
- if [[ '$InstallDrivers' 'all' && '$TargetDir' != '/EFI/BOOT' ]] ; then
- echo 'The --alldrivers option is meant for creating USB flash drives with (near-)'
- echo 'universal boot support. Using it on a hard disk partition runs the risk of'
- echo 'creating serious problems, up to and including rendering your computer'
- echo -n 'unbootable. Are you SURE you want to proceed (Y/N)? '
- if [[ '$YesNo' != 'Y' && '$YesNo' != 'y' ]] ; then
- exit 0
- fi
- EtcKeysDir='$RootDir/etc/refind.d/keys'
- # Get a yes/no response from the user and place it in the YesNo variable.
- # If the AlwaysYes variable is set to 1, skip the user input and set 'Y'
- ReadYesNo() {
- YesNo='Y'
- else
- fi
- # Determine what CPU type and EFI bit depth we're using.
- # Sets Platform global variable to lowercase EFI platform code (currently
- # 'x64', 'ia32', or 'aa64') -- the same code used in filenames.
- local CpuType
- darwin*)
- CpuType=`ioreg -l -p IODeviceTree | grep firmware-abi | cut -d '' -f 4`
- Platform='ia32'
- Platform='x64'
- ;;
- CpuType=`uname -m`
- aarch64)
- ;;
- Platform='x64'
- i?86)
- # If we're in EFI mode, do some sanity checks, and alert the user or even
- # abort. Not in BIOS mode, though, since that could be used on an emergency
- # disc to try to recover a troubled Linux installation.
- if [[ '$ShimSource' != 'none' && '$TargetDir' != '/BOOT/EFI' ]] ; then
- echo 'CAUTION: shim does not currently supports 32-bit systems, so you should not'
- echo 'use the --shim option to install on such systems. Aborting!'
- exit 1
- echo
- echo 'CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based'
- echo 'computers are VERY RARE. If you've installed a 32-bit version of Linux'
- echo 'on a 64-bit computer, you should manually install the 64-bit version of'
- echo 'rEFInd. If you're positive you want to continue with this installation,'
- echo
- echo -n 'Are you sure you want to continue (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- else
- fi
- ;;
- echo 'Unknown CPU type '$CpuType'; aborting!'
- ;;
- ;;
- echo 'Unknown OS; aborting!'
- ;;
- } # DeterminePlatform()
- # Abort if the rEFInd files can't be found.
- # Also sets $ConfFile to point to the configuration file,
- # $ShimSource to the source of the shim.efi file (if necessary),
- # $ThisDir to point to the directory in which this script resides,
- # and $RefindDir to point to where the rEFInd binaries live
- # Note: $ThisDir points to real (not symlinked) script home on Linux,
- # enabling creating a symlink in /usr/sbin (or wherever); but on OS X,
- # 'readlink' doesn't do the same thing as under Linux, so the script
- case '$OSTYPE' in
- ThisDir='$( cd -P '${BASH_SOURCE%/*}' && pwd )'
- linux*)
- ;;
- RefindDir='$ThisDir/refind'
- if [[ ! -f '$RefindDir/refind_$Platform.efi' ]] ; then
- echo 'The rEFInd binary file is missing! Aborting installation!'
- fi
- if [[ -f '$RefindDir/refind.conf-sample' ]] ; then
- elif [[ -f '$ThisDir/refind.conf-sample' ]] ; then
- else
- echo 'The sample configuration file is missing! Aborting installation!'
- fi
- if [[ -d '$RefindDir/icons' ]] ; then
- elif [[ -d '$ThisDir/icons' ]] ; then
- else
- echo 'The icons directory is missing! Aborting installation!'
- fi
- echo 'ShimSource is $ShimSource'
- if [[ -f '$ShimSource' ]] ; then
- if [[ $ShimType 'shimx64.efi' || $ShimType 'shim.efi' ]] ; then
- TargetAARCH64='grubaa64.efi'
- MokManagerSource=`dirname '$ShimSource'`/MokManager.efi
- elif [[ $ShimType 'preloader.efi' || $ShimType 'PreLoader.efi' ]] ; then
- MokManagerSource=`dirname '$ShimSource'`/HashTool.efi
- echo 'Unknown shim/PreBootloader filename: $ShimType!'
- echo 'Known filenames are shimx64.efi, shim.efi, and PreLoader.efi. Aborting!'
- fi
- echo 'The specified shim/PreBootloader file, $ShimSource, doesn't exist!'
- exit 1
- fi
- # Helper for CopyRefindFiles; copies shim files (including MokManager, if it's
- CopyShimFiles() {
- local inode1=`ls -i '$ShimSource' 2> /dev/null | cut -f 1 -d ' '`
- local inode2=`ls -i '$InstallDir/$TargetDir/$TargetShim' 2> /dev/null | cut -f 1 -d ' '`
- cp -fb '$ShimSource' '$InstallDir/$TargetDir/$TargetShim'
- Problems=1
- fi
- inode1=`ls -i '$MokManagerSource' 2> /dev/null | cut -f 1 -d ' '`
- inode2=`ls -i '$InstallDir/$TargetDir/$TargetMMName' 2> /dev/null | cut -f 1 -d ' '`
- if [[ -f '$MokManagerSource' ]] ; then
- cp -fb '$MokManagerSource' '$InstallDir/$TargetDir/'
- if [[ $? != 0 ]] ; then
- fi
- } # CopyShimFiles()
- # Copy the public keys to the installation medium
- if [[ $LocalKeys 1 ]] ; then
- cp '$EtcKeysDir/$LocalKeysBase.cer' '$InstallDir/$TargetDir/keys/'
- cp '$EtcKeysDir/$LocalKeysBase.crt' '$InstallDir/$TargetDir/keys/'
- } # CopyKeys()
- # Set varaibles for installation in EFI/BOOT directory
- TargetDir='/EFI/BOOT'
- TargetX64='bootx64.efi'
- TargetAARCH64='bootaa64.efi'
- if [[ $ShimType 'shim.efi' || $ShimType 'shimx64.efi' || $ShimType = 'shimaa64.efi' ]] ; then
- TargetAARCH64='grubaa64.efi'
- elif [[ $ShimType 'preloader.efi' || $ShimType 'PreLoader.efi' ]] ; then
- else
- echo 'Unknown shim/PreBootloader type: $ShimType'
- exit 1
- TargetIA32='bootia32.efi'
- fi
- echo 'Installation is to /EFI/BOOT, which is incompatible with --keepname! Aborting!'
- fi
- # Set variables for installation in EFI/Microsoft/Boot directory
- TargetDir='/EFI/Microsoft/Boot'
- TargetX64='bootmgfw.efi'
- TargetAARCH64='bootmgfw.efi'
- if [[ $ShimType 'shim.efi' || $ShimType 'shimx64.efi' || $ShimType 'shimaa64.efi' ]] ; then
- TargetAARCH64='grubaa64.efi'
- elif [[ $ShimType 'preloader.efi' || $ShimType 'PreLoader.efi' ]] ; then
- else
- echo 'Unknown shim/PreBootloader type: $ShimType'
- exit 1
- TargetShim='bootmgfw.efi'
- if [[ $KeepName 1 ]] ; then
- echo 'Installation is to /EFI/Microsoft/Boot, which is incompatible with --keepname!'
- exit 1
- } # SetVarsForMsBoot()
- # TargetDir defaults to /EFI/refind; however, this function adjusts it as follows:
- # - If an existing refind.conf is available in /EFI/BOOT or /EFI/Microsoft/Boot,
- # install to that directory under the suitable name; but DO NOT do this if
- # - If booted in BIOS mode and the ESP lacks any other EFI files, install to
- # - If booted in BIOS mode and there's no refind.conf file and there is a
- # /EFI/Microsoft/Boot/bootmgfw.efi file, move it down one level and
- # install under that name, 'hijacking' the Windows boot loader filename
- Upgrade=0
- if [[ -f $InstallDir/EFI/BOOT/refind.conf && ! -f $InstallDir/EFI/refind/refind.conf ]] ; then
- Upgrade=1
- if [[ -f $InstallDir/EFI/Microsoft/Boot/refind.conf && ! -f $InstallDir/EFI/refind/refind.conf ]] ; then
- Upgrade=1
- if [[ -f $InstallDir/EFI/refind/refind.conf ]] ; then
- if [[ $ShimSource 'none' || $KeepName 1 ]] ; then
- TargetIA32='refind_ia32.efi'
- fi
- fi
- echo 'Found rEFInd installation in $InstallDir$TargetDir; upgrading it.'
- if [[ ! -d /sys/firmware/efi && ! $OSTYPE darwin* && $Upgrade 0 ]] ; then # BIOS-mode
- FoundEfiFiles=`find '$InstallDir/EFI/BOOT' -name '*.efi' 2> /dev/null`
- FoundConfFiles=`find '$InstallDir' -name 'refind.conf' 2> /dev/null`
- if [[ ! -n '$FoundConfFiles' && -f '$InstallDir/EFI/Microsoft/Boot/bootmgfw.efi' ]] ; then
- mv -n '$InstallDir/EFI/Microsoft/Boot/bootmgfw.efi' '$InstallDir/EFI/Microsoft' &> /dev/null
- echo 'Running in BIOS mode with a suspected Windows installation; moving boot loader'
- echo 'files so as to install to $InstallDir$TargetDir.'
- elif [[ ! -n '$FoundEfiFiles' ]] ; then # In BIOS mode and no default loader; install as default loader
- echo 'Running in BIOS mode with no existing default boot loader; installing to'
- else
- echo 'Running in BIOS mode with an existing default boot loader; backing it up and'
- if [[ -d '$InstallDir/EFI/BOOT-rEFIndBackup' ]] ; then
- echo 'Caution: An existing backup of a default boot loader exists! If the current'
- echo 'default boot loader and the backup are different boot loaders, the current'
- echo '
- echo -n 'Do you want to proceed with installation (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- else
- fi
- mv -n '$InstallDir/EFI/BOOT' '$InstallDir/EFI/BOOT-rEFIndBackup'
- fi
- } # DetermineTargetDir()
- # Determine (or guess) the filesystem used on the Linux /boot filesystem.
- SetBootFS() {
- case '$OSTYPE' in
- if command -v blkid &>/dev/null; then
- BootPart=`df $RootDir/boot | grep dev | cut -f 1 -d ' '`
- BootFS=`blkid -o export $BootPart 2> /dev/null | grep TYPE= | cut -f 2 -d =`
- ;;
- # 0FC63DAF-8483-4772-8E79-3D69D8477DE4 = Linux filesystem
- # BC13C2FF-59E6-4262-A352-B275FD6F7172 = Freedesktop $boot partition
- # 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 = Freedesktop Linux /home
- # E6D6D379-F507-44C2-A23C-238F2A3DF928 = Linux LVM
- # A19D880F-05FC-4D3B-A006-743F0F84911E = Linux RAID
- # 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F = Linux swap
- Temp=$(diskutil list | grep -i '0FC63DAF-8483-4772-8E79-3D69D8477DE4|BC13C2FF-59E6-4262-A352-B275FD6F7172|933AC7E1-2EB4-4F13-B844-0E14E2AEF915|E6D6D379-F507-44C2-A23C-238F2A3DF928|A19D880F-05FC-4D3B-A006-743F0F84911E|0657FD6D-A4AB-43C4-84E5-0933C84B4F4F|Linux')
- if [[ -n $Temp ]] ; then
- echo 'Found suspected Linux partition(s); installing ext4fs driver.'
- fi
- esac
- # Copy drivers from $RefindDir/drivers_$1 to $InstallDir/$TargetDir/drivers_$1,
- # honoring the $InstallDrivers condition. Must be passed a suitable
- CopyDrivers() {
- mkdir -p '$InstallDir/$TargetDir/drivers_$1'
- cp '$ThisDir'/drivers_$1/*_$1.efi '$InstallDir/$TargetDir/drivers_$1/' 2> /dev/null
- cp '$RefindDir'/drivers_$1/*_$1.efi '$InstallDir/$TargetDir/drivers_$1/' 2> /dev/null
- SetBootFS
- case $BootFS in
- # Could use ext4, but that can create unwanted entries from symbolic
- # links in / to /boot/vmlinuz if a separate /boot partition is used.
- ext4) DriverType='ext4'
- reiserfs) DriverType='reiserfs'
- btrfs) DriverType='btrfs'
- hfsplus) DriverType='hfs'
- ntfs) DriverType='ntfs'
- *) BootFS='
- if [[ -n $BootFS ]] ; then
- echo 'Installing driver for $BootFS (${DriverType}_$1.efi)'
- cp '$ThisDir/drivers_$1/${DriverType}_$1.efi' '$InstallDir/$TargetDir/drivers_$1/' 2> /dev/null
- cp '$RefindDir/drivers_$1/${DriverType}_$1.efi' '$InstallDir/$TargetDir/drivers_$1'/ 2> /dev/null
- fi
- # Copy tools (currently only gptsync, and that only on Macs) to the EFI/tools
- # directory on the ESP. Must be passed a suitable architecture code (ia32
- CopyTools() {
- if [[ $OSTYPE darwin* ]] ; then
- cp -f '$RefindDir/tools_$1/gptsync_$1.efi' '$InstallDir/EFI/tools/'
- if [[ -f '$InstallDir/EFI/tools/gptsync.efi' ]] ; then
- mv '$InstallDir/EFI/tools/gptsync.efi' '$InstallDir/EFI/tools/gptsync.efi-disabled'
- echo 'Found old gptsync.efi; disabling it by renaming it to gptsync.efi-disabled'
- fi
- # Copy the rEFInd files to the ESP or OS X root partition.
- CopyRefindFiles() {
- if [[ '$TargetDir' '/EFI/BOOT' ]] ; then
- cp '$RefindDir/refind_ia32.efi' '$InstallDir/$TargetDir/$TargetIA32' 2> /dev/null
- echo 'Note: IA32 (x86) binary not installed!'
- cp '$RefindDir/refind_x64.efi' '$InstallDir/$TargetDir/$TargetX64' 2> /dev/null
- Problems=1
- cp '$RefindDir/refind_aa64.efi' '$InstallDir/$TargetDir/$TargetAARCH64' 2> /dev/null
- Problems=1
- if [[ '$ShimSource' != 'none' ]] ; then
- CopyShimFiles
- if [[ $InstallDrivers 'all' ]] ; then
- cp -r '$RefindDir'/drivers_* '$InstallDir/$TargetDir/' 2> /dev/null
- cp -r '$ThisDir'/drivers_* '$InstallDir/$TargetDir/' 2> /dev/null
- elif [[ $Upgrade 1 || $InstallToEspOnMac 1 ]] ; then
- CopyTools '$Platform'
- Refind='boot$Platform.efi'
- elif [[ $Platform 'x64' || $TargetDir '/EFI/Microsoft/Boot' ]] ; then
- cp '$RefindDir/refind_x64.efi' '$InstallDir/$TargetDir/$TargetX64'
- Problems=1
- CopyDrivers x64
- Refind='refind_x64.efi'
- if [[ '$ShimSource' != 'none' ]] ; then
- TargetShim=`basename '$ShimSource'`
- CopyShimFiles
- if [[ $LocalKeys 0 ]] ; then
- echo 'Storing copies of rEFInd Secure Boot public keys in $EtcKeysDir'
- cp '$ThisDir/keys/refind.cer' '$EtcKeysDir' 2> /dev/null
- cp '$ThisDir/keys/refind.crt' '$EtcKeysDir' 2> /dev/null
- fi
- if [[ '$TargetDir' '/System/Library/CoreServices' ]] ; then
- fi
- elif [[ $Platform 'ia32' || $Platform 'aa64' ]] ; then
- cp '$RefindDir/refind_ia32.efi' '$InstallDir/$TargetDir/$TargetIA32'
- Problems=1
- else
- cp '$RefindDir/refind_aa64.efi' '$InstallDir/$TargetDir/$TargetAARCH64'
- Problems=1
- fi
- CopyTools $Platform
- if [[ '$TargetDir' '/System/Library/CoreServices' ]] ; then
- fi
- echo 'Unknown platform! Aborting!'
- fi
- echo '
- if [[ -d '$InstallDir/$TargetDir/icons' ]] ; then
- rm -rf '$InstallDir/$TargetDir/icons-backup' &> /dev/null
- mv -f '$InstallDir/$TargetDir/icons' '$InstallDir/$TargetDir/icons-backup'
- echo 'Notice: Backed up existing icons directory as icons-backup.'
- cp -r '$IconsDir' '$InstallDir/$TargetDir'
- Problems=1
- mkdir -p '$InstallDir/$TargetDir/keys'
- cp -rf '$ThisDir'/keys/*.[cd]er '$InstallDir/$TargetDir/keys/' 2> /dev/null
- cp -rf '$EtcKeysDir'/*.[cd]er '$InstallDir/$TargetDir/keys/' 2> /dev/null
- if [[ -f '$InstallDir/$TargetDir/refind.conf' ]] ; then
- echo 'Existing refind.conf file found; copying sample file as refind.conf-sample'
- echo '
- if [[ $? != 0 ]] ; then
- fi
- echo 'Copying sample configuration file as refind.conf; edit this file to configure'
- echo '
- cp -f '$ConfFile' '$InstallDir/$TargetDir/refind.conf'
- Problems=1
- fi
- echo 'Deleting the temporary directory $RefindDir'
- fi
- # Mount the partition the user specified with the --usedefault or --ownhfs option
- InstallDir=/tmp/refind_install
- UnmountEsp=1
- if [[ $OwnHfs '1' ]] ; then
- Temp=`diskutil info '$TargetPart' | grep 'Mount Point'`
- if [[ $InstallDir ' ]] ; then
- mount -t hfs '$TargetPart' '$InstallDir'
- UnmountEsp=0
- else
- fi
- mount -t vfat '$TargetPart' '$InstallDir'
- if [[ $? != 0 ]] ; then
- rmdir '$InstallDir'
- fi
- # A series of OS X support functions..
- # Mount the ESP at /Volumes/ESP or determine its current mount
- # Sets InstallDir to the ESP mount point
- MountOSXESP() {
- # Identify the ESP. Note: This returns the FIRST ESP found;
- # if the system has multiple disks, this could be wrong!
- Temp=$(mount | sed -n -E '/^(/dev/disk[0-9]+s[0-9]+) on / (.*$/s//1/p')
- Temp=$(diskutil list | grep ' EFI ' | grep -o 'disk.*' | head -n 1)
- echo 'Warning: root device doesn't have an EFI partition'
- else
- fi
- Temp=$(diskutil list | sed -n -E '/^ *[0-9]+:[ ]+EFI EFI[ ]+[0-9.]+ [A-Z]+[ ]+(disk[0-9]+s[0-9]+)$/ { s//1/p
- }' )
- if [ -z $Temp ]; then
- echo 'Could not find an EFI partition. Aborting!'
- fi
- Esp=/dev/`echo $Temp`
- # If the ESP is mounted, use its current mount point..
- InstallDir=`echo $Temp | cut -f 6- -d ' '`
- mkdir /Volumes/ESP &> /dev/null
- # Some systems have HFS+ 'ESPs.' They shouldn't, but they do. If this is
- # detected, mount it as such and set appropriate options.
- mount -t hfs '$Esp' /Volumes/Esp
- InstallToEspOnMac=0
- echo 'Unable to mount ESP! Aborting!n'
- fi
- UnmountEsp=1
- fi
- # Set up for booting from Mac HFS+ volume that boots rEFInd in MJG's way
- # Must be passed the original rEFInd binary filename (without a path).
- if [[ -s '$InstallDir/mach_kernel' ]] ; then
- echo 'Attempt to install rEFInd to a partition with a /mach_kernel file! Aborting!'
- fi
- cp -n '$InstallDir/$TargetDir/boot.efi' '$InstallDir/$TargetDir/boot.efi-backup' &> /dev/null
- ln -f '$InstallDir/$TargetDir/$1' '$InstallDir/$TargetDir/boot.efi'
- rm '$InstallDir/$TargetDir/SystemVersion.plist' &> /dev/null
- cat - << ENDOFHERE >> '$InstallDir/$TargetDir/SystemVersion.plist'
- <plist version='1.0'>
- <key>ProductBuildVersion</key>
- <key>ProductName</key>
- <key>ProductVersion</key>
- </dict>
- ENDOFHERE
- if [[ -x '/usr/bin/csrutil' && -z '$TargetPart' ]] ; then
- grep 'Protection status: disabled|enabled (Apple Internal)|NVRAM Protections: disabled'`
- echo
- echo
- echo 'You are attempting to upgrade an existing installation, but it appears that'
- echo 'System Integrity Protection (SIP) is enabled. If rEFInd is working now, then'
- echo 'this is fine; you can upgrade your existing rEFInd. If rEFInd is not working,'
- echo 'though, re-installing from this boot will not help. To re-enable rEFInd, you'
- echo 'must re-install it from a Recovery system or from another OS. To enter the'
- else
- echo 'rEFInd cannot be installed because System Integrity Protection (SIP) seems'
- echo 'to be enabled! You must install rEFInd from your Recovery installation or'
- echo 'from another OS. To install from the Recovery system:'
- echo
- echo ' 2. Hold down Command+R as the chime sounds'
- echo ' 3. When the OS has booted, select Utilities->Terminal'
- echo ' 4. Change to this directory with the 'cd' command; it will probably be under'
- if [[ '`pwd | cut -b 1-8`' '/Volumes' ]] ; then
- else
- local RootName=`diskutil info -plist / | grep -A 1 VolumeName | grep string | cut -d > -f 2 | cut -d < -f 1`
- fi
- echo
- echo 'If you believe SIP is NOT enabled, you may attempt an installation anyhow,'
- echo
- echo 'For more on this subject, see http://www.rodsbooks.com/refind/sip.html'
- echo -n 'Do you want to attempt installation (Y/N)? '
- if [[ $YesNo 'N' || $YesNo 'n' ]] ; then
- exit
- fi # csrutil status suggests OK to install
- } # CheckForSIP()
- # Control the OS X installation.
- # Sets Problems=1 if problems found during the installation.
- echo 'Installing rEFInd on OS X..'
- if [[ '$InstallToEspOnMac' '1' && -z '$TargetPart' ]] ; then
- elif [[ '$TargetDir' '/EFI/BOOT' || '$OwnHfs' '1' ]] ; then
- else
- fi
- echo 'Installing rEFInd to the partition mounted at $InstallDir'
- CheckForSIP
- mkdir -p /usr/local/bin &> /dev/null
- cp '$ThisDir/mountesp' /usr/local/bin/ &> /dev/null
- if [[ $InstallToEspOnMac '1' && -z '$TargetPart' ]] ; then
- bless --mount '$InstallDir' --setBoot --file '$InstallDir/$TargetDir/$Refind' --shortform
- bless --setBoot --folder '$InstallDir/$TargetDir' --file '$InstallDir/$TargetDir/$Refind'
- if [[ $? != 0 ]] ; then
- fi
- if [[ -f /Library/StartupItems/rEFItBlesser || -d /Library/StartupItems/rEFItBlesser ]] ; then
- echo '/Library/StartupItems/rEFItBlesser found!'
- echo 'This program is part of rEFIt, and will cause rEFInd to fail to work after'
- echo -n 'its first boot. Do you want to remove rEFItBlesser (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- echo 'Deleting /Library/StartupItems/rEFItBlesser..'
- else
- fi
- } # InstallOnOSX()
- # Now a series of Linux support functions..
- # Check for evidence that we're running in Secure Boot mode. If so, and if
- # appropriate options haven't been set, warn the user and offer to abort.
- # If we're NOT in Secure Boot mode but the user HAS specified the --shim
- # or --localkeys option, warn the user and offer to abort.
- IsSecureBoot='0'
- if [[ -f /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c ]] ; then
- IsSecureBoot=`od -An -t u1 /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c | awk '{print substr($0,length,1)}'`
- elif [[ -f /sys/firmware/efi/vars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c/data ]] ; then
- IsSecureBoot=`od -An -t u1 /sys/firmware/efi/vars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c/data | tr -d '[[:space:]]'`
- if [[ $IsSecureBoot '1' && '$TargetDir' != '/EFI/BOOT' && '$ShimSource' 'none' ]] ; then
- echo 'CAUTION: Your computer appears to be booted with Secure Boot, but you haven't'
- echo 'specified a valid shim.efi file source. Chances are you should re-run with'
- echo 'the --shim option. You can read more about this topic at'
- echo 'http://www.rodsbooks.com/refind/secureboot.html.'
- echo -n 'Do you want to proceed with installation (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- else
- fi
- if [[ '$ShimSource' != 'none' && ! $IsSecureBoot '1' ]] ; then
- echo 'You've specified installing using a shim.efi file, but your computer does not'
- echo 'appear to be running in Secure Boot mode. Although installing in this way'
- echo 'should work, it's unnecessarily complex. You may continue, but unless you'
- echo 'plan to enable Secure Boot, you should consider stopping and omitting the'
- echo '--shim option. You can read more about this topic at'
- echo 'http://www.rodsbooks.com/refind/secureboot.html.'
- echo -n 'Do you want to proceed with installation (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- else
- fi
- if [[ $LocalKeys != 0 && ! $IsSecureBoot '1' ]] ; then
- echo 'You've specified re-signing your rEFInd binaries with locally-generated keys,'
- echo 'but your computer does not appear to be running in Secure Boot mode. The'
- echo 'keys you generate will be useless unless you enable Secure Boot. You may'
- echo 'proceed with this installation, but before you do so, you may want to read'
- echo 'more about it at http://www.rodsbooks.com/refind/secureboot.html.'
- echo -n 'Do you want to proceed with installation (Y/N)? '
- if [[ $YesNo 'Y' || $YesNo 'y' ]] ; then
- else
- fi
- # Check for the presence of locally-generated keys from a previous installation in
- # $EtcKeysDir (/etc/refind.d/keys). If they're not present, generate them using
- GenerateKeys() {
- CertKey='$EtcKeysDir/$LocalKeysBase.crt'
- OpenSSL=`which openssl 2> /dev/null`
- # Do the work only if one or more of the necessary keys is missing
- # TODO: Technically, we don't need the DerKey; but if it's missing and openssl
- # is also missing, this will fail. This could be improved.
- if [[ ! -f '$PrivateKey' || ! -f '$CertKey' || ! -f '$DerKey' ]] ; then
- mkdir -p '$EtcKeysDir'
- if [[ ! -x '$OpenSSL' ]] ; then
- echo 'Can't find openssl, which is required to create your private signing keys!'
- exit 1
- if [[ -f '$PrivateKey' ]] ; then
- cp -f '$PrivateKey' '$PrivateKey.backup' 2> /dev/null
- if [[ -f '$CertKey' ]] ; then
- cp -f '$CertKey' '$CertKey.backup' 2> /dev/null
- if [[ -f '$DerKey' ]] ; then
- cp -f '$DerKey' '$DerKey.backup' 2> /dev/null
- '$OpenSSL' req -new -x509 -newkey rsa:2048 -keyout '$PrivateKey' -out '$CertKey'
- -nodes -days 3650 -subj '/CN=Locally-generated rEFInd key/'
- '$OpenSSL' x509 -in '$CertKey' -out '$DerKey' -outform DER
- else
- fi
- # $1 = source file
- # Also assumes that the SBSign and various key variables are set appropriately.
- SignOneBinary() {
- $SBSign --key '$PrivateKey' --cert '$CertKey' --output '$2' '$1' 2>&1 >/dev/null |
- grep -v 'data remaining.*gaps between PE/COFF sections'
- echo 'Problem signing the binary $1! Aborting!'
- fi
- # Re-sign the x86-64 binaries with a locally-generated key, First look for appropriate
- # key files in $EtcKeysDir. If they're present, use them to re-sign the binaries. If
- # not, try to generate new keys and store them in $EtcKeysDir.
- SBSign=`which sbsign 2> /dev/null`
- TempDir='/tmp/refind_local'
- echo 'Can't find sbsign, which is required to sign rEFInd with your own keys!'
- exit 1
- GenerateKeys
- cp '$RefindDir/refind.conf-sample $TempDir' 2> /dev/null
- cp '$ThisDir/refind.conf-sample $TempDir' 2> /dev/null
- cp '$RefindDir/refind_ia32.efi $TempDir' 2> /dev/null
- cp -a '$RefindDir/drivers_ia32 $TempDir' 2> /dev/null
- cp -a '$ThisDir/drivers_ia32 $TempDir' 2> /dev/null
- SignOneBinary '$RefindDir/refind_$Platform.efi' '$TempDir/refind_$Platform.efi'
- IFS=$(echo -en 'nb')
- for Driver in `ls '$RefindDir'/drivers_$Platform/*.efi '$ThisDir'/drivers_$Platform/*.efi 2> /dev/null` ; do
- SignOneBinary '$Driver' '$TempDir/drivers_$Platform/$TempName'
- IFS=$SaveIFS
- DeleteRefindDir=1
- # Locate and mount an ESP, if possible, based on parted output.
- # Should be called only if /boot/efi is NOT an acceptable ESP.
- # Sets InstallDir to the mounted ESP's path ($RootDir/boot/efi)
- # and EspFilesystem the filesystem (always 'vfat')
- echo 'The ESP doesn't seem to be mounted! Trying to find it..'
- local Drive
- local TableType
- local SkipIt
- for Name in `lsblk -r | grep disk | cut -f 1 -d ' '` ; do
- SkipIt=0
- if [ -x '$Dmraid' ] ; then
- if [ -n '$DmStatus' ] ; then
- echo '$Drive seems to be part of a RAID array; skipping!'
- fi
- TableType=`parted $Drive print -m -s 2>/dev/null | awk -F: '$1 '$Drive' { print $6 }'`
- if [[ $TableType 'gpt' && $SkipIt 0 ]] ; then # read only GPT disks that aren't part of dmraid array
- PartNum=`LANG=C parted $Drive print -m -s 2>/dev/null | awk -F: '$7 ~ '(^boot| boot)' { print $1 }' | head -n 1`
- if [ '$PartNum' -eq '$PartNum' ] 2> /dev/null ; then
- mkdir -p $InstallDir
- EspFilesystem=`grep '$Drive$PartNum.*/boot/efi' /etc/mtab | uniq | grep -v autofs | cut -d ' ' -f 3`
- umount $InstallDir
- echo 'Mounting ESP at $InstallDir'
- fi
- fi # TableType
- } # FindLinuxESP()
- # Identifies the ESP's location (/boot or /boot/efi, or these locations under
- # the directory specified by --root); aborts if the ESP isn't mounted at
- # Sets InstallDir to the ESP mount point.
- mount /boot &> /dev/null
- EspLine=`df '$RootDir/boot/efi' 2> /dev/null | grep boot/efi`
- EspLine=`df '$RootDir'/boot | grep boot`
- InstallDir=`echo $EspLine | cut -d ' ' -f 6`
- if [[ -n '$InstallDir' ]] ; then
- EspFilesystem=`grep -w '$InstallDir' /etc/mtab | uniq | grep -v autofs | cut -d ' ' -f 3`
- if [[ $EspFilesystem != 'vfat' ]] ; then
- fi
- echo '$RootDir/$InstallDir doesn't seem to be on a VFAT filesystem. The ESP must be'
- echo 'mounted at $RootDir/boot or $RootDir/boot/efi and it must be VFAT! Aborting!'
- exit 1
- echo 'The computer appears to be running in BIOS mode and has no ESP. You should'
- echo 'create an ESP, and ideally boot in EFI mode, before installing rEFInd.'
- fi
- echo 'ESP was found at $InstallDir using $EspFilesystem'
- # Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM.
- AddBootEntry() {
- Efibootmgr=`which efibootmgr 2> /dev/null`
- InstallDisk=`grep '$InstallDir' /etc/mtab | cut -d ' ' -f 1 | cut -c 1-8`
- PartNum=`grep '$InstallDir' /etc/mtab | cut -d ' ' -f 1 | cut -c 9-10`
- EfiEntryFilename=`echo ${EntryFilename////}`
- EfiEntryFilename2=`echo ${EfiEntryFilename} | sed s///g`
- ExistingEntry=`'$Efibootmgr' -v | grep -i '$EfiEntryFilename2'`
- if [[ '$ExistingEntry' ]] ; then
- ExistingEntryBootNum=`echo '$ExistingEntry' | cut -c 5-8`
- FirstBoot=`'$Efibootmgr' | grep BootOrder | cut -c 12-15`
- if [[ '$ExistingEntryBootNum' != '$FirstBoot' ]] ; then
- echo 'An existing rEFInd boot entry exists, but isn't set as the default boot'
- echo 'manager. The boot order is being adjusted to make rEFInd the default boot'
- echo 'manager. If this is NOT what you want, you should use efibootmgr to'
- fi
- '$Efibootmgr' -b $ExistingEntryBootNum -B &> /dev/null
- if [[ '$KeepName' 0 ]] ; then
- '$Efibootmgr' -c -l '$EfiEntryFilename' -L 'rEFInd Boot Manager' -d $InstallDisk -p $PartNum &> /dev/null
- '$Efibootmgr' -c -l '$EfiEntryFilename' -L 'rEFInd Boot Manager' -d $InstallDisk -p $PartNum
- fi
- EfibootmgrProblems=1
- fi
- else # efibootmgr not found
- Problems=1
- echo
- echo 'ALERT: There were problems running the efibootmgr program! You may need to'
- echo 'rename the $Refind binary to the default name (EFI/BOOT/bootx64.efi'
- echo 'on x86-64 systems, EFI/BOOT/bootia32.efi on x86 systems, or'
- echo 'EFI/BOOT/bootaa64.efi on ARM64 systems) to have it run!'
- else
- echo 'rEFInd has been set as the default boot manager.'
- } # AddBootEntry()
- # Create a minimal/sample refind_linux.conf file in /boot.
- if [[ -f '$RLConfFile' ]] ; then
- echo 'Existing $RLConfFile found; not overwriting.'
- echo 'Creating $RLConfFile; edit it to adjust kernel options.'
- RootFS=`df '$RootDir' | grep dev | cut -f 1 -d ' '`
- if [[ '$StartOfDevname' '/dev/sd' || '$StartOfDevName' '/dev/hd' ]] ; then
- # Identify root filesystem by UUID rather than by device node, if possible
- Uuid=`blkid -o export -s UUID '$RootFS' 2> /dev/null | grep UUID=`
- RootFS='$Uuid'
- fi
- local FirstCmdlineOption=`cat /proc/cmdline | cut -d ' ' -f 1`
- if [[ '$FirstCmdlineOption' =~ (vmlinuz|bzImage|kernel) ]] ; then
- DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/S*initrd=S*//g' | sed 's/ *$//' | sed 's/^ *//'`
- DefaultOptions=`cat /proc/cmdline | sed 's/S*initrd=S*//g' | sed 's/ *$//' | sed 's/^ *//'`
- else
- # We want the default options used by the distribution, stored here..
- echo 'Setting default boot options based on $RootDir/etc/default/grub'
- DefaultOptions='ro root=$RootFS $GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT'
- echo 'Boot with standard options' '$DefaultOptions' > $RLConfFile
- echo 'Boot to single-user mode' '$DefaultOptions single' >> $RLConfFile
- echo 'Boot with minimal options' 'ro root=$RootFS' >> $RLConfFile
- }
- # Controls rEFInd installation under Linux.
- InstallOnLinux() {
- if [[ '$TargetDir' '/System/Library/CoreServices' ]] ; then
- echo 'You may not use the --ownhfs option under Linux! Aborting!'
- fi
- modprobe efivars &> /dev/null
- MountDefaultTarget
- FindMountedESP
- fi
- if [[ $LocalKeys 1 ]] ; then
- fi
- CheckSecureBoot
- if [[ '$TargetDir' != '/EFI/BOOT' && '$TargetDir' != '/EFI/Microsoft/Boot' ]] ; then
- GenerateRefindLinuxConf
- } # InstallOnLinux()
- #
- # The main part of the script. Sets a few environment variables,
- # performs a few startup checks, and then calls functions to
- # install under OS X or Linux, depending on the detected platform.
- GetParams '$@'
- echo 'Not running as root; attempting to elevate privileges via sudo..'
- if [[ $? != 0 ]] ; then
- echo 'This script must be run as root (or using sudo). Exiting!'
- else
- fi
- DeterminePlatform
- case '$OSTYPE' in
- if [[ '$ShimSource' != 'none' ]] ; then
- echo 'The --shim option is not supported on OS X! Exiting!'
- fi
- echo 'The --localkeys option is not supported on OS X! Exiting!'
- fi
- ;;
- InstallOnLinux
- *)
- if [[ '$InstallToEspOnMac' 0 ]] ; then
- echo 'The --notesp option is not supported on Linux! Exiting!'
- fi
- echo
- echo 'Installation has completed, but problems were detected. Review the output for'
- echo 'error messages and take corrective measures as necessary. You may need to'
- echo 're-run this script or install manually before rEFInd will work.'
- else
- echo 'Installation has completed successfully.'
- fi
- if [[ $UnmountEsp '1' ]] ; then
- case '$OSTYPE' in
- diskutil unmount $InstallDir
- *)
- ;;
- fi
- if [[ '$InstallDir' /tmp/refind_install ]] ; then
- rmdir '$InstallDir'
Join GitHub today
The Refind Binary File Is Missing Aborting Installation Artifactory
Sphero lock combination. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Hauppauge wintv drivers xp update. All WinTV PCI models, including the WinTV GO, WinTV Theater, and Impact VCB models may be installed on Windows XP systems. For instructions on reinstalling the WinTV PCI on Windows XP please follow these steps, using the software and drivers provided on that page.
- Upon installation, it copies the files to the ESP and registers rEFInd as the default boot loader with the ESP, assuming the computer was booted in EFI mode. The binary Debian package is equivalent to the binary RPM file and can be used in much the same way on Debian, Ubuntu, Mint, and other Linux distributions that employ Debian packages.
- Plus, the refind_linux.conf file and kernel are also on the second ESP, which actually is mount as /boot in Linux, so I thought it'd be nice to have everything all together on the same partition in addition to keeping Apple stuff clean.
- Echo ' The rEFInd binary file is missing! Aborting installation! Echo ' The sample configuration file is missing! Aborting installation! ' exit 1: fi: if.
- I recently tried to install rEFInd onto my Mac but it could not boot into the Ubuntu disk. To uninstall It I formatted my drive and reinstalled OS X along with my backup. From the menu bar select 'File->Disable Journaling'. Missing EFI + MediaKit. Can't modify partitions.
![Binary Binary](/uploads/1/2/4/7/124781785/766865112.jpg)
If the Binary.dll file is not in the DLL Cache, or the DLL Cache is corrupted, you will be prompted to insert the Windows installation disc to recover the original files. To run System File Checker ( Windows XP, Vista, 7, 8, and 10 ).
Sign upThe Refind Binary File Is Missing Aborting Installation Article
![The Refind Binary File Is Missing Aborting Installation Art The Refind Binary File Is Missing Aborting Installation Art](/uploads/1/2/4/7/124781785/974858687.jpg)
The Refind Binary File Is Missing Aborting Installation Art Definition
Find file Copy path
Cannot retrieve contributors at this time
#!/bin/bash |
# |
# Linux/MacOS X script to install rEFInd |
# |
# Usage: |
# |
# ./install.sh [esp] |
# |
# The 'esp' option is valid only on Mac OS X; it causes |
# installation to the EFI System Partition (ESP) rather than |
# to the current OS X boot partition. Under Linux, this script |
# installs to the ESP by default. |
# |
# This program is copyright (c) 2012 by Roderick W. Smith |
# It is released under the terms of the GNU GPL, version 3, |
# a copy of which should be included in the file COPYING.txt. |
# |
# Revision history: |
# |
# 0.3.3.1 -- Fixed OS X 10.7 bug; also works as make target |
# 0.3.2.1 -- Check for presence of source files; aborts if not present |
# 0.3.2 -- Initial version |
# |
# Note: install.sh version numbers match those of the rEFInd package |
# with which they first appeared. |
TargetDir=/EFI/refind |
# |
# Functions used by both OS X and Linux.. |
# |
# Abort if the rEFInd files can't be found. |
# Also sets $ConfFile to point to the configuration file, and |
# $IconsDir to point to the icons directory |
CheckForFiles() { |
# Note: This check is satisfied if EITHER the 32- or the 64-bit version |
# is found, even on the wrong platform. This is because the platform |
# hasn't yet been determined. This could obviously be improved, but it |
# would mean restructuring lots more code.. |
if [[ !-f$RefindDir/refind_ia32.efi &&!-f$RefindDir/refind_x64.efi ]] ;then |
echo'The rEFInd binary file is missing! Aborting installation!' |
exit 1 |
fi |
if [[ -f$RefindDir/refind.conf-sample ]] ;then |
ConfFile=$RefindDir/refind.conf-sample |
elif [[ -f$ThisDir/refind.conf-sample ]] ;then |
ConfFile=$ThisDir/refind.conf-sample |
else |
echo'The sample configuration file is missing! Aborting installation!' |
exit 1 |
fi |
if [[ -d$RefindDir/icons ]] ;then |
IconsDir=$RefindDir/icons |
elif [[ -d$ThisDir/icons ]] ;then |
IconsDir=$ThisDir/icons |
else |
echo'The icons directory is missing! Aborting installation!' |
fi |
} # CheckForFiles() |
# Copy the rEFInd files to the ESP or OS X root partition. |
# Sets Problems=1 if any critical commands fail. |
CopyRefindFiles() { |
mkdir -p $InstallPart/$TargetDir&> /dev/null |
if [[ $Platform'EFI32' ]] ;then |
cp $RefindDir/refind_ia32.efi $InstallPart/$TargetDir |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
Refind='refind_ia32.efi' |
elif [[ $Platform'EFI64' ]] ;then |
cp $RefindDir/refind_x64.efi $InstallPart/$TargetDir |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
Refind='refind_x64.efi' |
else |
echo'Unknown platform! Aborting!' |
exit 1 |
fi |
echo'Copied rEFInd binary file $Refind' |
echo'' |
if [[ -d$InstallPart/$TargetDir/icons ]] ;then |
rm -rf $InstallPart/$TargetDir/icons-backup &> /dev/null |
mv -f $InstallPart/$TargetDir/icons $InstallPart/$TargetDir/icons-backup |
echo'Notice: Backed up existing icons directory as icons-backup.' |
fi |
cp -r $IconsDir$InstallPart/$TargetDir |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
if [[ -f$InstallPart/$TargetDir/refind.conf ]] ;then |
echo'Existing refind.conf file found; copying sample file as refind.conf-sample' |
echo'to avoid collision.' |
echo'' |
cp -f $ConfFile$InstallPart/$TargetDir |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
else |
echo'Copying sample configuration file as refind.conf; edit this file to configure' |
echo'rEFInd.' |
echo'' |
cp -f $ConfFile$InstallPart/$TargetDir/refind.conf |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
fi |
} # CopyRefindFiles() |
# |
# A series of OS X support functions.. |
# |
# Mount the ESP at /Volumes/ESP or determine its current mount |
# point. |
# Sets InstallPart to the ESP mount point |
# Sets UnmountEsp if we mounted it |
MountOSXESP() { |
# Identify the ESP. Note: This returns the FIRST ESP found; |
# if the system has multiple disks, this could be wrong! |
Temp=`diskutil list | grep EFI` |
Esp=/dev/`echo $Temp| cut -f 5 -d ''` |
# If the ESP is mounted, use its current mount point.. |
Temp=`df | grep $Esp` |
InstallPart=`echo $Temp| cut -f 6 -d ''` |
if [[ $InstallPart'' ]] ;then |
mkdir /Volumes/ESP &> /dev/null |
mount -t msdos $Esp /Volumes/ESP |
if [[ $?!= 0 ]] ;then |
echo'Unable to mount ESP! Aborting!n' |
exit 1 |
fi |
UnmountEsp=1 |
InstallPart='/Volumes/ESP' |
fi |
} # MountOSXESP() |
# Control the OS X installation. |
# Sets Problems=1 if problems found during the installation. |
InstallOnOSX() { |
echo'Installing rEFInd on OS X..' |
if [[ $1'esp'||$1'ESP' ]] ;then |
MountOSXESP |
else |
InstallPart='/' |
fi |
echo'Installing rEFInd to the partition mounted at '$InstallPart'' |
Platform=`ioreg -l -p IODeviceTree | grep firmware-abi | cut -d ''' -f 4` |
CopyRefindFiles |
if [[ $1'esp'||$1'ESP' ]] ;then |
bless --mount $InstallPart --setBoot --file $InstallPart/$TargetDir/$Refind |
else |
bless --setBoot --folder $InstallPart/$TargetDir --file $InstallPart/$TargetDir/$Refind |
fi |
if [[ $?!= 0 ]] ;then |
Problems=1 |
fi |
echo |
echo'WARNING: If you have an Advanced Format disk, *DO NOT* attempt to check the' |
echo'bless status with 'bless --info', since this is known to cause disk corruption' |
echo'on some systems!!' |
echo |
} # InstallOnOSX() |
# |
# Now a series of Linux support functions.. |
# |
# Identifies the ESP's location (/boot or /boot/efi); aborts if |
# the ESP isn't mounted at either location. |
# Sets InstallPart to the ESP mount point. |
FindLinuxESP() { |
EspLine=`df /boot/efi | grep boot` |
InstallPart=`echo $EspLine| cut -d '' -f 6` |
EspFilesystem=`grep $InstallPart /etc/mtab | cut -d '' -f 3` |
if [[ $EspFilesystem!='vfat' ]] ;then |
echo'/boot/efi doesn't seem to be on a VFAT filesystem. The ESP must be mounted at' |
echo'/boot or /boot/efi and it must be VFAT! Aborting!' |
exit 1 |
fi |
echo'ESP was found at $InstallPart using $EspFilesystem' |
} # MountLinuxESP |
# Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM. |
# If this fails, sets Problems=1 |
AddBootEntry() { |
Efibootmgr=`which efibootmgr 2> /dev/null` |
if [[ $Efibootmgr ]] ;then |
modprobe efivars &> /dev/null |
InstallDisk=`grep $InstallPart /etc/mtab | cut -d '' -f 1 | cut -c 1-8` |
PartNum=`grep $InstallPart /etc/mtab | cut -d '' -f 1 | cut -c 9-10` |
EntryFilename=$TargetDir/$Refind |
EfiEntryFilename=`echo ${EntryFilename////}` |
ExistingEntry=`$Efibootmgr -v | grep $Refind` |
if [[ $ExistingEntry ]] ; then |
echo 'An existing EFI boot manager entry for rEFInd seems to exist:' |
echo |
echo '$ExistingEntry' |
echo |
echo 'This entry is NOT being modified, and no new entry is being created.' |
else |
$Efibootmgr -c -l $EfiEntryFilename -L rEFInd -d $InstallDisk -p $PartNum &> /dev/null |
if [[ $? != 0 ]] ; then |
EfibootmgrProblems=1 |
Problems=1 |
fi |
fi |
else |
EfibootmgrProblems=1 |
Problems=1 |
fi |
if [[ $EfibootmgrProblems ]] ; then |
echo |
echo 'ALERT: There were problems running the efibootmgr program! You may need to' |
echo 'rename the $Refind binary to the default name (EFI/boot/bootx64.efi' |
echo 'on x86-64 systems or EFI/boot/bootia32.efi on x86 systems) to have it run!' |
echo |
fi |
}# AddBootEntry() |
# Controls rEFInd installation under Linux. |
# Sets Problems=1 if something goes wrong. |
InstallOnLinux() { |
echo 'Installing rEFInd on Linux..' |
FindLinuxESP |
CpuType=`uname -m` |
if [[ $CpuType'x86_64' ]] ;then |
Platform='EFI64' |
elif [[ $CpuType'i386'||$CpuType'i486'||$CpuType'i586'||$CpuType'i686' ]] ;then |
Platform='EFI32' |
echo |
echo'CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based' |
echo'computers are VERY RARE. If you've installed a 32-bit version of Linux' |
echo'on a 64-bit computer, you should manually install the 64-bit version of' |
echo'rEFInd. If you're installing on a Mac, you should do so from OS X. If' |
echo'you're positive you want to continue with this installation, answer 'Y'' |
echo'to the following question..' |
echo |
echo -n 'Are you sure you want to continue (Y/N)? ' |
read ContYN |
if [[ $ContYN'Y'||$ContYN'y' ]] ;then |
echo'OK; continuing with the installation..' |
else |
exit 0 |
fi |
else |
echo'Unknown CPU type '$CpuType'; aborting!' |
exit 1 |
fi |
CopyRefindFiles |
AddBootEntry |
} # InstallOnLinux() |
# |
# The main part of the script. Sets a few environment variables, |
# performs a few startup checks, and then calls functions to |
# install under OS X or Linux, depending on the detected platform. |
# |
OSName=`uname -s` |
ThisDir='$(cd -P '$( dirname '${BASH_SOURCE[0]}')'&&pwd)' |
RefindDir='$ThisDir/refind' |
ThisScript='$ThisDir/`basename $0`' |
CheckForFiles |
if [[ `whoami`!='root' ]] ;then |
echo'Not running as root; attempting to elevate privileges via sudo..' |
sudo $ThisScript$1 |
if [[ $?!= 0 ]] ;then |
echo'This script must be run as root (or using sudo). Exiting!' |
exit 1 |
else |
exit 0 |
fi |
fi |
if [[ $OSName'Darwin' ]] ;then |
InstallOnOSX $1 |
elif [[ $OSName'Linux' ]] ;then |
InstallOnLinux |
else |
echo'Running on unknown OS; aborting!' |
fi |
if [[ $Problems ]] ;then |
echo |
echo'ALERT:' |
echo'Installation has completed, but problems were detected. Review the output for' |
echo'error messages and take corrective measures as necessary. You may need to' |
echo're-run this script or install manually before rEFInd will work.' |
echo |
else |
echo |
echo'Installation has completed successfully.' |
echo |
fi |
if [[ $UnmountEsp ]] ;then |
umount $InstallPart |
fi |
System Registry File Is Missing Or Corrupt
Copy lines Copy permalink