-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_image.sh
More file actions
55 lines (46 loc) · 724 Bytes
/
Copy pathcreate_image.sh
File metadata and controls
55 lines (46 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
set -e
. $(dirname $0)/utils.sh
image_create() {
echo Creating $1 - size $2MB...
dd if=/dev/zero of=$1 count=$2 bs=$((1024*1024))
}
partitions_create() {
echo Creating partitions on $1... - sizes $3
if [ $2 -eq $3 ];
then
/sbin/sfdisk $1 << EOF
;
;
;
;
EOF
else
/sbin/sfdisk -uM $1 << EOF
,$3;
,,E;
;
;
,,L;
EOF
fi
}
INAME=$1
ISIZE=$2
PSIZE=$3
if [ x$PSIZE = x ];
then
PSIZE=$2
fi
image_create $INAME $ISIZE
partitions_create $INAME $ISIZE $PSIZE
format_partition $INAME 1
echo Mounting the partition...
mount_partition $INAME img1 /mnt
sudo touch /mnt/here
echo Cleaning up...
umount_partition /mnt
if [ $PSIZE -ne $ISIZE ];
then
echo Formatting 5
format_partition $INAME 5
fi