1 #!/bin/sh 2 3 # Configuration: 4 if [ -e userinstall-defaults-uml ]; then 5 . "$PWD/userinstall-defaults-uml" 6 elif [ -e /etc/default/userinstall-uml ]; then 7 . /etc/default/userinstall-uml 8 else 9 echo "No defaults found for userinstall (UML)." 1>&2 10 exit 1 11 fi 12 13 if [ "$1" = '--help' ]; then 14 echo "Usage: `basename $0` [ --root ] <root image size in GB> <swap image size in MB>" 1>&2 15 exit 1 16 fi 17 18 if [ "$1" = '--root' ]; then 19 shift 1 20 AS_USER="sudo" 21 else 22 AS_USER= 23 fi 24 25 if [ ! "$1" ]; then 26 echo "Need a root image size in GB." 1>&2 27 exit 1 28 fi 29 30 if [ ! "$2" ]; then 31 echo "Need a swap image size in MB." 1>&2 32 exit 1 33 fi 34 35 IMAGESIZE=$1 36 SWAPSIZE=$2 37 THISDIR=`dirname "$0"` 38 39 if [ ! -e "$PACKAGEROOT" ]; then 40 echo "A package root must first be made using user-setup." 1>&2 41 exit 1 42 fi 43 44 if [ ! "$IMAGEDIR" ]; then 45 echo "An image directory must be defined." 1>&2 46 exit 1 47 fi 48 49 echo "Making the filesystem with size ${IMAGESIZE}GB..." 50 dd if=/dev/zero of=$IMAGE bs=1024 count=1 seek=$(($IMAGESIZE*1024*1024-1024)) 51 mkfs.ext3 $IMAGE 52 53 echo "Making the swap file with size ${SWAPSIZE}MB..." 54 dd if=/dev/zero of=$SWAPIMAGE bs=1M count=$SWAPSIZE 55 56 # Image population activities. 57 58 "$AS_USER" "$THISDIR/uml-access-image" "$THISDIR/uml-populate-image" 59 "$AS_USER" "$THISDIR/uml-access-image" "$THISDIR/uml-make-network"