Qemu gets stuck at booting from hard disk

Viewed 19849

I am trying to load a simple kernel using the qemu emulator but, qemu gets stuck at "Booting from hard disk". A screenshot of the problem

The source code for the kernel can be found in the following link: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-828-operating-system-engineering-fall-2012/ , in the lab 1 assignment in the directory obj/kern/kernel.img. Pdf of lab1, tar.gz of lab1, pointers1.c. The task was:

The first part concentrates on getting familiarized with x86 assembly language, the QEMU x86 emulator, and the PC's power-on bootstrap procedure. The second part examines the boot loader for our 6.828 kernel, which resides in the boot directory of the lab tree ...

 % cd lab
 % make
 ...
 + mk obj/kern/kernel.img 

.. Now you're ready to run QEMU, supplying the file obj/kern/kernel.img, created above, as the contents of the emulated PC's "virtual hard disk." This hard disk image contains both our boot loader (obj/boot/boot) and our kernel (obj/kernel).

 % make qemu 
3 Answers

It also may be issue with gcc version. Latest available Fall(2018) has fix for this

Author: Jonathan Behrens <fintelia@gmail.com>
Date:   Tue Sep 4 14:10:42 2018 -0400

Tweak kernel.ld linker script so edata and end are set correctly

This change should hopefully resolve issues when compiling with newer versions
of GCC.

commit a56269d4beefc7d0b3672180aa46c654cfb63af4
diff --git a/kern/kernel.ld b/kern/kernel.ld
index 45a0b6a..a219d1d 100644
--- a/kern/kernel.ld
+++ b/kern/kernel.ld
@@ -47,13 +47,13 @@ SECTIONS
                *(.data)
    }
-       PROVIDE(edata = .);
-
        .bss : {
+               PROVIDE(edata = .);
                *(.bss)
+               PROVIDE(end = .);
+               BYTE(0)
        }
-       PROVIDE(end = .);
        /DISCARD/ : {
                *(.eh_frame .note.GNU-stack)
Related