Permalink
Browse files

Add bootManager=GRUB option to pc-sysinstall. Using this will require…

… that

you ship grub-install && grub-mkconfig with your install image,
or just install the package during installation time.
  • Loading branch information...
1 parent fdb75b8 commit 9caf430463d25f1977a5807b4d0629c414cf338a @kmoore134 kmoore134 committed Jun 18, 2013
@@ -383,6 +383,34 @@ set_root_pw()
};
+# Script which stamps grub on the specified disks
+setup_grub()
+{
+ # Mount devfs
+ rc_halt "mount -t devfs devfs ${FSMNT}/dev"
+
+ # Read through our list and stamp grub for each device
+ while read line
+ do
+ # Make sure we have a /dev in front of the disk name
+ echo $line | grep -q '/dev/'
+ if [ $? -eq 0 ] ; then
+ gDisk="$line"
+ else
+ gDisk="/dev/$line"
+ fi
+
+ # Stamp GRUB now
+ rc_halt "chroot ${FSMNT} grub-install --force $gDisk"
+ done < ${TMPDIR}/.grub-install
+
+ # Make sure we re-create the default grub.cfg
+ rc_halt "chroot ${FSMNT} grub-mkconfig -o /boot/grub/grub.cfg"
+
+ # Sleep and cleanup
+ sleep 5
+ rc_halt "umount ${FSMNT}/dev"
+};
run_final_cleanup()
{
@@ -410,4 +438,8 @@ run_final_cleanup()
# Generate the fstab for the installed system
setup_fstab
+
+ # Check if we need to setup GRUB
+ if [ -e "${TMPDIR}/.grub-install" ] ; then setup_grub; fi
+
};
@@ -648,6 +648,7 @@ init_apm_full_disk()
init_gpt_full_disk()
{
_intDISK=$1
+ _intBOOT=$2
# Set our sysctl so we can overwrite any geom using drives
sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
@@ -664,8 +665,13 @@ init_gpt_full_disk()
rc_halt "gpart create -s GPT ${_intDISK}"
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}"
+ if [ "${_intBOOT}" = "GRUB" ] ; then
+ # Doing a GRUB stamp? Lets save it for post-install
+ echo "${_intDISK}" >> ${TMPDIR}/.grub-install
+ else
+ echo_log "Stamping boot sector on ${_intDISK}"
+ rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}"
+ fi
}
@@ -705,6 +711,9 @@ init_mbr_full_disk()
if [ "$_intBOOT" = "bsd" ] ; then
echo_log "Stamping boot0 on ${_intDISK}"
rc_halt "gpart bootcode -b /boot/boot0 ${_intDISK}"
+ elif [ "$_intBOOT" = "GRUB" ] ; then
+ # Doing a GRUB stamp? Lets save it for post-install
+ echo "${_intDISK}" >> ${TMPDIR}/.grub-install
else
echo_log "Stamping boot1 on ${_intDISK}"
rc_halt "gpart bootcode -b /boot/boot1 ${_intDISK}"
@@ -726,7 +735,7 @@ run_gpart_full()
init_mbr_full_disk "$DISK" "$BOOT"
slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'`
else
- init_gpt_full_disk "$DISK"
+ init_gpt_full_disk "$DISK" "$BOOT"
slice=`echo "${DISK}:1:gpt" | sed 's|/|-|g'`
fi
@@ -836,10 +845,12 @@ run_gpart_slice()
sleep 1
- if [ "${BMANAGER}" = "bsd" ]
- then
+ if [ "${BMANAGER}" = "bsd" ]; then
echo_log "Stamping boot sector on ${DISK}"
rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
+ elif [ "${BMANAGER}" = "GRUB" ] ; then
+ # Doing a GRUB stamp? Lets save it for post-install
+ echo "${DISK}" >> ${TMPDIR}/.grub-install
fi
# Set the slice to the format we'll be using for gpart later
@@ -889,10 +900,12 @@ run_gpart_free()
sleep 1
- if [ "${BMANAGER}" = "bsd" ]
- then
+ if [ "${BMANAGER}" = "bsd" ]; then
echo_log "Stamping boot sector on ${DISK}"
rc_halt "gpart bootcode -b /boot/boot0 ${DISK}"
+ elif [ "${BMANAGER}" = "GRUB" ] ; then
+ # Doing a GRUB stamp? Lets save it for post-install
+ echo "${DISK}" >> ${TMPDIR}/.grub-install
fi
slice=`echo "${DISK}:${SLICENUM}:mbr" | sed 's|/|-|g'`
@@ -161,10 +161,10 @@ than the drive being mirrored.
Allows the setting of the mirror balance method to be used, if not
specified this defaults to "round-robin"
-# bootManager=(none, bsd)
+# bootManager=(none, bsd, GRUB)
Setting this option will instruct pc-sysinstall to install the BSD boot Manager,
-or leave it empty
+GRUB boot-manager, or leave it empty
# image=(/path/to/image/file) (/mountpoint)

0 comments on commit 9caf430

Please sign in to comment.