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

Re: How to create qemu-bootable image using debootstrap?



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

Following up on my previous post: I've figured out some of the steps, but I'm stuck on installing Grub. Do you know how to install grub on a raw device file?

Basically, grub-install appears to require an actual device, unlike "parted" (which was unexpectedly happy being given a simple raw file). My work-in-progress script for creating a bootable qemu image from scratch is here; can you help me finish it?

echo "Creating 1GB file of zeros in $1.raw"
dd if=/dev/zero of=$1.raw bs=1024 count=1048576

echo "Formating $1.raw with ext2 filesystem"
/sbin/parted $1.raw mklabel msdos
/sbin/parted $1.raw mkpart primary ext2 0 954
/sbin/parted $1.raw mkpart extended 954 1069
/sbin/parted $1.raw mkpart logical  linux-swap 954 1069
/sbin/parted $1.raw set 1 boot on
/sbin/parted $1.raw mkfs 1 ext2

echo "Mounting $1.raw on $1.mount"
mkdir -p $1.mount
sudo mount -o loop,offset=16384 -t ext2 $1.raw $1.mount

echo "Installing Etch into $1.mount"
sudo debootstrap --arch i386 etch $1.mount http://ftp.us.debian.org/debian

echo "Setting up host networking in $1.mount for apt"
sudo cp /etc/resolv.conf $1.mount/etc
sudo cp /etc/hosts       $1.mount/etc

echo "Installing kernel and grub into $1.mount"
sudo chroot $1.mount apt-get update
sudo chroot $1.mount apt-get -y install linux-image-2.6-486 grub
sudo grub-install --root-directory=$1.mount/root $1.raw

Basically, this last command doesn't work; it fails as follows:

david@SonOfLappy:~/test$ sudo grub-install --root-directory=blah.mount/root blah.raw
Probing devices to guess BIOS drives. This may take a long time.
Format of install_device not recognized.

Any ideas?  Thanks!

-david


Reply to: