Please note, as Giles pointed out, this applies to the x86 architecture only.
Background
If you want to learn the proper order, you need to install a host system in QEMU before you install a kernel. While this approach seems counter intuitive to learning about the boot process, it is the only working way. Let me explain:
A running system of any OS has at least 3 Parts:
- A Kernel
- A Loader
- The final Booted OS.
Computers operate in two modes:
- Real Mode
- Protected Mode, sometimes referred to incorrectly as Virtual Mode.
All x86 processors operate in some form of these two modes no matter how sophisticated they are or how fast they operate. For More see the list to the right of the WikiPedia Articles I've linked.
How This Works
- All Computers Start in Real Mode.
- Real Mode does things like Checking your BIOS Settings, making sure all your Devices are connected, and Controls the Clock for Timing.
- Once Real Mode Completes checking, control is passed to the loader, aka the bootloader. The bootloader does exactly what it's name implies, by loading just enough pieces of code to transfer control of the PC from Real Mode to Protected Mode. Some Bootloaders achieve this Transfer at the beginning of their "takeover" Some do at the end, but most do it in Stages. See Booting.
- Once the Bootloader, completes loading the stages, the OS can safely and efficiently handle all other operations, as the PC is now in "Permanent Protected Mode" until the next restart.
How this Relates to Grub
If you look at the files that were copied over when you properly installed Grub, you'll see files containing the text Stage. There should be 3. Stage1*, Stage1_5*, and Stage2*
- Stage1 Loads
boot.img which is embedded in the MBR/EFI. It is configured to attach to disks and at the Very end loads core.img
- Stage1_5 uses
core.img to load Sectors 0-62, commonly referred to as the BootSector. These sectors by convention contain nothing, and therefore items placed in them are never overwritten or updated automaticaly
- Once Stage_2 begins, the first 62 sectors and the path to your kernel have been determined. Stage_2 loads the kernel, and its helper files, most natably the Initial RAM Disk into memory. The RAM Disk and Kernel are then uncompressed and used to setup yur system and transfer control to your chosen Linux OS.
See GNU Grub
Now the reason I say this is counter intuitive: You cannot start at Step 3 of How this Works, and Work your way through the How this Relates to Grub. After Stage1.5 completes Stage_2 will send you to a rescue prompt, as the Kernel and Initial RAM Disk, if you have one, once uncompressed have no device to setup, in your case hd0. Also the error Grub is reporting is correct.
error: no such device
is correct because there is no OS on hd0 to setup, therefore there is no OS to tell Grub Stage_2, "Hey I'm the OS that needs to be loaded." As such, you must work backwards, by building or installing the OS, then installing a kernel, and lastly installing the Bootloader. In your case, you need to configure QEMU to load the ISO image of a LiveCD as a CDROM, then install the OS on the virtual Disk hd0 then configure the bootloader. For a list of LiveCD's see DistroWatch Major Distributions. If you feel more comfortable with less bloat, try a Source Based Distribution, like Gentoo.
hd0is correct. I believe your issue her is that you have not embedded the boot sector code in the boot block. See this Gentoo Wiki Entry. Follow the Configuration Section for BIOS/MBR/dev/loop0is a CDROM type device. See WikiPedia, and you can't install a bootloader on a Read-only device.grub-install --no-floppy /dev/loop0indicates that you attemped to install the bootsector code as an appendage to the image file. QEMU does not see the image file because it is treating the image as the hard diskhd0as noted by your rescue prompt. You need to mount the image in a working system on the loop device like an ISO without the RO flag, create a boot directory in the image, rungrub-install, pointed at the mount point of the image, unmount and reboot QEMU. This is one of the reasons I use VirtualBox.