1#!/bin/bash
2
3set -e
4
5if [ "$#" -ne 3 ]; then
6    echo "$0 src.img head.img tail.img" >&2
7    exit 1
8fi
9
10srcimg=$1
11headimg=$2
12tailimg=$3
13
14disksize=$(stat -c %s $srcimg)
15
16mycount=`expr $disksize \/ 1024 \/ 1024 - 1`
17
18dd if=$srcimg of=$headimg ibs=1M obs=1M count=1
19dd if=$srcimg of=$tailimg ibs=1M obs=1M count=1 skip=$mycount
20#dd if=/dev/zero of=file.txt count=3083 bs=1M
21