kern

view mkdiskimg @ 84:4dd35ccceba1

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Dec 2011 04:26:18 +0000
parents 4ef83db5f4cd
children 5fb7ad5967a8
line source
1 #!/bin/sh
3 # mkdiskimg - prepare a disk image for the kernel
4 # usage: mkdiskimg [size in mb, default: 40]
6 imgfile=disk.img
7 if [ -e $imgfile ]; then
8 echo "file '$imgfile' exists, will not overwrite, delete it first" >&2
9 exit 1
10 fi
12 if [ -n "$1" ]; then
13 sizemb=$1
14 else
15 sizemb=40
16 fi
18 # create the image file
19 echo 'creating image file ...'
20 dd if=/dev/zero of=$imgfile bs=1M count=$sizemb || exit 1
22 mkpart_linux()
23 {
24 sfdisk -q $imgfile <<EOF
25 ,,cc
26 EOF
27 }
29 mkpart_fbsd()
30 {
31 fdisk -f - $imgfile <<EOF
32 p 1 204 * *
33 EOF
34 }
36 sys=`uname -s`
38 # create partition table
39 echo 'creating partition table with a single partition ...'
40 if [ $sys = Linux ]; then
41 mkpart_linux
42 #elif [ $sys = FreeBSD ]; then
43 # mkpart_fbsd
44 else
45 echo "don't know how to partition the image on your system."
46 echo "please create a partition in the disk image ($imgfile) manually."
47 exit 0
48 fi
50 if [ $? != 0 ]; then
51 echo 'failed to create partition' >&2
52 exit 1
53 fi
55 echo
56 echo 'done. happy hacking!'