kern

view mkdiskimg @ 83:4ef83db5f4cd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 15:53:57 +0200
parents
children 4dd35ccceba1
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 # create partition table
23 if ! sfdisk --version | grep linux; then
24 echo "failed to find the linux sfdisk program."
25 echo "please install it, or create a partition on the disk image ($imgfile) manually."
26 exit 0
27 fi
29 echo 'creating partition table with a single partition ...'
30 sfdisk -q $imgfile <<EOF
31 ,,cc
32 EOF
33 if [ $? != 0 ]; then
34 echo 'failed to create partition' >&2
35 exit 1
36 fi
38 echo
39 echo 'done. happy hacking!'