[PC-BSD Commits] r8167 - pcbsd/stable/pc-sysinstall/backend
svn at pcbsd.org
svn at pcbsd.org
Tue Dec 7 14:39:30 PST 2010
Author: kris
Date: 2010-12-07 14:39:30 -0800 (Tue, 07 Dec 2010)
New Revision: 8167
Modified:
pcbsd/stable/pc-sysinstall/backend/functions-bsdlabel.sh
pcbsd/stable/pc-sysinstall/backend/functions-disk.sh
Log:
MFC changes to pc-sysinstall for 4k disk alignment, and fix for wiping out GPT backup tables
Modified: pcbsd/stable/pc-sysinstall/backend/functions-bsdlabel.sh
===================================================================
--- pcbsd/stable/pc-sysinstall/backend/functions-bsdlabel.sh 2010-12-07 22:37:23 UTC (rev 8166)
+++ pcbsd/stable/pc-sysinstall/backend/functions-bsdlabel.sh 2010-12-07 22:39:30 UTC (rev 8167)
@@ -298,7 +298,12 @@
# Create the partition
if [ "${_pType}" = "gpt" ] ; then
- rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}"
+ if [ "$CURPART" = "2" ] ; then
+ # If this is GPT, make sure first partition is aligned to 4k
+ rc_halt "gpart add -b 2016 ${SOUT} -t ${PARTYPE} ${_pDisk}"
+ else
+ rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}"
+ fi
else
rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}"
fi
Modified: pcbsd/stable/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/stable/pc-sysinstall/backend/functions-disk.sh 2010-12-07 22:37:23 UTC (rev 8166)
+++ pcbsd/stable/pc-sysinstall/backend/functions-disk.sh 2010-12-07 22:39:30 UTC (rev 8167)
@@ -248,7 +248,7 @@
delete_all_gpart()
{
echo_log "Deleting all gparts"
- DISK="$1"
+ local DISK="$1"
# Check for any swaps to stop
for i in `gpart show ${DISK} 2>/dev/null | grep 'freebsd-swap' | tr -s ' ' | cut -d ' ' -f 4`
@@ -265,6 +265,13 @@
fi
done
+ # Destroy the disk geom
+ rc_nohalt "gpart destroy ${DISK}"
+
+ # Make sure we clear any hidden gpt tables
+ clear_backup_gpt_table "${DISK}"
+
+ # Wipe out front of disk
rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=3000"
};
@@ -558,6 +565,24 @@
fi
} ;
+
+# Function to wipe the potential backup gpt table from a disk
+clear_backup_gpt_table()
+{
+ # Get the disk block size
+ local dSize="`gpart show $1 | grep $1 | tr -s ' ' | cut -d ' ' -f 3`"
+
+ # Make sure this is a valid number
+ is_num "${dSize}" >/dev/null 2>/dev/null
+ if [ "$?" != "0" ] ; then return ; fi
+
+ # Die backup label, DIE
+ echo_log "Clearing gpt backup table location on disk"
+ rc_nohalt "dd if=/dev/zero of=${1} bs=512 seek=${dSize}"
+
+} ;
+
+
# Function which runs gpart and creates a single large GPT partition scheme
init_gpt_full_disk()
{
@@ -572,15 +597,11 @@
# Remove any existing partitions
delete_all_gpart "${_intDISK}"
- #Erase any existing bootloader
- echo_log "Cleaning up ${_intDISK}"
- rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
-
sleep 2
echo_log "Running gpart on ${_intDISK}"
rc_halt "gpart create -s GPT ${_intDISK}"
- rc_halt "gpart add -b 34 -s 1982 -t freebsd-boot ${_intDISK}"
+ rc_halt "gpart add -b 34 -s 64 -t freebsd-boot ${_intDISK}"
echo_log "Stamping boot sector on ${_intDISK}"
rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}"
@@ -604,10 +625,6 @@
# Remove any existing partitions
delete_all_gpart "${_intDISK}"
- #Erase any existing bootloader
- echo_log "Cleaning up ${_intDISK}"
- rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
-
sleep 2
echo_log "Running gpart on ${_intDISK}"
More information about the Commits
mailing list