OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:07 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Trying to boot from iso using Qemu
PostPosted: Sun Jan 04, 2015 1:39 pm 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
I have followed the bare bones tutorial on the wiki with (more or less) success and I now have a 'working' OS :)

I also went ahead and implemented the 'Moving Forward' steps with success, this is great fun. However there is still one problem that I have been unable to solve: booting from cd rom on Qemu.

Whenever I try to boot from cd rom using the command
Code:
qemu-system-i386 -cdrom build/myos.iso


I see the following in the Qemu boot terminal regarding booting from CD:
Code:
Booting from DVD/CD...
Boot failed: Could not read from CDROM (code 0009)

Booting ultimately fails with the message: "No bootable device".

I have tried searching online for the error code 0009 but could not find it. Does anyone here know what this error code means and how I could resolve it?

Some more information which might help people help me:

To create the cd I execute the following commands:
Code:
mkdir isodir
mkdir isodir/boot
cp myos.bin isodir/boot/myos.bin
mkdir isodir/boot/grub
cp ../grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o myos.iso isodir


My grub.cfg file looks like this:
Code:
menuentry "myos"{
   multiboot /boot/myos.bin
}


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Sun Jan 04, 2015 7:16 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 16, 2014 5:33 pm
Posts: 213
Location: Costa Rica
Check the generated ISO. I have already seen that grub-mkrescue is a pretty dumb program and just calls xorriso, and either if all the process succeeds or fails, drops a ISO image. If the program failed, your ISO will be effectively have nothing important. Use a file viewer to view the ISOs contents. Are GRUB's files in there? Is your kernel binary in there? What's the size of the ISO image? We need more details...

_________________
Happy New Code!
Hello World in Brainfuck :D:
Code:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Mon Jan 05, 2015 11:09 am 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
Hello Kemyland. Thank you for your response.

I've tried your suggestions. Opening the iso with a text editor does seem to suggest grub was included (I saw strings like "grub.cfg"). I am not sure how to check if my kernel is included, the text editor I've tried so far (Gedit) does not handle large files very well.

The ISO itself is 8.9MB.

When building the following is outputted in the terminal:
Code:
xorriso 1.3.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:myos.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 3358m free
Added to ISO image: directory '/'='/tmp/grub.fdN4YE'
xorriso : UPDATE : 277 files added in 1 seconds
Added to ISO image: directory '/'='***/build/isodir'
xorriso : UPDATE : 281 files added in 1 seconds
ISO image produced: 4345 sectors
Written to medium : 4345 sectors at LBA 0
Writing to 'stdio:myos.iso' completed successfully.


I've added the '***' to the file location to hide some personal details :)

I am developing on Ubuntu 12.04 with a cross compiler set up as explained in the bare bones tutorial.

Please let me know if you need any more information. I am still rather new to this so please forgive me if I have forgotten anything.


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Mon Jan 05, 2015 11:40 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
You could check if your kernel binary is in there by searching in the iso file for your kernel. I'm not sure what commands to use for that but you will need a command that will attempt to find one file inside another. Also, although this might be obvious, make sure that you're definitey compiling/assembling the kernel before making the iso image and that you aren't including the kernel source code instead of the binary.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Mon Jan 05, 2015 12:42 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Mathyn wrote:
Opening the iso with a text editor
How about mounting it as a loop device instead?
Code:
mount -o loop /path/to/myos.iso /cdrom

Then you can look through the ISO and make sure all the files are in it.


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Tue Jan 06, 2015 10:43 am 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
I mounted the ISO as suggested and it looks like all the required files are there.

The root of the ISO looks like this:
Code:
dr-xr-xr-x 1 root root    2048 jan  6 17:27 boot
-r--r--r-- 1 root root    2048 jan  6 17:27 boot.catalog
-r--r--r-- 1 root root 2949120 jan  6 17:27 efi.img
-r--r--r-- 1 root root       0 jan  6 17:27 mach_kernel
dr-xr-xr-x 1 root root    2048 jan  6 17:27 System


In the folder 'boot' I then find my compiled kernel:
Code:
dr-xr-xr-x 1 root root  2048 jan  6 17:27 grub
-r-xr-xr-x 1 root root 14573 jan  6 17:27 myos.bin


So the ISO looks ok as far as I can see.

Could read/write permissions be a problem? Currently the ISO is set to read-only.


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Tue Jan 06, 2015 11:06 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
It looks like the ISO might be set up for EFI boot only. QEMU uses BIOS firmware by default, so can't boot from the EFI ISO.

If your host OS boots from EFI by default, grub-mkrescue will create an EFI ISO by default. When I had this issue, I went and completely replaced "grub-mkrescue" with the commands to make the ISO "manually" (see the "btos.iso" target in my Makefile). However, I believe if you install your distro's "grub-pc-bin" package, you should be able to keep using "grub-mkrescue", although you may need an extra parameter or two.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Wed Jan 07, 2015 6:06 am 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
That might very well be the problem, I'll take a look at your makefile to see how I can properly build the ISO. I'll post an update once I know more.


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Sat Jan 10, 2015 4:20 am 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
I solved the problem. It was indeed because it was set up for EFI boot only. After installing the grub-pc-bin package I had to add one extra parameter:

Code:
grub-mkrescue /usr/lib/grub/i386-pc -o myos.iso isodir

The "/usr/lib/grub/i386-pc" made it work :)

Would it be an idea to edit the bare bones tutorial to add least add a note about this potential problem? I can imagine in the future more people might run into this problem.

Anyway thanks for all the help everyone!


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Tue Jan 13, 2015 1:55 pm 
Offline

Joined: Tue Jan 13, 2015 1:53 pm
Posts: 1
Thanks Mathyn.

Same issue, was able to solve by your helpful comments.

I have a small question does this efi image is because of a specific architecture or how can I decide which boot image will be written to my iso file when I do grub-mkrescue?

Thanks-
Rituraj Chauhan


Top
 Profile  
 
 Post subject: Re: Trying to boot from iso using Qemu
PostPosted: Sat Jan 17, 2015 8:35 am 
Offline

Joined: Sun Jan 04, 2015 1:20 pm
Posts: 13
Glad your problem was solved, rsinghc.

As for your other question, I am not sure what you mean. Are you asking how to select the files you want to write on the ISO file?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group