#!/bin/sh [ x${1}x = xx ] && echo "USAGE: '$0 drivename', where drivename is the full path to the drive node (/dev/ad0, etc)" && exit 1 disk=$1 # STEP 1 - CREATE SLICES echo "Create Slices:" # Put the geom. line into the script # Sometimes you get a bogus sector value, not sure why fdisk -p $disk | head -2 | sed -e 's/s255/s63/' >/tmp/fdiskscript # First slice is 5gb echo "p 1 165 255 10489425" >>/tmp/fdiskscript echo "a 1" >>/tmp/fdiskscript # This is how many sectors are on the disk -- there must be a better way to get this sectors=$(newfs -N $disk | head -1 | awk '{print $3}' | cut -c2-) # Second slice is the rest of the drive echo "p 2 165 10489680 $(($sectors-10489680))" >>/tmp/fdiskscript # Zero the other slices in case they are already defined echo "p 3 0 0 0" >>/tmp/fdiskscript echo "p 4 0 0 0" >>/tmp/fdiskscript fdisk -f /tmp/fdiskscript $disk # Install the FreeBSD boot loader boot0cfg -B $disk fdisk -p $disk #STEP 2 - CREATE PARTITIONS echo "Create Partitions:" # Write a basic label for the first slice, we only need a single partition bsdlabel -w ${disk}s1 bsdlabel ${disk}s1 # Write something more complicated for the second slice bsdlabel -w ${disk}s2 cat </tmp/label 8 partitions: # size offset fstype # / a: 512M 16 unused # swap b: 2G * swap # special crap - don't touch c: * * unused # /var d: 2G * unused # /usr e: * * unused EOF bsdlabel -R ${disk}s2 /tmp/label bsdlabel ${disk}s2 # STEP 3 - INITIALISE REIMAGING PARTITION echo "Restore reimaging partition:" newfs -n ${disk}s1a >/dev/null # Restore the reimaging partition... mkdir /reimage mount ${disk}s1a /reimage cd /reimage restore -rf /mnt/dev-reimage-partition.dump echo "Set the right /etc/fstab data:" cat <