-1

I've tried to write a simple kernel in C. I've found this tutorial: Bare Bones. I've followed the steps. When I compiled the "o" files to one "bin" file, I tried to run this in VirtualBox. I've changed "bin" extension to "img". I've created a new virtual machine and when I tried to set "img" file as floppy image, I get an error:

A floppy fájl megnyitása sikertelen: path_of_file. (Eng.: failed to load floppy image.)

Could not get the storage format of the medium 'path_of_file' (VERR_NOT_SUPPORTED).

Eredmény kód: VBOX_E_IPRT_ERROR (0x80BB0005) (Eng.: Result code.)

Komponens: Medium (Eng.: Component.)

Interfész: IMedium {05f2bbb6-a3a6-4fb9-9b49-6d0dda7142ac} (Eng.: Interface.)

Callee: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}

Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

I will be very happy, if someone can tell me what is the problem and how I can fix it. I've searched for the solution all over the internet, but I didn't find it yet. Software what I used:

  • NASM 2.11.06
  • i686-elf-gcc 4.8.2 (from OSDev forum)
  • VirtualBox 4.3.20

My OS is Windows 7 Professional 64-bit.

(Sorry for my english, but I've been learning this language yet.)

Thanks.

uno20001
  • 211
  • 1
  • 5

1 Answers1

0

One option is to use QEMU from http://qemu.weilnetz.de/. Set your PATH variable to the QEMU binary directory (inside your QEMU installation directory). Open a command prompt to where kernel.bin is saved, and type in:

qemu-system-i386 -kernel kernel.bin

Otherwise, you need to use an existing bootloader (preferrably GRUB2) to create a bootable ISO disk. Right now, all you have is a binary file which has your kernel code in it.

1) Make a file called grub.cfg with the following contents:

menuentry "my os" {
    multiboot /boot/kernel.bin
    boot
}

2) Run the following commands in a terminal:

mkdir isodir
mkdir isodir/boot
mkdir isodir/boot/grub

3) Save the grub.cfg file in the isodir/boot/grub directory.

4) Copy your kernel.bin file to isodir/boot

5) Get Cygwin for 32-bit by downloading setup-x86.exe from here: https://cygwin.com/install.html (if you already have it installed, run your setup file and skip to step 7)

6) Run the file, select an installation directory, package directory and GNU mirror.

7) Once the package listing has appeared, untick the 'Hide Obsolete Packages' checkbox.

8) In the search bar, search for grub and it should appear as "grub2" in the obsolete category. Select it for installation and proceed.

9) After installation (remember to add the Cygwin binary directory to your path), simply run:

sh grub-mkrescue --output=myos.iso isodir

You can then run the "myos.iso" file in VirtualBox.

If you have any questions, please leave a comment. Hope this helps!

Forrest4096
  • 159
  • 1
  • 8