From owner-svn-src-head@FreeBSD.ORG Fri Feb 18 15:00:25 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4FC7106566B; Fri, 18 Feb 2011 15:00:25 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 909D48FC16; Fri, 18 Feb 2011 15:00:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1IF0P4l061796; Fri, 18 Feb 2011 15:00:25 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1IF0PK4061793; Fri, 18 Feb 2011 15:00:25 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201102181500.p1IF0PK4061793@svn.freebsd.org> From: Josh Paetzel Date: Fri, 18 Feb 2011 15:00:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218800 - in head/usr.sbin/pc-sysinstall: backend-partmanager pc-sysinstall X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 15:00:25 -0000 Author: jpaetzel Date: Fri Feb 18 15:00:25 2011 New Revision: 218800 URL: http://svn.freebsd.org/changeset/base/218800 Log: Add support to pc-sysinstall's create-part feature, to create non MBR type partitions, such as GPT and others. PR: bin/154684 Submitted by: kmoore Approved by: kib (mentor, implicit) Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Fri Feb 18 14:54:34 2011 (r218799) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Fri Feb 18 15:00:25 2011 (r218800) @@ -25,7 +25,7 @@ # # $FreeBSD$ -# Query a disk for partitions and display them +# Create partitions on a target disk ############################# . ${PROGDIR}/backend/functions.sh @@ -47,46 +47,52 @@ fi DISK="${1}" MB="${2}" +TYPE="${3}" +STARTBLOCK="${4}" TOTALBLOCKS="`expr $MB \* 2048`" +# If no TYPE specified, default to MBR +if [ -z "$TYPE" ] ; then TYPE="mbr" ; fi -# Lets figure out what number this slice will be -LASTSLICE="`fdisk -s /dev/${DISK} 2>/dev/null | grep -v ${DISK} | grep ':' | tail -n 1 | cut -d ':' -f 1 | tr -s '\t' ' ' | tr -d ' '`" +# Sanity check the gpart type +case $TYPE in + apm|APM) ;; + bsd|BSD) ;; + ebr|EBR) ;; + pc98|pc98) ;; + gpt|GPT) ;; + mbr|MBR) ;; + vtoc8|VTOC8) ;; + *) echo "Error: Unknown gpart type: $TYPE" ; exit 1 ;; +esac + +# Lets figure out what number this partition will be +LASTSLICE="`gpart show $DISK | grep -v -e $DISK -e '\- free \-' -e '^$' | awk 'END {print $3}'`" if [ -z "${LASTSLICE}" ] ; then LASTSLICE="1" else LASTSLICE="`expr $LASTSLICE + 1`" fi -if [ ${LASTSLICE} -gt "4" ] ; then - echo "Error: FreeBSD MBR setups can only have a max of 4 slices" - exit 1 -fi - - SLICENUM="${LASTSLICE}" -# Lets get the starting block -if [ "${SLICENUM}" = "1" ] ; then - STARTBLOCK="63" -else - # Lets figure out where the prior slice ends - checkslice="`expr ${SLICENUM} - 1`" - - # Get starting block of this slice - fdisk -s /dev/${DISK} | grep -v "${DISK}:" | grep "${checkslice}:" | tr -s " " >${TMPDIR}/pfdisk - pstartblock="`cat ${TMPDIR}/pfdisk | cut -d ' ' -f 3`" - psize="`cat ${TMPDIR}/pfdisk | cut -d ' ' -f 4`" - STARTBLOCK="`expr ${pstartblock} + ${psize}`" +# Set a 4k Aligned start block if none specified +if [ "${SLICENUM}" = "1" -a -z "$STARTBLOCK" ] ; then + STARTBLOCK="2016" fi -# If this is an empty disk, see if we need to create a new MBR scheme for it +# If this is an empty disk, see if we need to create a new scheme for it gpart show ${DISK} >/dev/null 2>/dev/null if [ "$?" != "0" -a "${SLICENUM}" = "1" ] ; then - gpart create -s mbr ${DISK} + gpart create -s ${TYPE} ${DISK} +fi + +# If we have a starting block, use it +if [ -z "$STARTBLOCK" ] ; then + sBLOCK="-b $STARTBLOCK" fi -gpart add -b ${STARTBLOCK} -s ${TOTALBLOCKS} -t freebsd -i ${SLICENUM} ${DISK} +gpart add ${sBLOCK} -s ${TOTALBLOCKS} -t freebsd -i ${SLICENUM} ${DISK} exit "$?" Modified: head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh Fri Feb 18 14:54:34 2011 (r218799) +++ head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh Fri Feb 18 15:00:25 2011 (r218800) @@ -125,7 +125,7 @@ case $1 in ;; # The user is wanting to create a new partition - create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" + create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}" ;; # The user is wanting to delete an existing partition