How can I boot my bootsector files with qemu?

506 views Asked by At

I'm doing some experimenting with (very basic) OS development in order to teach myself something about machine language and x86 assembly.

I have lib-virt / qemu installed on my system. (Debian 11)

However I am struggling to find a convenient way to boot my output files.

I have assembled some assembly code using nasm bootsector.asm -f bin -o bootsector.bin.

Initially I tried running this command:

qemu bootsector.bin

however I obtained the error command not found. I believe this is because (for whatever reason, I don't know exactly) the command supplied with my package manager is actually this:

qemu-system-x86_64 bootsector.bin

however this produces this output, which is not what I would expect

WARNING: Image format was not specified for 'bootsector.bin' and probing guessed raw.
     Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
     Specify the 'raw' format explicitly to remove the restrictions.
VNC server running on ::1:5900

I would have expected a graphical window to pop up showing the output of the emulated boot process. However apparently instead a VNC server is being launched instead.

Some searching around online indicated that -display sdl or -display gtk might be required to launch the display. (However I don't recall this being required in versions of qemu from a few years back.)

Neither of these switches work, both print

Display `gtk`/`sdl` is not avaiable.

I couldn't find a solution to this. I believe qemu packages for Debian are not built with either gtk or sdl support. I don't know exactly why this is.

Therefore I tried an alternative method, which is to create a virtual machine using virt-manager and assign my bootsector as the single storage device.

This works, but only once. After launching the vm, the bootsector file is changed ownership and group to libvirt. This then prevents my makefile from over-writing it, as it is a write protected file.

At this point I am out of ideas. I assume that there must be a fair number of SO users who play around with OS development or even do it full time as a career. How do I fix the problems I have with qemu or alternatively what else can I do to speed up my development process. All I want to do is to be able to start an emulator from the command line and boot my experimental boot sectors.

1

There are 1 answers

0
hardfau18 On

try with -nographic -serial mon:stdio