Re: kernel panic booting from USB flash drive

"NakanoMiku" ([email protected] via lfs-support Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.support
Message-ID <TYWPR01MB1063009CAF63C52F316C687BEAC442@TYWPR01MB10630.jpnprd01.prod.outlook.com>
On 2024/10/14 12:22, Michael Peters ([email protected] via 
lfs-support Mailing List) wrote:
> Build Host: x86_64 LFS 11.3 SystemV running kernel 6.6.56
>
> I'm building LFS 12.2 SystemD (also kernel 6.6.56, I prefer LTS 
> kernels) to a
> USB flash drive (using shell scripts) with the intent of then booting 
> from the
> USB flash drive to re-run my scripts to build it to a partition on the hd.
>
> Everything is working well *except* the boot.
>
> The flash drive is a single ext4 partition created by using fdisk (LFS 
> 11.3) to
> delete what the manufacturer put on it, create a single primary 
> partition of
> type Linux, and marking the partition bootable in fdisk.
>
> I then format the single partition with mkfs.ext4 (I *probably* should 
> have used
> ext2 but that's not the issue).
>
> LFS builds on it (albeit slowly), kernel installs, grub-install on 
> /dev/sdi from
> within the chroot after building kernel reports no problems.
>
> This is the grub.cfg I initially tried:
>
>     # Begin /boot/grub/grub.cfg
>     set default=0
>     set timeout=5
>
>     insmod part_gpt
>     insmod ext2
>     search --set=root --fs-uuid add2119a-1a46-4c72-b212-863ee869ebd1
>
>     #USB Flash Grub
>
>     menuentry "USB Flash GNU/Linux, Linux 6.6.56-lfs-12.2-systemd" {
>       linux /boot/vmlinuz-6.6.56-lfs-12.2-systemd 
> root=PARTUUID=8d5d11ba-01 ro
>     }
>
> The UUID and PARTUUID are from the `blkid` command and are correct, 
> and LFS 11.3
> booting from a hard drive is just fine with me using them so that 
> changes in the
> device name don't cause issues.
>
> When booting off the flash drive, the grub menu appears and it 
> actually starts
> to boot but I get
>
>     [    0.605403]  msdos
>     [    0.605474]  iso9660
>     [    0.605545]
>     [    0.605685] Kernel panic - not syncing: VFS: Unable to mount 
> root fs on unkno
>     wn-block(0,0)
>     [    0.605770] CPU: 5 PID: 1 Comm: swapper/0 Not tainted 6.6.56 #1
>     [    0.605850] Hardware name: Supermicro X10SLH-F/X10SLM+-F/X10SLM+-F,
>     BIOS 3.3 03/27/2020
>     [    0.605934] Call Trace:
>     [    0.606011]  <TASK>
>     [    0.606077]  dump_stack_lvl+0x38/0x50
>     [    0.606157]  panic+0x170/0x320
>     [    0.606238]  mount_root_generic+0x24b/0x300
>     [    0.606317]  ? rest_init+0xc0/0xc0
>     [    0.606394]  prepare_namespace+0x5e/0x270
>     [    0.606471]  kernel_init+0x11/0x1a0
>     [    0.606567]  ret_from_fork+0x28/0x40
>     [    0.606646]  ? rest_init+0xc0/0xc0
>     [    0.606722]  ret_from_fork_asm+0x11/0x20
>     [    0.606799]  </TASK>
>     [    0.606897] Kernel Offset: 0x16c00000 from 0xffffffff81000000 
> (relocation ran
>     ge: 0xffffffff80000000-0xffffffffbfffffff)
>     [    0.606987] ---[ end Kernel panic - not syncing: VFS: Unable to 
> mount root fs
>      on unknown- block(0,0) ]---
>
> (above manually transcribed from photo)
>
> It's definitely the Linux kernel and not a bios related kernel as the 
> kernel
> version is clearly visible.
>
> I tried changing
>
>     search --set=root --fs-uuid add2119a-1a46-4c72-b212-863ee869ebd1
>
> to
>
>     set root=(hd4,1)
>
> and I tried changing
>
>     root=PARTUUID=8d5d11ba-01
>
> to
>
>     /dev/sdi1
>
> but when I do that, grub can't even find the kernel. Clearly one or 
> both of
> those relative device references is wrong when I try it, I suspect the
> `set root=(hd4,1)` as I have four physical SATA drives which I think 
> should
> correspond to (hd0--hd3) but with bios boot order set to USB first, 
> who knows?
>
> But anyway I think the `UUID` and `PARTUUID` should work and when 
> used, clearly
> the kernel loads enough to panic.
>
> Same kernel config used as what works with LFS 11.3 but I wonder if 
> maybe there
> are some kernel options I need (or need as built-in instead of 
> modular) to boot
> a kernel off of USB? Anyone know?
>
> Would it be better to make an initramfs that lets kernel modules load 
> before the
> filesystem is mounted and does anyone have a clear reference to that 
> process?
>
> Thank you for your time.
>
I had my initramfs install on the USB drive and I didn't encounter this 
issue although I never try to boot  without initramfs. And I think it is 
better to go with the UUID method.

Here is a link: About initramfs (linuxfromscratch.org) 
<https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html>

-- 
http://lists.linuxfromscratch.org/sympa/info/lfs-support
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.