How do you develop an operating system with VirtualBox?

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
slammar
Posts: 24
Joined: Fri Feb 07, 2020 7:35 pm
Libera.chat IRC: slammar

How do you develop an operating system with VirtualBox?

Post by slammar »

How do you develop an operating system with VirtualBox?

Without GRUB and all that stuff. Basically execute the basic example at https://wiki.osdev.org/Babystep1.
nlg
Member
Member
Posts: 41
Joined: Mon Mar 14, 2016 5:34 am

Re: How do you develop an operating system with VirtualBox?

Post by nlg »

first i use a floppy image whit basic functionality installed to test the kernel on a very simple VM, like your exemple but improved https://github.com/N-LG/SEAC/blob/master/disquette.ASM
and finaly i upgrade (over the network with a tftp server) an other VM who have an old version of my kernel to test full functionality
Octocontrabass
Member
Member
Posts: 5885
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do you develop an operating system with VirtualBox?

Post by Octocontrabass »

Instead of attaching the floppy disk image to the emulated floppy disk drive in QEMU, attach the floppy disk image to the emulated floppy disk drive in VirtualBox.

That example you're following is more of a bootloader than an operating system. Are you sure you want to write a bootloader? It's a lot of work, and that means less time to write your operating system.
slammar
Posts: 24
Joined: Fri Feb 07, 2020 7:35 pm
Libera.chat IRC: slammar

Re: How do you develop an operating system with VirtualBox?

Post by slammar »

I am getting this error:
Image

Code: Select all

Failed to open the disk image file C:\Users\Adrian\Desktop\kernel.bin.

Could not get the storage format of the medium 'C:\Users\Adrian\Desktop\kernel.bin' (VERR_NOT_SUPPORTED).

Result Code: VBOX_E_IPRT_ERROR (0x80BB0005)
Component: MediumWrap
Interface: IMedium {ad47ad09-787b-44ab-b343-a082a3f2dfb1}
Callee: IVirtualBox {d0a0163f-e254-4e5b-a1f2-011cf991c38d}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

These are the exact steps I followed:

1. Copied and pasted the bootloader into a kernel.asm file:

Code: Select all

     cli
 hang:
     jmp hang
 
     times 510-($-$$) db 0
     db 0x55
     db 0xAA
2. Compiled the bootloader with nasm:

Code: Select all

nasm kernel.asm -f bin -o kernel.bin
3. Added a floppy controller in VirtualBox
4. Selected the floppy drive selecting kernel.bin
nlg
Member
Member
Posts: 41
Joined: Mon Mar 14, 2016 5:34 am

Re: How do you develop an operating system with VirtualBox?

Post by nlg »

i think virtualbox want a floppy image of 1474560 byte
so try to add "times 1474048 db 0" to your code
slammar
Posts: 24
Joined: Fri Feb 07, 2020 7:35 pm
Libera.chat IRC: slammar

Re: How do you develop an operating system with VirtualBox?

Post by slammar »

nlg wrote:i think virtualbox want a floppy image of 1474560 byte
so try to add "times 1474048 db 0" to your code
I don't know where you got this number from, but it doesn't work anyways. The same thing keeps happening.
Octocontrabass
Member
Member
Posts: 5885
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do you develop an operating system with VirtualBox?

Post by Octocontrabass »

VirtualBox does not recognize the file extension. Try changing the file extension to "img", "ima", "dsk", "flp", or "vfd" for your floppy disk image.
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: How do you develop an operating system with VirtualBox?

Post by klange »

I highly recommend building ISOs, possibly with GRUB's mkrescue tool, for testing across a wide variety of emulators with ease. VirtualBox will have no trouble with that.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: How do you develop an operating system with VirtualBox?

Post by Octacone »

It is almost 2021 and people still ask questions about floppy images. WTF?
Just use an ISO or make a virtual HDD (that I what I do for my OS).
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: How do you develop an operating system with VirtualBox?

Post by bzt »

I think klange and Octacone is right. I'm asking the moderators and old members: what do you think, is it time to remove floppy instructions from the wiki? Or at least move all of it to an "outdated" category? I guess the wiki should talk about LBA addressing and have USB-compatible boot tutorials. Opinions?

Cheers,
bzt
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: How do you develop an operating system with VirtualBox?

Post by klange »

bzt wrote:I think klange and Octacone is right. I'm asking the moderators and old members: what do you think, is it time to remove floppy instructions from the wiki? Or at least move all of it to an "outdated" category? I guess the wiki should talk about LBA addressing and have USB-compatible boot tutorials. Opinions?
I don't think any article should ever be removed for being about an outdated tech, but there's definitely an argument to be made about steering people away from targeting such outmoded things.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: How do you develop an operating system with VirtualBox?

Post by bzt »

klange wrote:I don't think any article should ever be removed for being about an outdated tech, but there's definitely an argument to be made about steering people away from targeting such outmoded things.
I agree, "outdated" category is better.

I've checked the wiki, and the thing is, there's not much floppy-related stuff actually.
Bootloader in section Loading your kernel could mention BIOS LBA packets, but that's all.
Rolling your own bootloader mentions hard drive, it might use an example code though.
Boot sequence has a section on hard disks and MBR.
File systems talks about floppies, but about disks as well.
Disk images talks about floppies, but also about hard disks.
Loopback device likewise, there's an entire section on hard disk images too.
Bare bones tutorials use GRUB Multiboot.
Real mode assembly series does not load sectors at all.
Babystep1 does mention floppy, but there's nothing in the code that shouldn't work on HDD. Maybe a "qemu -hda" example would be useful.

Did I miss something? It looks like our wiki does not suggest floppies (except for GRUB mkrescue which indeed requires a floppy image so that's fine).

Cheers,
bzt
slammar
Posts: 24
Joined: Fri Feb 07, 2020 7:35 pm
Libera.chat IRC: slammar

Re: How do you develop an operating system with VirtualBox?

Post by slammar »

Octocontrabass wrote:VirtualBox does not recognize the file extension. Try changing the file extension to "img", "ima", "dsk", "flp", or "vfd" for your floppy disk image.
This solved my problem, thanks.
Octacone wrote:It is almost 2021 and people still ask questions about floppy images. WTF?
Just use an ISO or make a virtual HDD (that I what I do for my OS).
Like most people here, I am not developing an OS for need, but for fun and because I want to understand how computers work. I do know that OS developing would be much easier using GRUB instead of floppy images, but with floppy images you can develop your own boot sector whereas in the other hand with GRUB you don't have control over it since you have the job done for yourself. This way I can understand much better how things work (and why is it such a bad idea to develop a bootsector yourself instead of relying on GRUB :wink: ).
User avatar
BenLunt
Member
Member
Posts: 970
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: How do you develop an operating system with VirtualBox?

Post by BenLunt »

bzt wrote:I agree, "outdated" category is better.
I also agree. I thoroughly enjoyed programming the FDC, using quirks to find the different types of FDCs available. Yes, the FDC is outdated, but I believe it is a great learning experience to program the FDC. Learn how to communicate with the hardware, learn the different quirks, learn how to use polling or DMA, all in all, a great learning experience.

Probably will never use it again, nor ever need to. However, it was an enjoyable thing to do and a good learning experience, not only to learn about the FDC but to help with my hardware programming experience. I would recommend it to anyone.

My opinion would be the same as already said, do not remove outdated information, but do encourage those wanting to target newer hardware to not worry about this outdated information.

Ben
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: How do you develop an operating system with VirtualBox?

Post by bzt »

@BenLunt: thanks for sharing your opinion! I'm glad we all agree.
slammar wrote:with floppy images you can develop your own boot sector whereas in the other hand with GRUB you don't
Actually, you can also develop your boot sector for disks too. The only difference is, you'll have to use a different BIOS routine to read the disk (int 13h, ah=0x42, using LBA packets, you can forget about CHS addressing), but that's it. You can find many examples on the wiki, BootProg, Gujin, BOOTBOOT's stage1, etc. Neither of these use GRUB :-)

Cheers,
bzt
Post Reply