kern

diff mkdiskimg @ 83:4ef83db5f4cd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 15:53:57 +0200
parents
children 4dd35ccceba1
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mkdiskimg	Tue Dec 06 15:53:57 2011 +0200
     1.3 @@ -0,0 +1,39 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +# mkdiskimg - prepare a disk image for the kernel
     1.7 +# usage: mkdiskimg [size in mb, default: 40]
     1.8 +
     1.9 +imgfile=disk.img
    1.10 +if [ -e $imgfile ]; then
    1.11 +	echo "file '$imgfile' exists, will not overwrite, delete it first" >&2
    1.12 +	exit 1
    1.13 +fi
    1.14 +
    1.15 +if [ -n "$1" ]; then
    1.16 +	sizemb=$1
    1.17 +else
    1.18 +	sizemb=40
    1.19 +fi
    1.20 +
    1.21 +# create the image file
    1.22 +echo 'creating image file ...'
    1.23 +dd if=/dev/zero of=$imgfile bs=1M count=$sizemb || exit 1
    1.24 +
    1.25 +# create partition table
    1.26 +if ! sfdisk --version | grep linux; then
    1.27 +	echo "failed to find the linux sfdisk program."
    1.28 +	echo "please install it, or create a partition on the disk image ($imgfile) manually."
    1.29 +	exit 0
    1.30 +fi
    1.31 +
    1.32 +echo 'creating partition table with a single partition ...'
    1.33 +sfdisk -q $imgfile <<EOF
    1.34 +,,cc
    1.35 +EOF
    1.36 +if [ $? != 0 ]; then
    1.37 +	echo 'failed to create partition' >&2
    1.38 +	exit 1
    1.39 +fi
    1.40 +
    1.41 +echo
    1.42 +echo 'done. happy hacking!'