#!/bin/sh BL1=bl1.bin.hardkernel UBOOT=u-boot.bin if [ -z $1 ]; then echo "usage ./sd_freebsd.sh " exit 0 fi if [ ! -f $BL1 ]; then echo "Error: $BL1 does not exist." exit 0 fi if [ ! -f $UBOOT ]; then echo "Error: $UBOOT does not exist." exit 0 fi # Write BL1 / MBR dd if=$BL1 of=$1 bs=512 # Write U-boot dd if=$UBOOT of=$1 bs=512 seek=64 conv=sync # Zero out U-boot Environment dd if=/dev/zero of=$1 bs=512 seek=1024 count=64 # Create MBR GEOM gpart create -s mbr `basename $1` # Add MSDOS partition to contain kernel.bin gpart add -t fat16 -b 1134 -s 64M `basename $1` # Add FreeBSD partition gpart add -t freebsd -b 132174 `basename $1` # Creating the MBR GEOM may have cleared the # MBR bootcode in block zero so refresh it. dd if=$BL1 bs=512 count=1 of=bl1-mbr.tmp gpart bootcode -b bl1-mbr.tmp `basename $1` rm -f bl1-mbr.tmp # Format filesystems newfs_msdos -F 16 ${1}s1 newfs ${1}s2 echo "Successfully partitioned and wrote boot code to $1"