1d874df95d6902ad5279500925ebf36cd60eb4bb
3 # Copyright (C) 2016 Josua Mayer
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 echo "$0 <sectors> <outfile> <bootloader> [<type_partitionN> <sectors_partitionN> <img_partitionN>]?"
24 # always require first 3 arguments
25 # then in pairs up to 8 more for a total of up to 4 partitions
26 if [ $# -lt 3 ] ||
[ $# -gt 15 ] ||
[ $
(($#%3)) -ne 0 ]; then
36 BOOTLOADER
="$1"; shift
39 printf "Creating $OUTFILE from /dev/zero: "
40 dd if=/dev
/zero of
="$OUTFILE" bs
=512 count
=1 >/dev
/null
43 while [ "$#" -ge 3 ]; do
44 ptgen_args
="$ptgen_args -p $(($2 / 2)) -S 0x$1"
52 # create real partition table using fdisk
53 printf "Creating partition table: "
54 set `ptgen -o "$OUTFILE" -h $head -s $sect -l 1024 $ptgen_args`
58 printf "Writing bootloader: "
59 dd of
="$OUTFILE" if="$BOOTLOADER" bs
=512 seek
=1 conv
=notrunc
2>/dev
/null
63 while [ "$#" -ge 2 ]; do
67 printf "Writing %s to partition %i: " "$img" $i
68 dd if="$img" of
="$OUTFILE" bs
=512 seek
=$
(($1 / 512)) conv
=notrunc
2>/dev
/null