Skip to content

Instantly share code, notes, and snippets.

@javacruft
Created September 9, 2011 08:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javacruft/1205751 to your computer and use it in GitHub Desktop.
Save javacruft/1205751 to your computer and use it in GitHub Desktop.
omap4 netboot SD card creation script
#!/bin/bash
set -e
if [ ! "$1" = "/dev/sda" ] ; then
unset LANG
DRIVE=$1
if [ -b "$DRIVE" ] ; then
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
mke2fs -j -L "rootfs" ${DRIVE}p2
fi
if [ -b "${DRIVE}p1" ] ; then
mount ${DRIVE}p1 /mnt
wget -O /mnt/MLO http://ports.ubuntu.com/ubuntu-ports/dists/oneiric/main/installer-armel/current/images/omap4/netboot/MLO
wget -O /mnt/u-boot.bin http://ports.ubuntu.com/ubuntu-ports/dists/oneiric/main/installer-armel/current/images/omap4/netboot/u-boot.bin
echo "setenv pxecfg_ram 0x88000000;setenv kernel_ram 0x80000000;setenv initrd_ram 0x81600000;pxecfg get;pxecfg boot" > /mnt/ENV.txt
umount /mnt
fi
fi
@GrueMaster
Copy link

Line 12 can be replaced with:
CYLINDERS=$(($SIZE/255/63/512))

eliminating the need for bc (and speeding the script up by a few ms).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment