Skip to contentSkip to conversation

make_root.sh

Qemu-devel Rusty Russell 2 participants 2 messages Jul 10, 2003

lore
Share & tools
lore
#0 lore raw

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 <<EOF
# # /dev/hda1 / ext2 errors=remount-ro 0 1
proc /proc proc defaults 0 0
EOF

# Console on ttyS0, not tty1, and no other gettys.
sed 's,1:2345:respawn:/sbin/getty 38400 tty1,1:2345:respawn:/sbin/getty 38400 ttyS0,' < /tmp/mount.$$/etc/inittab | sed 's,^.:23:respawn.*,,' > /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<G1I=&EO;BUT86)L90#LT#$-"0!,&']D6AD6XP1T& M"%B@))FIMKGF(OA9C;%;EENYZO.Z3P\"````!P``__\:!0````#__QH%```` M`/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH% M`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#_ M_QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0`` M``#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:
M!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4````` M__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4` M````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__ M&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%```` M`/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH% M`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#_ M_QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0`` M``#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:
M!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4````` M__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__&@4` M````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%`````/__ M&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH%```` M`/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#__QH% M`````/__&@4`````__\:!0````#__QH%`````/__&@4`````__\:!0````#_ M_QH%`````/__&@4`````__\:!0````#__QH%`````/__0@``````__\#%&_ &<90?@``
`
end
EOF
cat $IMAGE.ext2 >> $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.

#1 lore raw

[Qemu-devel] 4GB/4GB split

Hi,

I just saw the announce of Ingo Molnar about his patch for 4GB/4GB
kernel split. This patch is mostly what I was dreaming in order to have optimal performances in QEMU : no guest kernel patches will be necessary and no software MMU will be necessary.

I hope that some of the kernel gurus reading this list will tell Ingo that his patch may be useful also for people having less than 4GB of RAM :-)

Ideally, he should add a feature to activate the 4GB/4GB on demand (if the user process maps data above 0xc0000000) and he should also be able to move dynamically the trampoline page if the user process tries to map something at its address.

Fabrice.