Setting QEMU Disk Geometry

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jasonc122
Member
Member
Posts: 27
Joined: Fri Jan 01, 2010 7:51 am

Setting QEMU Disk Geometry

Post by jasonc122 »

Hi,

I've got a FAT32 boot sector driver which works fine on real hardware but not on QEMU. The driver loads sectors correctly on real hardware but not when I use QEMU.

This bootsector is installed on a usb stick with a sector size of 512 bytes and a capacity of 4GB. Does QEMU use larger sector sizes for images greater than the size of a floppy? How can I get QEMU to see the usb stick as a great big floppy?

To get the usb stick to boot on real hardware I get the BIOS to boot from a USB FDD device.

I use the following commands for qemu:

qemu /dev/sdb
qemu usb.img
qemu -drive file=usb.img if=floppy index=0

TIA
H Technology Solutions - Business Operating System Specialists
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Setting QEMU Disk Geometry

Post by Brynet-Inc »

jasonc122 wrote:Hi,

I've got a FAT32 boot sector driver which works fine on real hardware but not on QEMU. The driver loads sectors correctly on real hardware but not when I use QEMU.

This bootsector is installed on a usb stick with a sector size of 512 bytes and a capacity of 4GB. Does QEMU use larger sector sizes for images greater than the size of a floppy? How can I get QEMU to see the usb stick as a great big floppy?

To get the usb stick to boot on real hardware I get the BIOS to boot from a USB FDD device.

I use the following commands for qemu:

qemu /dev/sdb
qemu usb.img
qemu -drive file=usb.img if=floppy index=0

TIA
That's ridiculous, you're telling QEMU you have a 4GB floppy disk.. which do not exist, set that to 'ide'.

On a system with USB boot capability, the BIOS/chipset does some trickery.. and pretends to be a floppy when manipulated using BIOS interrupts, but it is not actually on the floppy controller.

What you should be doing is treating the USB device as a hardrive, installing a complete MBR along with a partition record spanning the entire medium, along with a filesystem.

You can tell QEMU CHS geometry using the cyls/heads/secs arguments to -drive, or by using -hdachs in older versions.. it can automatically guess those.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
jasonc122
Member
Member
Posts: 27
Joined: Fri Jan 01, 2010 7:51 am

Re: Setting QEMU Disk Geometry

Post by jasonc122 »

Thanks.

I used the cyls/heads/secs arguments to set disk geometry and still no luck. Until such times as QEMU performs some trickery by supporting USB FDD, I'll be using the el torito format to boot my OS.

Thanks again.
H Technology Solutions - Business Operating System Specialists
Post Reply