userinstall

uml-make-image

46:23d8f07c9537
2012-04-02 Paul Boddie Added a table describing the different modes of operation. Removed a somewhat irrelevant changelog note given the scale of the subsequent modifications.
     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 ] [ --do-not-populate ] <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" = '--do-not-populate' ]; then    26         shift 1    27         DO_NOT_POPULATE=$1    28 else    29         DO_NOT_POPULATE=    30 fi    31     32 if [ ! "$1" ]; then    33         echo "Need a root image size in GB." 1>&2    34         exit 1    35 fi    36     37 if [ ! "$2" ]; then    38         echo "Need a swap image size in MB." 1>&2    39         exit 1    40 fi    41     42 IMAGESIZE=$1    43 SWAPSIZE=$2    44 THISDIR=`dirname "$0"`    45     46 if [ ! -e "$PACKAGEROOT" ] && [ ! "$DO_NOT_POPULATE" ]; then    47         echo "A package root must first be made using user-setup." 1>&2    48         exit 1    49 fi    50     51 if [ ! "$IMAGEDIR" ]; then    52         echo "An image directory must be defined." 1>&2    53         exit 1    54 fi    55     56 echo "Making the filesystem with size ${IMAGESIZE}GB..."    57 dd if=/dev/zero of=$IMAGE bs=1024 count=1 seek=$(($IMAGESIZE*1024*1024-1024))    58 mkfs.ext3 $IMAGE    59     60 echo "Making the swap file with size ${SWAPSIZE}MB..."    61 dd if=/dev/zero of=$SWAPIMAGE bs=1M count=$SWAPSIZE    62     63 # Image population activities.    64     65 if [ ! "$DO_NOT_POPULATE" ]; then    66         "$AS_USER" "$THISDIR/uml-access-image" "$THISDIR/uml-populate-image"    67         "$AS_USER" "$THISDIR/uml-access-image" "$THISDIR/uml-make-network"    68 fi