#
# Revision history:
#
+# 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
# honoring the $InstallDrivers condition. Must be passed a suitable
# architecture code (ia32 or x64).
CopyDrivers() {
+ local Blkid
+
+ Blkid=`which blkid 2> /dev/null`
if [[ $InstallDrivers == "all" ]] ; then
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
- elif [[ "$InstallDrivers" == "boot" && -x `which blkid` ]] ; then
+ elif [[ "$InstallDrivers" == "boot" && -x "$Blkid" ]] ; then
BootPart=`df /boot | grep dev | cut -f 1 -d " "`
- BootFS=`blkid -o export $BootPart 2> /dev/null | grep TYPE= | cut -f 2 -d =`
+ BootFS=`$Blkid -o export $BootPart 2> /dev/null | grep TYPE= | cut -f 2 -d =`
DriverType=""
case $BootFS in
ext2 | ext3) DriverType="ext2"
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 " | grep -o 'disk.*'`
+ Temp=$(mount | sed -n -E "/^(\/dev\/disk[0-9]+s[0-9]+) on \/ \(.*$/s//\1/p")
+ if [ $Temp ]; then
+ Temp=$(diskutil list $Temp | sed -n -E '/^ *[0-9]+:[ ]+EFI EFI[ ]+[0-9.]+ [A-Z]+[ ]+(disk[0-9]+s[0-9]+)$/ { s//\1/p
+ q
+ }' )
+ if [ -z $Temp ]; then
+ echo "Warning: root device doesn't have an EFI partition"
+ fi
+ else
+ echo "Warning: root device could not be found"
+ fi
+ if [ -z $Temp ]; then
+ Temp=$(diskutil list | sed -n -E '/^ *[0-9]+:[ ]+EFI EFI[ ]+[0-9.]+ [A-Z]+[ ]+(disk[0-9]+s[0-9]+)$/ { s//\1/p
+ q
+ }' )
+
+ if [ -z $Temp ]; then
+ echo "Could not find an EFI partition. Aborting!"
+ exit 1
+ fi
+ fi
Esp=/dev/`echo $Temp`
# If the ESP is mounted, use its current mount point....
Temp=`df -P | grep "$Esp"`
cp -n "$InstallDir/$TargetDir/boot.efi" "$InstallDir/$TargetDir/boot.efi-backup" &> /dev/null
ln -f "$InstallDir/$TargetDir/$1" "$InstallDir/$TargetDir/boot.efi"
touch "$InstallDir/mach_kernel"
- cp -n "$RefindDir/icons/os_refind.icns" "$InstallDir/.VolumeIcon.icns" &> /dev/null
rm "$InstallDir/$TargetDir/SystemVersion.plist" &> /dev/null
cat - << ENDOFHERE >> "$InstallDir/$TargetDir/SystemVersion.plist"
<xml version="1.0" encoding="UTF-8"?>
local Drive
local PartNum
local TableType
+ local DmStatus
+ local SkipIt
+ local Dmraid
for Drive in `ls /dev/[sh]d?` ; do
- TableType=`parted $Drive print -m -s 2> /dev/null | head -n 2 | tail -n 1 | cut -d ":" -f 6`
- if [[ $TableType == 'gpt' ]] ; then # read only GPT disks
- PartNum=`parted $Drive print -m -s 2> /dev/null | grep ":boot[,;]" | cut -d ":" -f 1`
+ SkipIt=0
+ Dmraid=`which dmraid 2> /dev/null`
+ if [ -x "$Dmraid" ] ; then
+ DmStatus=`dmraid -r | grep $Drive`
+ if [ -n "$DmStatus" ] ; then
+ echo "$Drive seems to be part of a RAID array; skipping!"
+ SkipIt=1
+ fi
+ 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
InstallDir="$RootDir/boot/efi"
mkdir -p $InstallDir
# either location.
# Sets InstallDir to the ESP mount point.
FindMountedESP() {
+ mount /boot &> /dev/null
+ mount /boot/efi &> /dev/null
EspLine=`df "$RootDir/boot/efi" 2> /dev/null | grep boot/efi`
if [[ ! -n "$EspLine" ]] ; then
EspLine=`df "$RootDir"/boot | grep boot`
InstallDir=`echo $EspLine | cut -d " " -f 6`
if [[ -n "$InstallDir" ]] ; then
- EspFilesystem=`grep "$InstallDir" /etc/mtab | uniq | grep -v autofs | cut -d " " -f 3`
+ EspFilesystem=`grep -w "$InstallDir" /etc/mtab | uniq | grep -v autofs | cut -d " " -f 3`
fi
if [[ $EspFilesystem != 'vfat' ]] ; then
FindLinuxESP