diff options
author | jpaetzel <jpaetzel@FreeBSD.org> | 2011-02-18 15:00:25 +0000 |
---|---|---|
committer | jpaetzel <jpaetzel@FreeBSD.org> | 2011-02-18 15:00:25 +0000 |
commit | 56e8c76633dfcde8ec5fb5f6425c1c5efa126026 (patch) | |
tree | 5d827d4cfa2a2708fbbe737bea6cd9ba24932ca9 /usr.sbin | |
parent | b35b3cdb7175a6a6ac7a09b47e1d1cfc53c27816 (diff) | |
download | FreeBSD-src-56e8c76633dfcde8ec5fb5f6425c1c5efa126026.zip FreeBSD-src-56e8c76633dfcde8ec5fb5f6425c1c5efa126026.tar.gz |
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)
Diffstat (limited to 'usr.sbin')
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh | 56 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh | 2 |
2 files changed, 32 insertions, 26 deletions
diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh index a4b2b25..407c9a4 100755 --- a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh +++ b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh @@ -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`" - -# 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 ' '`" +# If no TYPE specified, default to MBR +if [ -z "$TYPE" ] ; then TYPE="mbr" ; fi + +# 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 "$?" diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh index ff62a6f..2dc7093 100755 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh +++ b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh @@ -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 |