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