Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19aXsZ-0004ii-TM for qemu-devel@nongnu.org; Thu, 10 Jul 2003 05:38:20 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19aXsV-0004Uv-Qe for qemu-devel@nongnu.org; Thu, 10 Jul 2003 05:38:16 -0400 Received: from dp.samba.org ([66.70.73.150] helo=lists.samba.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19aXpp-0002UI-Nx for qemu-devel@nongnu.org; Thu, 10 Jul 2003 05:35:29 -0400 From: Rusty Russell Date: Thu, 10 Jul 2003 19:35:02 +1000 Sender: rusty@bach.samba.org Message-Id: <20030710093529.975872C085@lists.samba.org> Subject: [Qemu-devel] [SCRIPT] make_root.sh Reply-To: qemu-devel@nongnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org OK, Debian fans! Here's my script to make a Debian qemu root image, for use as -hda. You will need debootstrap, sharutils and sfdisk installed, and to run this as root. It takes at least 90MB to fit the base Debian, unfortunately. Also, my script is naive and needs twice the size of the image temporarily. Example use: $ sudo ./make_root.sh 200 sid http://proxy:10000/debian qemu .... $ ./vl -snapshot -hda qemu bzImage root=/dev/hda1 ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe Feedback and patches welcome! Rusty. -- Anyone who quotes me in their sig is an idiot. -- Rusty Russell. #! /bin/sh -e # Script to make a debian root image. if [ $# -ne 4 ]; then echo Usage: "%s size-in-MB distrib deburl image" >&2 echo "eg %s 150 sid http://proxy:10000/debian qemu" >&2 exit 1 fi SIZE=$1 DISTRO=$2 URL=$3 IMAGE=$4 if [ $SIZE -lt 110 ]; then echo 'Size must be at least 110 megabytes (Debian takes 90)' >&2 exit 1 fi cleanup() { echo Cleaning up... >&2 umount /tmp/mount.$$ || true rm -f $IMAGE.ext2 $IMAGE } trap cleanup EXIT HEADS=16 SECTORS=63 # 512 bytes in a sector: cancel the 512 with one of the 1024s... CYLINDERS=$(( $SIZE * 1024 * 2 / ($HEADS * $SECTORS) )) # Create a filesystem: one track for partition table. dd bs=$(($SECTORS * 512)) if=/dev/zero of=$IMAGE.ext2 count=$(($CYLINDERS * $HEADS - 1)) mke2fs -q -m1 -F $IMAGE.ext2 # Mount it. mkdir /tmp/mount.$$ mount -o loop $IMAGE.ext2 /tmp/mount.$$ # Do debian install on it. debootstrap --exclude=syslinux,at,exim,mailx,libstdc++2.10-glibc2.2,mbr,setserial,fdutils,info,ipchains,lilo,pcmcia-cs,ppp,pppoe,pppoeconf,pppconfig $DISTRO /tmp/mount.$$ $URL # Final configuration. cat > /tmp/mount.$$/etc/fstab < /tmp/mount.$$/etc/inittab.new mv /tmp/mount.$$/etc/inittab.new /tmp/mount.$$/etc/inittab # Set hostname to base of image name. basename $IMAGE > /tmp/mount.$$/etc/hostname # Remove ones we can remove. chroot /tmp/mount.$$ /usr/bin/dpkg --remove console-tools console-data base-config umount /tmp/mount.$$ # Create file with partition table. uudecode -o- << "EOF" | gunzip > $IMAGE begin 664 partition-table.gz M'XL("*_<##\"`W!A> $IMAGE rm $IMAGE.ext2 # Repartition so one partition covers entire disk. echo '63,' | sfdisk -uS -H$HEADS -S$SECTORS -C$CYLINDERS $IMAGE trap "" EXIT echo Done.