Qemu gets stuck at booting from hard disk

17,452

Solution 1

eng140,you could use a 32-bit Linux. I had the same problem. After having used a 32-bit Linux, this problem was solved. In the following web https://pdos.csail.mit.edu/6.828/2017/tools.html in the section "Using a virtual Machine", they recommend that we should use a 32-bit Linux.

Solution 2

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

Author: Jonathan Behrens <[email protected]>
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)
Share:
17,452

Related videos on Youtube

eng140
Author by

eng140

Updated on June 19, 2022

Comments

  • eng140
    eng140 11 months

    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 
    
    • danglingpointer
      danglingpointer almost 6 years
      add more information about the boot parameters what your providing. This pic doesn't help much to identify the problem your facing?
  • eng140
    eng140 almost 6 years
    Thanks for the response! I tried adding the above line to the GNUmakefile but it didn't work.
  • osgx
    osgx almost 6 years
    eng140, does qemu-system-i386 -hda obj/kern/kernel.img -serial mon:stdio line work? What is the text output of it?
  • eng140
    eng140 almost 6 years
    It displays: Could not open qemu-system-i386, no such file or directory.
  • osgx
    osgx almost 6 years
    eng140, so do install it (or rebuild qemu)? You can't work with VM when you have only image of VM and not the virtual machine runner. I don't know how compatible are system-x86_64 and system-i386 in qemu.
  • Jet Blue
    Jet Blue over 3 years
    Alternatively, instead of using a VM, if you are on a 64-bit Linux machine, you can create a compiler toolchain that generates 32-bit binaries by using sudo apt-get install gcc-multilib (as explained in the link shared in this answer).

Related