[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to create qemu-bootable image using debootstrap?



What's the best way to create a raw disk image using debootstrap that can be booted with qemu?

I think I've almost figured it out, but I'm not savvy with the low-level file commands. Can you point me in the right direction?

I'm hacking together a few sources -- most notably http://www.debian.org/releases/stable/i386/apds03.html.en -- but I'm missing a couple steps. This is what I think I've got so far:

#-------------- 1. Create the raw image ------------
# Create 1GB raw image
dd if=/dev/zero of=image.raw bs=1024 count=1048576

# Format it with ext3 file system
??? how to do this ???
??? can I do it all with a single partition ???

# Mount it
mkdir -p image.mount
sudo mount -o loop,offset=32256 image.raw image.mount

#-------------- 2. Configure a chroot --------------
# Debootstrap it
/usr/sbin/debootstrap --arch i386 etch image.mount \
	http://ftp.us.debian.org/debian

# Create /etc/fstab as follows:
??? what goes in here ???

# Mount the file system inside the chroot
sudo chroot image.mount mount -a


# ---------- 3. Enable networking ----------------
# Though it'll ultimately be a qemu image, we need
# to temporarily use the host's network interface
# in order to get apt working.
sudo cp /etc/resolv.conf image.mount/etc
sudo cp /etc/hosts       image.mount/etc


#----------- 4. Make it bootable -----------------
# First install the kernel
sudo chroot image.mount apt-get update
sudo chroot image.mount apt-get install \
	linux-image-2.6.24-17-generic

# Then install grub
sudo chroot image.mount apt-get install grub
sudo chroot image.mount apt-get grub-install /dev/????
sudo chroot image.mount apt-get update-grub


# ----------- 5. Done, boot it up! ------------
sudo qemu -kernel-kqemu image.raw


Granted, at this point its networking will be screwed up, but that's a task for another day. I'm just trying to get it to boot. With this in mind, can you fill in any of the blanks in the above script? Thanks!

-david


Reply to: