kern

diff mkdiskimg @ 85:5fb7ad5967a8

changed mkdiskimg to make partitioning work on freebsd
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Dec 2011 06:58:05 +0000
parents 4dd35ccceba1
children
line diff
     1.1 --- a/mkdiskimg	Wed Dec 07 04:26:18 2011 +0000
     1.2 +++ b/mkdiskimg	Wed Dec 07 06:58:05 2011 +0000
     1.3 @@ -1,5 +1,10 @@
     1.4  #!/bin/sh
     1.5  
     1.6 +SUDO=${SUDO:-sudo}
     1.7 +if [ `id -u` = 0 ]; then
     1.8 +	unset SUDO
     1.9 +fi
    1.10 +
    1.11  # mkdiskimg - prepare a disk image for the kernel
    1.12  # usage: mkdiskimg [size in mb, default: 40]
    1.13  
    1.14 @@ -28,19 +33,25 @@
    1.15  
    1.16  mkpart_fbsd()
    1.17  {
    1.18 -	fdisk -f - $imgfile <<EOF
    1.19 +	devfile=`$SUDO mdconfig -a -t vnode -f $imgfile`
    1.20 +	if [ $? != 0 ]; then
    1.21 +		echo "failed to map $imgfile as a memory device, need root" >&2
    1.22 +		exit 1
    1.23 +	fi
    1.24 +
    1.25 +	$SUDO fdisk -q -f - /dev/$devfile <<EOF
    1.26  p 1 204 * *
    1.27  EOF
    1.28 +	$SUDO mdconfig -d -u $devfile
    1.29  }
    1.30  
    1.31 -sys=`uname -s`
    1.32 -
    1.33  # create partition table
    1.34  echo 'creating partition table with a single partition ...'
    1.35 +sys=`uname -s`
    1.36  if [ $sys = Linux ]; then
    1.37  	mkpart_linux
    1.38 -#elif [ $sys = FreeBSD ]; then
    1.39 -#	mkpart_fbsd
    1.40 +elif [ $sys = FreeBSD ]; then
    1.41 +	mkpart_fbsd
    1.42  else
    1.43  	echo "don't know how to partition the image on your system."
    1.44  	echo "please create a partition in the disk image ($imgfile) manually."