kern

annotate mkdiskimg @ 83:4ef83db5f4cd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 15:53:57 +0200
parents
children 4dd35ccceba1
rev   line source
nuclear@83 1 #!/bin/sh
nuclear@83 2
nuclear@83 3 # mkdiskimg - prepare a disk image for the kernel
nuclear@83 4 # usage: mkdiskimg [size in mb, default: 40]
nuclear@83 5
nuclear@83 6 imgfile=disk.img
nuclear@83 7 if [ -e $imgfile ]; then
nuclear@83 8 echo "file '$imgfile' exists, will not overwrite, delete it first" >&2
nuclear@83 9 exit 1
nuclear@83 10 fi
nuclear@83 11
nuclear@83 12 if [ -n "$1" ]; then
nuclear@83 13 sizemb=$1
nuclear@83 14 else
nuclear@83 15 sizemb=40
nuclear@83 16 fi
nuclear@83 17
nuclear@83 18 # create the image file
nuclear@83 19 echo 'creating image file ...'
nuclear@83 20 dd if=/dev/zero of=$imgfile bs=1M count=$sizemb || exit 1
nuclear@83 21
nuclear@83 22 # create partition table
nuclear@83 23 if ! sfdisk --version | grep linux; then
nuclear@83 24 echo "failed to find the linux sfdisk program."
nuclear@83 25 echo "please install it, or create a partition on the disk image ($imgfile) manually."
nuclear@83 26 exit 0
nuclear@83 27 fi
nuclear@83 28
nuclear@83 29 echo 'creating partition table with a single partition ...'
nuclear@83 30 sfdisk -q $imgfile <<EOF
nuclear@83 31 ,,cc
nuclear@83 32 EOF
nuclear@83 33 if [ $? != 0 ]; then
nuclear@83 34 echo 'failed to create partition' >&2
nuclear@83 35 exit 1
nuclear@83 36 fi
nuclear@83 37
nuclear@83 38 echo
nuclear@83 39 echo 'done. happy hacking!'