0

Setup

Partitions:

# fdisk -l /dev/sda
...
Device     Boot Start    End Sectors Size Id Type
/dev/sda1  *     2048  51199   49152  24M  c W95 FAT32 (LBA)
/dev/sda2       51200 204799  153600  75M 83 Linux

Syslinux configuration:

UI menu.c32
LABEL linux
        LINUX ../bzImage
        APPEND nomodeset rootfstype=ext4 root=/dev/sda2

/init:

#!/bin/sh

mount -t proc proc proc mount -t sysfs sysfs sys mount -t devtmpfs udev dev

/bin/sh poweroff -f

Testing

Booting via QEMU works:

# qemu-system-x86_64 /dev/sda

However, booting on my laptop gives:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

If I use an initrd:

...
APPEND nomodeset rootfstype=tmpfs initrd=../initrd.img

...then my laptop boots fine, despite the initrd not having any kernel modules

See also

  • so: what is the question? – jarnosc Oct 17 '23 at 00:13
  • @jarnosz Why does it crash on hardware, but not in the emulator? Why does an initrd fix it, and can I boot without it? – GooseDeveloper Oct 17 '23 at 02:24
  • You told QEMU to present some kind of storage device interface, and built your kernel with the driver for it. If it was a virtio- or vhost- device in QEMU configuration, the hardware certainly won't have that. Your kernel needs to include the driver(s) to handle the actual storage controller that is in your laptop hardware. In QEMU terms, it might be nvme or ahci if your laptop is reasonably modern; if your laptop is old enough to not have AHCI, then it gets more complex. You could include one driver for QEMU use and another for HW: if you tried that, you chose the wrong one for HW. – telcoM Oct 18 '23 at 17:18
  • @telcoM I built the kernel on my laptop using defconfig. I'm fairly sure nvme and ahci are the correct drivers, but I'll check lspci, etc. just in case. – GooseDeveloper Oct 18 '23 at 17:59
  • On kernel version 6.5.7, the arch/x86/configs/x86_64_defconfig (where make defconfig gets its defaults from, assuming x86_64) does specify CONFIG_SATA_AHCI, CONFIG_ATA_PIIX and even CONFIG_PATA_AMD and CONFIG_PATA_OLDPIIX, but (surprisingly) neither CONFIG_NVME_CORE nor CONFIG_BLK_DEV_NVME. – telcoM Oct 18 '23 at 18:42

0 Answers0