Difference between revisions of "Mac Build Scripts"

From FreekiWiki
Jump to navigation Jump to search
(page creation, fdisk_scriptgen added)
 
Line 21: Line 21:
 
  test $target || echo "no target specified"
 
  test $target || echo "no target specified"
 
  test $target || exit 1
 
  test $target || exit 1
 +
 +
[[Category:Macintosh]]
 
    
 
    
 
  # starts and lengths for boot, linux and swap partitions
 
  # starts and lengths for boot, linux and swap partitions

Revision as of 15:11, 14 February 2007

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

#!/bin/sh
#
# create a set of input commands for fdisk to use to partition a blank
# drive for Macintosh machines.
#
# Partitions are created in the same order that an Ubuntu installation creates
# them: 
#   1. partition map
#   2. boot partition
#   3. linux partition
#   4. swap partition
# The partition map is automatically created with length 63.  The boot
# partition start block (64) and size (1954) are known (from the Ubuntu model). 
# The swap partition size is fixed arbitrary size, chosen to support 512Mb
# of ram and to allow the swap and linux partition lengths to be even.

# target device
target=$1
test $target || echo "no target specified"
test $target || exit 1
 
# starts and lengths for boot, linux and swap partitions
#
# known values
bootstart=64
bootlen=1954
swaplen=1494848
linuxstart=2018
 
# calculated values
linuxlen=$(($hdlen-(2017+$swaplen)))
swapstart=$(($linuxstart+$linuxlen))

# debug
#echo "target=           $target"
#echo "hdlen=            $hdlen"
#echo "bootstart=        $bootstart"
#echo "bootlen=          $bootlen"
#echo "linuxstart=       $linuxstart"
#echo "linuxlen=         $linuxlen"
#echo "swapstart=        $swapstart"
#echo "swaplen=          $swaplen"
#calclen=$((63+$bootlen+$linuxlen+$swaplen))
#echo "calculated hdlen= $calclen"

# write an input script for fdisk
#
# initialize partition table, answer disk length query, and show the result
echo i > fdisk.script
echo "" >> fdisk.script
echo p >> fdisk.script

# create a boot partition with explicit partition size/type, and show result
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

# create a linux native partition, and show result
echo c >> fdisk.script
echo $linuxstart >> fdisk.script
echo $linuxlen >> fdisk.script
echo c >> fdisk.script
echo p >> fdisk.script

# create the swap partition. and show result
echo $swapstart >> fdisk.script
echo $swaplen >> fdisk.script
echo swap >> fdisk.script
echo p >> fdisk.script

# write out the partition map and confirm
echo w >> fdisk.script
echo "" >> fdisk.script

# we done partishin' now
echo q >> fdisk.script