How to install Red Hat 7.3 into a file under QEMU as a regular user.

Rob Landley rob at landley.net
Fri Jan 20 19:45:55 UTC 2006


Shortly after the new qemu came out, I downloaded the Red Hat 7.2 iso images 
and installed them into an image file.  I have Red Hat 7.2 running in an 
800x600 window, so I can test building busybox under it.

For those of you who want to follow along at home, download qemu from:
 http://www.qemu.org/qemu-0.8.0.tar.gz
and do the standard "./configure; make; make install" dance.  (The only corner 
case is it needs SDL support in order to fake a graphics card.  You may 
already have SDL but not the gratuitously separated sdl-devel package...)

Once qemu is installed, download the Red Hat 7.3 install CDs from:
 ftp://archive.download.redhat.com/pub/redhat/linux/

Then make a blank 2 gig image file:
 dd if=/dev/zero of=valhalla.img bs=1048576 count=2048

Run qemu with the image file as hda and the install CD as hdd:
 qemu -monitor /dev/stdin -cdrom valhalla-i386-disc1.iso \
  -hda valhalla.img -boot d

Yes, the above attaches the qemu control console (monitor) to stdio in an 
extremely impolite way.  When it's done you have to type "reset" at the 
command prompt and hit enter to unconfuse the pty.  (No, it won't echo back 
what you type when you do this.)

During the install you'll need to switch to the second cd, and that's what the 
monitor is for:
 change cdrom valhalla-i386-disc2.iso

Remember to type "reset" and hit enter after qemu exits.

At this point the valhalla.img file is a partitioned hard drive image.  You 
can run "qemu valhalla.img" and RH 7.3 should come up in a window.  (You 
probably want to change the screen resolution to something smaller, or stay 
in text mode.)

What you can't do is trivially loopback mount it to get data (like the busybox 
source tarball) into and out of it.  (It's not impossible, you just have to 
use losetup by hand, feeding a calculated offset to -o.  Probably 63 sectors 
times 512 bytes per sector for the first partition.  But let's not bother 
right now).

Instead, what we do is create hdb.img (say 256 megs):
 dd if=/dev/zero of=hdb.img bs=65536 count=4096

Format it:
 mke2fs hdb.img
 tune2fs -c 0 -i 0 hdb.img

And then as root go:
 mkdir sub
 mount -o loop hdb.img sub
 cp lots_of_stuff sub
 umount sub

And then run qemu like:
 qemu -hda valhalla.img -hdb hdb.img

And in there you can:
 mount /dev/hdb somewhere

You can also set up a virtual network device so qemu can scp stuff to and from 
the host machine, but that's left as an exercise for the reader right now. 

As for testing busybox under RH 7.3, the good news is "make allnoconfig" 
builds.  Not much else right now.  I'll post a workaround next message...

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list