http://www.coreboot.org/QEMU_Build_Tutorial
My test versions: coreboot v2- revision 3275 filo - v0.5- revision 45 qemu- v0.9.1
I followed steps described in that wiki page, and I got: "
1 init_drive: Probing for hda 2 init_drive: LBA mode, sectors=409600 3 init_drive: LBA48 mode, sectors=409600 4 init_drive: Init device params... ok 5 hda: LBA48 209MB: QEMU HARDDISK 6 init_controller: MASTER CHECK: master yes 7 init_controller: /*slave */ -- drive is 0 8 open_pc_partition: pc partition magic number not found
" Have I missed anything? Seems 'qemu-create img' not produce the correct image? here is my xxd result:
$ head disk.img | xxd | vi -
" 1 0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 2 0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 3 0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 4 0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 5 0000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 6 0000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 7 0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 8 0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 9 0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 10 0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 11 00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 12 00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 13 00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 14 00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 15 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 16 00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 17 0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 18 0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 19 0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 20 0000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 21 0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 22 0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 23 0000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 24 0000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 25 0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 26 0000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 27 00001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 28 00001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 29 00001c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 30 00001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ <SNIP> "
http://www.coreboot.org/QEMU_Build_Tutorial
My test versions: coreboot v2- revision 3275 filo - v0.5- revision 45 qemu- v0.9.1
I followed steps described in that wiki page, and I got: "
1 init_drive: Probing for hda 2 init_drive: LBA mode, sectors=409600 3 init_drive: LBA48 mode, sectors=409600 4 init_drive: Init device params... ok 5 hda: LBA48 209MB: QEMU HARDDISK 6 init_controller: MASTER CHECK: master yes 7 init_controller: /*slave */ -- drive is 0 8 open_pc_partition: pc partition magic number not found
" Have I missed anything? Seems 'qemu-create img' not produce the correct image? here is my xxd result:
$ head disk.img | xxd | vi -
" 1 0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 2 0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
I don't know how this tutorial is supposed to work. Disk.img is supposed to be the whole hard drive, and you're treating it like a partition with mkfs.ext2. Here is something that should work:
1. Create the raw image like it says in the tutorial 2. Boot QEMU with a rescue disk from your favorite OS 3. Run fdisk and create a single partition on the drive that takes up the whole drive 4. Quit and write the partition to disk 5. Run mkfs.ext2fs on that partition 6. Exit QEMU
You now have a partitioned disk with an ext2 fs. You could have put in a second partition for swap while you were there, but lets keep this simple.
Now you have a hard drive image with a partition and you need to mount that partition to copy the files you want.
Use
mount -o loop,skip=32256 disk.img /mnt/rootfs
(Thanks to http://wiki.archlinux.org/index.php/Qemu)
and continue the tutorial.
To restate: The problem is that when you run mkfs.ext2 on the disk.img, you're formatting it as if it were a partition, not a drive, and you don't have a valid partition table.
There are many other ways to get this done, I think this is the easiest. If you can't get it to work you might also try:
1. Stealing the first 32256 bytes (63 * 512B sectors) from a known good image of the same size and concatenating it to the front of a partition like you made in the tutorial (- 63 sectors)
Hope that helps,
Myles
PS The page I referenced above has other advanced tips too.
On Fri, May 2, 2008 at 11:12 PM, Myles Watson mylesgw@gmail.com wrote:
I don't know how this tutorial is supposed to work. Disk.img is supposed to be the whole hard drive, and you're treating it like a partition with mkfs.ext2. Here is something that should work:
- Create the raw image like it says in the tutorial
- Boot QEMU with a rescue disk from your favorite OS
- Run fdisk and create a single partition on the drive that takes up the
whole drive 4. Quit and write the partition to disk 5. Run mkfs.ext2fs on that partition 6. Exit QEMU
You now have a partitioned disk with an ext2 fs. You could have put in a second partition for swap while you were there, but lets keep this simple.
Now you have a hard drive image with a partition and you need to mount that partition to copy the files you want.
Use
mount -o loop,skip=32256 disk.img /mnt/rootfs
(Thanks to http://wiki.archlinux.org/index.php/Qemu)
and continue the tutorial.
To restate: The problem is that when you run mkfs.ext2 on the disk.img, you're formatting it as if it were a partition, not a drive, and you don't have a valid partition table.
There are many other ways to get this done, I think this is the easiest. If you can't get it to work you might also try:
- Stealing the first 32256 bytes (63 * 512B sectors) from a known good
image of the same size and concatenating it to the front of a partition like you made in the tutorial (- 63 sectors)
Hope that helps,
Thanks, Myles. This wiki maybe need update, :) I supposed that wiki page to be the official coreboot guide. I just installed debian-4.0r2 using qemu-0.9.1(and bochs pc-bios), it works fine.
Another try will be taken for coreboot tomorrow, I would like to write a new doc about "QEMU Build Tutorial".
PS The page I referenced above has other advanced tips too.
Nice page, thanks!
Thanks, Myles. This wiki maybe need update, :) I supposed that wiki page to be the official coreboot guide. I just installed debian-4.0r2 using qemu-0.9.1(and bochs pc-bios), it works fine.
I'm glad something is working for you. It's easy for tutorials to get out of date.
Another try will be taken for coreboot tomorrow, I would like to write a new doc about "QEMU Build Tutorial".
Your contributions are welcome!
Thanks, Myles
On Sat, May 3, 2008 at 12:29 AM, Myles Watson mylesgw@gmail.com wrote:
Your contributions are welcome!
"You must have cookies enabled to log in to coreboot. If you don't have an account and wish to contribute contact Stefan Reinauer or Ronald Minnich. NOTE: You don't need an account to read the information on this site. So don't ask for an account unless you have something to contribute."
Here is a instruction with ugly format, hope I have not miss important things.
==START== My test env: debian etch with kernel 2.6.25.
src prepare: coreboot v2 - svn://coreboot.org/repos/trunk/coreboot-v2 qemu-0.9.1.tar.gz/kqemu - http://fabrice.bellard.free.fr/qemu/ filo-0.5 - svn co svn://coreboot.org/filo/trunk/filo-0.5 linux src - http://www.kernel.org linux rescue cd. - for partitions.
build tools: qemu: New linux distributions use gcc4.x as default, but qemu needs gcc-3.x, so maybe you need to install gcc3.4 (for debian users, 'sudo apt-get install gcc-3.4') $ cd qemu-0.9.1 $ ./configure --cc=gcc-3.4 --target-list=i386-softmmu && make $ sudo make install
Ok, qemu is done. you can use "qemu -h" for more helps. Let us create a qemu hard disk image first. BTW, kqemu will bring you better performance, please google for installing.
$ qemu-img create -f raw test.img 200M Use your favourite rescue CD to do partion issues.(I choose rhel here because both Debian etch/lenny CDs could not enter the rescue mode in qemu-0.9.1.:<. anyone who knows the reason please tell me, thanks. ) $ qemu -cdrom ~/iso/rhel5_rescue.iso -boot d -hda test.img -L ~/work/qemu-0.9.1/pc-bios/ -m 512 Run fdisk and create a single partition on the drive that takes up the whole drive Quit and write the partition to disk Run mkfs.ext2fs on that partition Exit QEMU
Allright, we start to build rootfs for qemu image. $ sudo mount -o loop,offset=32256 test.img /mnt/rootfs
Create a boot directory and copy your Linux kernel (vmlinuz) and initramfs (initrd) to it:
$ sudo mkdir /mnt/rootfs/boot $ sudo mkdir /mnt/rootfs/boot/filo $ sudo cp vmlinuz /mnt/rootfs/boot/vmlinuz $ sudo cp initrd /mnt/rootfs/boot/initrd $ sudo vi /mnt/rootfs/boot/filo/menu.lst # For booting GNU/Linux title GNU/Linux root (hd0,0) kernel /boot/vmlinuz root=/dev/hda1 initrd /boot/initrd
# Add other files as you wish. $ sudo cp -R /* /mnt/rootfs
Alternatively, with Debian you can use the debootstrap command to create a basic root filesystem: $ sudo debootstrap --arch i386 etch /mnt/rootfs http://ftp.debian.org/debian/
If you are using a debootstrap filesystem, open the file /mnt/rootfs/etc/inittab and change runlevel to level 1: id:1:initdefault:
cd out of /mnt/rootfs and umount it: $ sudo umount /mnt/rootfs
filo: $ cd filo-0.5 First invocation of make creates the default Config file. $ make Edit this file as you like. vi Config change MENULST_FILE to "hda1:/boot/filo/menu.lst", since we only have one single partition. change AUTOBOOT_FILE to "hda1:/boot/vmlinuz root=/dev/hda1 console=ttyS0,115200"
Run make again to create filo.elf, the ELF FILO image. $ make
coreboot: change payload to path/to/filo.elf $ vi coreboot-v2/targets/emulation/qemu-x86/Config.lb
$ cd coreboot-v2/targets $ ./buildtarget emulation/qemu-x86 $ cd emulation/qemu-x86/qemu-x86/ $ sudo make Here we got coreboot.rom which use filo as bootloader.
$ cp coreboot.rom ~/bios.bin $ cp $path/to/qemu-0.9.1/pc-bios/vgabios-cirrus.bin ~/
Here we go! Boot test.img using coreboot. $ qemu -L ~ -hda test.img
==END==
On Sat, May 3, 2008 at 12:29 AM, Myles Watson mylesgw@gmail.com wrote:
Your contributions are welcome!
"You must have cookies enabled to log in to coreboot. If you don't have an account and wish to contribute contact Stefan Reinauer or Ronald Minnich. NOTE: You don't need an account to read the information on this site. So don't ask for an account unless you have something to contribute."
I'll put it up on the Wiki if you'd like, but I since you "have something to contribute", you could also ask for an account.
Did you get this all to work like you wanted?
Thanks,
Myles
Here is a instruction with ugly format, hope I have not miss important things.
==START== My test env: debian etch with kernel 2.6.25.
src prepare: coreboot v2 - svn://coreboot.org/repos/trunk/coreboot-v2 qemu-0.9.1.tar.gz/kqemu - http://fabrice.bellard.free.fr/qemu/ filo-0.5 - svn co svn://coreboot.org/filo/trunk/filo-0.5 linux src - http://www.kernel.org linux rescue cd. - for partitions.
build tools: qemu: New linux distributions use gcc4.x as default, but qemu needs gcc-3.x, so maybe you need to install gcc3.4 (for debian users, 'sudo apt-get install gcc-3.4') $ cd qemu-0.9.1 $ ./configure --cc=gcc-3.4 --target-list=i386-softmmu && make $ sudo make install
Ok, qemu is done. you can use "qemu -h" for more helps. Let us
create a qemu hard disk image first. BTW, kqemu will bring you better performance, please google for installing.
$ qemu-img create -f raw test.img 200M Use your favourite rescue CD to do partion issues.(I choose
rhel here because both Debian etch/lenny CDs could not enter the rescue mode in qemu-0.9.1.:<. anyone who knows the reason please tell me, thanks. ) $ qemu -cdrom ~/iso/rhel5_rescue.iso -boot d -hda test.img -L ~/work/qemu-0.9.1/pc-bios/ -m 512 Run fdisk and create a single partition on the drive that takes up the whole drive Quit and write the partition to disk Run mkfs.ext2fs on that partition Exit QEMU
Allright, we start to build rootfs for qemu image. $ sudo mount -o loop,offset=32256 test.img /mnt/rootfs Create a boot directory and copy your Linux kernel (vmlinuz)
and initramfs (initrd) to it:
$ sudo mkdir /mnt/rootfs/boot $ sudo mkdir /mnt/rootfs/boot/filo $ sudo cp vmlinuz /mnt/rootfs/boot/vmlinuz $ sudo cp initrd /mnt/rootfs/boot/initrd $ sudo vi /mnt/rootfs/boot/filo/menu.lst # For booting GNU/Linux title GNU/Linux root (hd0,0) kernel /boot/vmlinuz root=/dev/hda1 initrd /boot/initrd # Add other files as you wish. $ sudo cp -R /* /mnt/rootfs Alternatively, with Debian you can use the debootstrap command
to create a basic root filesystem: $ sudo debootstrap --arch i386 etch /mnt/rootfs http://ftp.debian.org/debian/
If you are using a debootstrap filesystem, open the file
/mnt/rootfs/etc/inittab and change runlevel to level 1: id:1:initdefault:
cd out of /mnt/rootfs and umount it: $ sudo umount /mnt/rootfs
filo: $ cd filo-0.5 First invocation of make creates the default Config file. $ make Edit this file as you like. vi Config change MENULST_FILE to "hda1:/boot/filo/menu.lst", since we only have one single partition. change AUTOBOOT_FILE to "hda1:/boot/vmlinuz root=/dev/hda1 console=ttyS0,115200"
Run make again to create filo.elf, the ELF FILO image. $ make
coreboot: change payload to path/to/filo.elf $ vi coreboot-v2/targets/emulation/qemu-x86/Config.lb
$ cd coreboot-v2/targets $ ./buildtarget emulation/qemu-x86 $ cd emulation/qemu-x86/qemu-x86/ $ sudo make Here we got coreboot.rom which use filo as bootloader. $ cp coreboot.rom ~/bios.bin $ cp $path/to/qemu-0.9.1/pc-bios/vgabios-cirrus.bin ~/
Here we go! Boot test.img using coreboot. $ qemu -L ~ -hda test.img
==END==
-- FIXME if it is wrong.
On Wed, May 7, 2008 at 12:07 AM, Myles Watson mylesgw@gmail.com wrote:
I'll put it up on the Wiki if you'd like, but I since you "have something to contribute", you could also ask for an account.
Thanks, Myles. I will ask the maintainer for the account. :)
Did you get this all to work like you wanted?
Yes, this guide is exactly what I want. but there still has few troubles, for example: 'Enter, b, e' and other bash-like edit commands not works in filo.(I thought it might be my config err or filo's bug on keyboard event handling, I could use 'a' to boot the vmlinuz...), I have not read the code yet.
Thanks,
Myles