jump to navigation

first contact with QEMU January 12, 2007

Posted by TSAI HONG-BIN in Linux.
trackback

How do you debug your root file system? create a new partition, add a grub entry, put in files and reboot then “Oops, not working.” so the development goes into debug situation officially. It becomes an iteration of “kernel panic, reboot, modify, reboot, system hang, reboot, modify … ” and ends up with a “DAMN!” or a “Yahoo!”
So, what do we learn from the irritating but necessary debug process?

REBOOT

Is there anything we can do to simplify the process? yes, use an OS emulator. QEMU.
since I’m using fedora, I got qemu by simply execute

#yum install qemu

you may download the binary or build from the source. then create a qemu dsk

#qemu-img create qemu-disk.raw 200M

Then a kindda upset thing, fdisk cannot identify it directly since that virtual disk contains no cylinder information. So, first you have to prepare a Linux liveCD, for exampl, gentoo.

#qemu -m 512M -boot d -cdrom livecd-i686-installer-2006.0.iso qemu-disk.raw

Well, my suggestion, run qemu with a window manager, like gnome, it will ease your work. Then, use fdisk to modify its partition table and install grub.

(in gentoo-livecd)
#fdisk /dev/hda1
new a partition
write to partition table
#grub
#root (hd0,0)
#setup (hd0)
#quit

after that, quit qemu and you can put in files as desired by mounting it.

#mount -o loop,offset=32256 qemu-disk.raw qemu

amazingly, it mounts the first partition correctly. However, I have no idea how to deal with a qemu virtual disk that has more than two partitions.

Then do whatever you want to the root file system, and your debug process would become “kernel panic, quit qemu, modify, start qemu …” so fast and easy. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: