LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-06-2022, 02:14 PM   #1
dMeister
LQ Newbie
 
Registered: Nov 2022
Posts: 2

Rep: Reputation: 0
Bare Linux kernel/Busybox system displays in QEMU, not on hardware


I'm trying to boot a bare system in the form of an ISO written on a USB drive. I compiled the kernel and Busybox, created an initramfs file with Busybox and an init script, formatted the kernel and initramfs images into an ISO, then wrote that ISO directly to the USB drive using dd. I tested the drive directly using the following command:

Code:
qemu-system-x86_64 -hda /dev/sda
It boots into GRUB and displays the one entry I created. I can select the entry, and the boot procedure begins and prints out all the log info to the screen, and eventually I get access to the shell that I spawn in the init script. If I press CTRL+D and kill the shell, the kernel goes into a panic as would be expected.

However, when I try to boot the drive directly on my PC, GRUB loads, but when I select the entry to boot, nothing is displayed. I think the kernel is booting up, because if I press CTRL+D I can see from my blinking CAPS lock key that the kernel is panicking. But nothing shows up on the screen. Any ideas as to why the drive is bootable in QEMU but not my actual PC?

Some extra details--

Linux Kernel 5.19.17
compilation commands:
Code:
make x86_64_defconfig
Code:
make
(everything else left default)

Busybox 1.34.1
Code:
make x86_64_defconfig
Enable static linking, everything else default. I'm running Manjaro which doesn't include libcrypt.a, so I downloaded it manually and copied it into my /lib directory.

Code:
make
make install
Inside the Busybox _install directory
Code:
mkdir dev proc sys
Create a file "init".

Init script:
Code:
#!/bin/sh
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo  "Hello, Linux!"
exec /bin/sh
Creating initramfs.cpio.gz from the _install directory
Code:
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz
To create the ISO image, inside of a directory called iso/
Code:
mkdir iso/boot iso/boot/grub
cp <kernel build dir>/boot/bzImage <Busybox build directory>/initramfs.cpio.gz .
Create a file in iso/boot/grub gruf.cfg, contents:

Code:
set default=0
set timeout=10
insmod efi_gop
insmod font
if loadfont /boot/grub/fonts/unicode.pf2
then
        insmod gfxterm
        set gfxmode=auto
        set gfxpayload=keep
        terminal_output gfxterm
fi

menuentry 'myos' --class os {
    insmod gzio
    insmod part_msdos
    linux /boot/bzImage
    initrd /boot/initramfs.cpio.gz
}
To make the ISO
Code:
grub-mkrescue -o myos.iso iso/
And finally I write myos.iso directly to /dev/sda.
 
Old 11-12-2022, 06:13 AM   #2
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
This is a very complicated question you are asking here, so many things could go wrong during such a boot. Where to even start?

Are you sure that Kernel can boot on your hardware? Can it, if you say boot it with Manjaro?
 
Old 11-12-2022, 09:19 AM   #3
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Any&every 'true LinuxGuru' SHOULD have DONE mll, w/VMcustom .config

[Simple ] mll? http://DistroWatch.com/mll
http://minimal.idzona.com/the_dao_of...linux_live.txt

(It's been my lifelong dream get up the '?gumption?' to build this simple thing, so ...) (c.f.)

WILDguess (withOUT carefully reading OP):
Might you be missing the video driver for your hardware, but included the video driver for QEMU's virtual video device? (I vaguely think defconfig reads the current lsmod, or some functionally similar Magic)

Last edited by !!!; 11-12-2022 at 09:46 AM. Reason: DW link; guess; then inflammatorally (doIt4me) trolling title:eek:
 
Old 11-23-2022, 11:42 PM   #4
dMeister
LQ Newbie
 
Registered: Nov 2022
Posts: 2

Original Poster
Rep: Reputation: 0
I know both my PC and laptop can run Linux because I'm currently running Manjaro on both. I think the issue is related to missing drivers, specifically Nvidia drivers, because my PC display runs on my graphics card. I tried booting the same ISO on my laptop (which has no dedicated graphics card) and the display worked, which I suppose would support that theory. Or maybe it's common knowledge that extra drivers will be needed if the system display is running from a graphics card--I'm very new to kernel tinkering of any kind.

Are there any general routes to take when trying to diagnose issues such as this? That is, debugging a kernel at early stages and boot time? As I mentioned, I'm new to this and would like to learn how to approach this in the future.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libvirt (QEMU 2.6.0): virtfs (Plan 9, 9p) painfully slow, NFS on par with bare metal atelszewski Linux - Virtualization and Cloud 0 08-21-2016 03:53 AM
LXer: Set up qemu-kvm-1.0+noroms as spice enabled qemu server vs qemu-kvm-spice on Ubuntu Precise LXer Syndicated Linux News 0 05-26-2012 07:41 AM
qemu: hardware error: qemu: could not load PowerPC bios 'openbios-ppc' Skaperen Linux - Virtualization and Cloud 8 06-09-2011 07:15 AM
bare ide and bare acpi kernels denning Slackware 1 03-04-2005 05:50 AM
creating a bare-bare-barebones system for an underpowered laptop orange400 Linux - General 3 06-15-2004 05:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration