Mac Build Scripts

Generate fdisk script
This script takes a raw device argument like /dev/hda and writes out a set of commands that can be fed to fdisk to automatically define a partition table for a Mac. The commands are written to a file named fdisk.script, but that can be changed to stdout, if this script needs to called from another script, for example. It is currently only tested for G3 towers, and needs more work and testing # # target=$1 test $target || echo "no target specified" test $target || exit 1 # bootstart=64 bootlen=1954 swaplen=1494848 linuxstart=2018 linuxlen=$(($hdlen-(2017+$swaplen))) swapstart=$(($linuxstart+$linuxlen)) # echo i > fdisk.script echo "" >> fdisk.script echo p >> fdisk.script echo C >> fdisk.script echo $bootstart >> fdisk.script echo $bootlen >> fdisk.script echo untitled >> fdisk.script echo Apple_Bootstrap >> fdisk.script echo p >> fdisk.script echo c >> fdisk.script echo $linuxstart >> fdisk.script echo $linuxlen >> fdisk.script echo c >> fdisk.script echo p >> fdisk.script echo $swapstart >> fdisk.script echo $swaplen >> fdisk.script echo swap >> fdisk.script echo p >> fdisk.script echo w >> fdisk.script echo "" >> fdisk.script echo q >> fdisk.script
 * 1) !/bin/sh
 * 1) create a set of input commands for fdisk to use to partition a blank
 * 2) drive for Macintosh machines.
 * 1) Partitions are created in the same order that an Ubuntu installation creates
 * 2) them:
 * 3)   1. partition map
 * 4)   2. boot partition
 * 5)   3. linux partition
 * 6)   4. swap partition
 * 7) The partition map is automatically created with length 63.  The boot
 * 8) partition start block (64) and size (1954) are known (from the Ubuntu model).
 * 9) The swap partition size is fixed arbitrary size, chosen to support 512Mb
 * 10) of ram and to allow the swap and linux partition lengths to be even.
 * 1) target device
 * 1) starts and lengths for boot, linux and swap partitions
 * 1) known values
 * 1) calculated values
 * 1) debug
 * 2) echo "target=          $target"
 * 3) echo "hdlen=           $hdlen"
 * 4) echo "bootstart=       $bootstart"
 * 5) echo "bootlen=         $bootlen"
 * 6) echo "linuxstart=      $linuxstart"
 * 7) echo "linuxlen=        $linuxlen"
 * 8) echo "swapstart=       $swapstart"
 * 9) echo "swaplen=         $swaplen"
 * 10) calclen=$((63+$bootlen+$linuxlen+$swaplen))
 * 11) echo "calculated hdlen= $calclen"
 * 1) write an input script for fdisk
 * 1) initialize partition table, answer disk length query, and show the result
 * 1) create a boot partition with explicit partition size/type, and show result
 * 1) create a linux native partition, and show result
 * 1) create the swap partition. and show result
 * 1) write out the partition map and confirm
 * 1) we done partishin' now