kern

annotate mkdiskimg @ 84:4dd35ccceba1

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Dec 2011 04:26:18 +0000
parents 4ef83db5f4cd
children 5fb7ad5967a8
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@84 22 mkpart_linux()
nuclear@84 23 {
nuclear@84 24 sfdisk -q $imgfile <<EOF
nuclear@84 25 ,,cc
nuclear@84 26 EOF
nuclear@84 27 }
nuclear@84 28
nuclear@84 29 mkpart_fbsd()
nuclear@84 30 {
nuclear@84 31 fdisk -f - $imgfile <<EOF
nuclear@84 32 p 1 204 * *
nuclear@84 33 EOF
nuclear@84 34 }
nuclear@84 35
nuclear@84 36 sys=`uname -s`
nuclear@84 37
nuclear@83 38 # create partition table
nuclear@84 39 echo 'creating partition table with a single partition ...'
nuclear@84 40 if [ $sys = Linux ]; then
nuclear@84 41 mkpart_linux
nuclear@84 42 #elif [ $sys = FreeBSD ]; then
nuclear@84 43 # mkpart_fbsd
nuclear@84 44 else
nuclear@84 45 echo "don't know how to partition the image on your system."
nuclear@84 46 echo "please create a partition in the disk image ($imgfile) manually."
nuclear@83 47 exit 0
nuclear@83 48 fi
nuclear@84 49
nuclear@83 50 if [ $? != 0 ]; then
nuclear@83 51 echo 'failed to create partition' >&2
nuclear@83 52 exit 1
nuclear@83 53 fi
nuclear@83 54
nuclear@83 55 echo
nuclear@83 56 echo 'done. happy hacking!'