[PC-BSD Commits] r8166 - pcbsd/current/build-files/src-patches

svn at pcbsd.org svn at pcbsd.org
Tue Dec 7 14:37:23 PST 2010


Author: kris
Date: 2010-12-07 14:37:23 -0800 (Tue, 07 Dec 2010)
New Revision: 8166

Modified:
   pcbsd/current/build-files/src-patches/patch-pcsysinstall-4k-bsdlabel.txt
Log:

Updated our patch for 4k alignment, and also includes a fix for going from GPT disk back to MBR
and the backup GPT tables getting cleared out properly



Modified: pcbsd/current/build-files/src-patches/patch-pcsysinstall-4k-bsdlabel.txt
===================================================================
--- pcbsd/current/build-files/src-patches/patch-pcsysinstall-4k-bsdlabel.txt	2010-12-07 21:31:05 UTC (rev 8165)
+++ pcbsd/current/build-files/src-patches/patch-pcsysinstall-4k-bsdlabel.txt	2010-12-07 22:37:23 UTC (rev 8166)
@@ -1,6 +1,6 @@
-diff -ruN usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh.o usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
---- usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh.o	2010-11-15 15:18:24.629391537 -0500
-+++ usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	2010-11-16 10:31:20.623658464 -0500
+diff -ruN usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+--- usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	2010-12-07 13:14:06.809482201 -0500
++++ usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	2010-12-07 16:25:32.516591385 -0500
 @@ -158,227 +158,29 @@
    export VAL
  };
@@ -308,20 +308,25 @@
        fi
  
        # Figure out the gpart type to use
-@@ -483,7 +297,11 @@
+@@ -483,7 +297,16 @@
        esac
  
        # Create the partition
 -      rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${DISK}"
 +      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
  
        # Check if this is a root / boot partition, and stamp the right loader
        for TESTMNT in `echo ${MNT} | sed 's|,| |g'`
-@@ -497,19 +315,53 @@
+@@ -497,19 +320,53 @@
        done 
  
        # Save this data to our partition config dir
@@ -384,7 +389,7 @@
  
      fi # End of subsection locating a slice in config
  
-@@ -518,13 +370,17 @@
+@@ -518,13 +375,17 @@
      then
  
        # If this is the boot disk, stamp the right gptboot
@@ -405,7 +410,7 @@
  
        # Found our flag to commit this label setup, check that we found at least 1 partition
        if [ "${CURPART}" = "2" ] ; then
-@@ -564,15 +420,9 @@
+@@ -564,15 +425,9 @@
      exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
    fi
  
@@ -423,19 +428,75 @@
  
  };
  
-diff -ruN usr.sbin/pc-sysinstall/backend/functions-disk.sh.o usr.sbin/pc-sysinstall/backend/functions-disk.sh
---- usr.sbin/pc-sysinstall/backend/functions-disk.sh.o	2010-11-15 15:18:24.622397324 -0500
-+++ usr.sbin/pc-sysinstall/backend/functions-disk.sh	2010-11-16 11:14:11.012131353 -0500
-@@ -580,7 +580,7 @@
+diff -ruN usr.sbin/pc-sysinstall/backend/functions-disk.sh usr.sbin/pc-sysinstall/backend/functions-disk.sh
+--- usr.sbin/pc-sysinstall/backend/functions-disk.sh	2010-12-07 13:14:06.809482201 -0500
++++ usr.sbin/pc-sysinstall/backend/functions-disk.sh	2010-12-07 16:25:29.544320674 -0500
+@@ -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 128 -t freebsd-boot ${_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}"
-@@ -593,7 +593,7 @@
+@@ -593,7 +614,7 @@
    _intDISK=$1
    _intBOOT=$2
   
@@ -444,3 +505,14 @@
  
    # Set our sysctl so we can overwrite any geom using drives
    sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
+@@ -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