1 #!/bin/sh 2 3 # Support partitioning of a device using sfdisk. 4 # 5 # Important tasks: 6 # 7 # Erase bootloader blocks. 8 # Perform partitioning using sfdisk. 9 10 PROGNAME=`basename "$0"` 11 THISDIR=`dirname "$0"` 12 13 COMMON="$THISDIR/makesd-common" 14 EXPAND="$THISDIR/makesd-expand-def" 15 PARTSUMMARY="$THISDIR/makesd-partition-summary" 16 PARTTABLE="$THISDIR/makesd-partition-table" 17 SFDISK="/sbin/sfdisk" 18 19 . "$COMMON" 20 21 22 23 # Test sfdisk behaviour and obtain useful information. 24 25 init_sfdisk() 26 { 27 if "$SFDISK" -uS -s "$1" > /dev/null 2>&1 ; then 28 SFDISK_OPTIONS="-uS -L" 29 else 30 SFDISK_OPTIONS= 31 fi 32 } 33 34 35 36 # Obtain details of the selected device. 37 38 check_device 39 40 # Test for the cylinder alignment option. 41 42 if [ "$1" = '--align' ] ; then 43 ALIGN_CYLINDER="$1" 44 shift 1 45 else 46 ALIGN_CYLINDER= 47 fi 48 49 DEF="$1" 50 51 if [ ! "$DEF" ] ; then 52 cat 1>&2 <<EOF 53 No definition specified. 54 EOF 55 exit 1 56 fi 57 58 # Initialise sfdisk usage. 59 60 init_sfdisk "$DEV" 61 62 # Expand the definition to partitioning options. 63 # Use the options to generate a partition summary. 64 # Convert the summary into a table. 65 # Present the table to sfdisk. 66 67 "$EXPAND" "$DEF" \ 68 | xargs "$PARTSUMMARY" \ 69 | "$PARTTABLE" $ALIGN_CYLINDER \ 70 | "$SFDISK" $SFDISK_OPTIONS "$DEV"