diff options
author | Samuli Piippo <samuli.piippo@digia.com> | 2013-04-28 19:23:50 +0300 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@digia.com> | 2013-04-30 08:48:37 +0300 |
commit | 417c2a114832be80ea122de8a2cc6c8c606ff74f (patch) | |
tree | b0652cdfa7af3b5a96696299d8c7bf2d7f5048d8 /recipes/mkcard/files/mkcard.sh | |
parent | b56a5fd406130a851ac6b443f4e43523cc2573f4 (diff) | |
download | meta-boot2qt-417c2a114832be80ea122de8a2cc6c8c606ff74f.tar.gz |
mkcard: script to initialize memory card
The mkcard.sh script can be used to initialize memory card,
so that rootfs and boot files can be copied to it.
Creates two partitions, fat and ext3, named boot and rootfs
respectively.
Change-Id: I62846802845f1715cde2c2fbb98e57f604b96878
Reviewed-by: Kalle Viironen <kalle.viironen@digia.com>
Diffstat (limited to 'recipes/mkcard/files/mkcard.sh')
-rwxr-xr-x | recipes/mkcard/files/mkcard.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/recipes/mkcard/files/mkcard.sh b/recipes/mkcard/files/mkcard.sh new file mode 100755 index 0000000..3e70dbc --- /dev/null +++ b/recipes/mkcard/files/mkcard.sh | |||
@@ -0,0 +1,78 @@ | |||
1 | #! /bin/sh | ||
2 | # mkcard.sh v0.5 | ||
3 | # (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk> | ||
4 | # Licensed under terms of GPLv2 | ||
5 | # | ||
6 | # Parts of the procudure base on the work of Denys Dmytriyenko | ||
7 | # http://wiki.omap.com/index.php/MMC_Boot_Format | ||
8 | |||
9 | export LC_ALL=C | ||
10 | |||
11 | if [ $# -ne 1 ]; then | ||
12 | echo "Usage: $0 <drive>" | ||
13 | exit 1; | ||
14 | fi | ||
15 | |||
16 | DRIVE=$1 | ||
17 | |||
18 | dd if=/dev/zero of=$DRIVE bs=1024 count=1024 | ||
19 | |||
20 | SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'` | ||
21 | |||
22 | echo DISK SIZE - $SIZE bytes | ||
23 | |||
24 | CYLINDERS=`echo $SIZE/255/63/512 | bc` | ||
25 | |||
26 | echo CYLINDERS - $CYLINDERS | ||
27 | |||
28 | { | ||
29 | echo ,9,0x0C,* | ||
30 | echo ,,,- | ||
31 | } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE | ||
32 | |||
33 | sleep 1 | ||
34 | |||
35 | |||
36 | if [ -x `which kpartx` ]; then | ||
37 | kpartx -a ${DRIVE} | ||
38 | fi | ||
39 | |||
40 | # handle various device names. | ||
41 | # note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1 | ||
42 | # won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572 | ||
43 | |||
44 | PARTITION1=${DRIVE}1 | ||
45 | if [ ! -b ${PARTITION1} ]; then | ||
46 | PARTITION1=${DRIVE}p1 | ||
47 | fi | ||
48 | |||
49 | DRIVE_NAME=`basename $DRIVE` | ||
50 | DEV_DIR=`dirname $DRIVE` | ||
51 | |||
52 | if [ ! -b ${PARTITION1} ]; then | ||
53 | PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1 | ||
54 | fi | ||
55 | |||
56 | PARTITION2=${DRIVE}2 | ||
57 | if [ ! -b ${PARTITION2} ]; then | ||
58 | PARTITION2=${DRIVE}p2 | ||
59 | fi | ||
60 | if [ ! -b ${PARTITION2} ]; then | ||
61 | PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2 | ||
62 | fi | ||
63 | |||
64 | |||
65 | # now make partitions. | ||
66 | if [ -b ${PARTITION1} ]; then | ||
67 | umount ${PARTITION1} | ||
68 | mkfs.vfat -F 32 -n "boot" ${PARTITION1} | ||
69 | else | ||
70 | echo "Cant find boot partition in /dev" | ||
71 | fi | ||
72 | |||
73 | if [ -b ${PARITION2} ]; then | ||
74 | umount ${PARTITION2} | ||
75 | mke2fs -t ext3 -j -L "rootfs" ${PARTITION2} | ||
76 | else | ||
77 | echo "Cant find rootfs partition in /dev" | ||
78 | fi | ||