Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Add some initial EFI installation support using GRUB
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Moore committed Oct 21, 2014
1 parent b5a7a42 commit 0505904
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src-sh/pc-sysinstall/backend/functions-disk.sh
Expand Up @@ -675,9 +675,20 @@ init_gpt_full_disk()
rc_halt "gpart create -s GPT ${_intDISK}"

if [ "${_intBOOT}" = "GRUB" ] ; then
rc_halt "gpart add -b 34 -s 1M -t bios-boot ${_intDISK}"
# Doing a GRUB stamp? Lets save it for post-install
echo "${_intDISK}" >> ${TMPDIR}/.grub-install

# Check the boot mode we are using {pc|efi}
BOOTMODE=`kenv grub.platform`
if [ "$BOOTMODE" = "efi" ]; then
# Need to enable EFI booting, lets create the stupid FAT partition
rc_halt "gpart add -s 100M -t efi ${_intDISK}"
# Doing a GRUB stamp? Lets save it for post-install
echo "${_intDISK}" >> ${TMPDIR}/.grub-install
else
# Doing bios-boot partition
rc_halt "gpart add -b 34 -s 1M -t bios-boot ${_intDISK}"
# Doing a GRUB stamp? Lets save it for post-install
echo "${_intDISK}" >> ${TMPDIR}/.grub-install
fi
else
rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}"
echo_log "Stamping boot sector on ${_intDISK}"
Expand Down
27 changes: 26 additions & 1 deletion src-sh/pc-sysinstall/backend/functions-unmount.sh
Expand Up @@ -35,7 +35,7 @@ umount_all_dir()
for _ud in $_umntdirs
do
echo_log "Unmounting: ${_ud}"
sleep 5
sleep 2
umount -f ${_ud}
done
}
Expand Down Expand Up @@ -251,6 +251,15 @@ setup_grub()
GRUBFLAGS="--modules='zfs part_gpt part_bsd geli'"
fi

# Check if we ned to install in EFI mode
BOOTMODE=`kenv grub.platform`
if [ "$BOOTMODE" = "efi" ]; then
GRUBFLAGS="$GRUBFLAGS --efi-directory=/boot/efi --target=x86_64-efi"
EFIMODE="TRUE"
else
EFIMODE="FALSE"
fi

# Read through our list and stamp grub for each device
while read line
do
Expand All @@ -262,8 +271,24 @@ setup_grub()
gDisk="/dev/$line"
fi

# Do any EFI creation
if [ "$EFIMODE" = "TRUE" ] ;then
# Format the EFI partition
echo_log "Formatting EFI / FAT32 partition"
rc_halt "newfs_msdos -F 32 ${gDisk}p1"

# Mount the partition
mkdir ${FSMNT}/boot/efi
rc_halt "mount -t msdosfs ${gDisk}p1 ${FSMNT}/boot/efi"
fi

# Stamp GRUB now
rc_halt "chroot ${FSMNT} grub-install $GRUBFLAGS --force $gDisk"

# Cleanup after EFI
if [ "$EFIMODE" = "TRUE" ] ;then
rc_halt "umount ${FSMNT}/boot/efi"
fi
done < ${TMPDIR}/.grub-install

# Make sure we re-create the default grub.cfg
Expand Down

0 comments on commit 0505904

Please sign in to comment.