Permalink
Browse files

Fix GRUB and GPT to place nice together

  • Loading branch information...
1 parent d464bcc commit acdd4b9e88a5f0520702c0817948314e0e7e7b1f @kmoore134 kmoore134 committed Jun 21, 2013
@@ -105,6 +105,14 @@ setup_zfs_mirror_parts()
{
_nZFS=""
+ # Check if the target disk is using GRUB
+ grep -q "/dev/$2" ${TMPDIR}/.grub-install 2>/dev/null
+ if [ $? -eq 0 ] ; then
+ _tBL="GRUB"
+ else
+ _tBL="bsd"
+ fi
+
ZTYPE="`echo ${1} | awk '{print $1}'`"
# Using mirroring, setup boot partitions on each disk
@@ -119,9 +127,13 @@ setup_zfs_mirror_parts()
is_disk "$_zvars" >/dev/null 2>/dev/null
if [ $? -eq 0 ] ; then
echo "Setting up ZFS disk $_zvars" >>${LOGOUT}
- init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null
+ init_gpt_full_disk "$_zvars" "$_tBL" >/dev/null 2>/dev/null
rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
- rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null
+
+ # If we are not using GRUB we need to add pmbr / gptzfsboot
+ if [ "$_tBL" != "GRUB" ] ; then
+ rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null
+ fi
_nZFS="$_nZFS ${_zvars}p2"
else
_nZFS="$_nZFS ${_zvars}"
@@ -663,12 +663,13 @@ init_gpt_full_disk()
echo_log "Running gpart on ${_intDISK}"
rc_halt "gpart create -s GPT ${_intDISK}"
- rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_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
else
+ rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}"
echo_log "Stamping boot sector on ${_intDISK}"
rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}"
fi

0 comments on commit acdd4b9

Please sign in to comment.