contrib/angstrom/omap3-mkcard.sh : add script for formatting cards for omap3
[openembedded.git] / contrib / angstrom / omap3-mkcard.sh
1 #! /bin/sh
2 # mkcard.sh v0.4
3 # (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
4 # Licensed under terms of GPLv2
5
6 LC_ALL=C
7
8 if [ $# -ne 1 ]; then
9         echo "Usage: $0 <drive>"
10         exit 1;
11 fi
12
13 DRIVE=$1
14
15 dd if=/dev/zero of=$DRIVE bs=1024 count=1024
16
17 SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
18
19 echo DISK SIZE - $SIZE bytes
20
21 CYLINDERS=`echo $SIZE/255/63/512 | bc`
22
23 echo CYLINDERS - $CYLINDERS
24
25 {
26 echo ,9,0x0C,*
27 echo ,,,-
28 } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
29
30 if [ -b ${DRIVE}1 ]; then
31         mkfs.vfat -F 32 -n "boot" ${DRIVE}1
32 else
33         if [ -b ${DRIVE}p1 ]; then
34                 mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
35         else
36                 echo "Cant find boot partition in /dev"
37         fi
38 fi
39
40 if [ -b ${DRIVE}2 ]; then
41         mke2fs -j -L "rootfs" ${DRIVE}2
42 else
43         if [ -b ${DRIVE}p2 ]; then
44                 mke2fs -j -L "rootfs" ${DRIVE}p2
45         else
46                 echo "Cant find rootfs partition in /dev"
47         fi
48 fi
49