Quest to build minimal BusyBox liveCD

ucscjaime

New Member
Joined
Sep 19, 2018
Messages
4
Reaction score
2
Credits
0
Hiya y'all. Just for fun and as a learning experience, I'm currently trying to set up a bootable stick that has BusyBox by itself as a userland.

I was following these tutorials online:
  • This one to set up the initramfs and compile the kernel to use it
  • This one to set up ISOLINUX and pack the system into an ISO to burn to the drive
  • After I experienced some problems, there were also tutorials I was following to turn on debug in the kernel, redirect guest serial to a host machine pipe, and make device nodes that may be necessary to set up the console, but I seem to have lost those tutorials
I'm testing the ISO in VirtualBox because I don't want to let it loose on my machine until I'm sure it works and is safe.

I'm experiencing a problem:

[ 7.857101] Failed to create /dev/root: -2
[ 7.857602] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -2
[ 7.858479] Please append a correct "root=" boot option; here are the available partitions:
[ 7.859572] 0b00 1048575 sr0
[ 7.859573] driver: sr
[ 7.860655] 0800 8388608 sda
[ 7.860655] driver: sd
[ 7.861514] 0801 8387567 sda1 031261bc-6194-5148-8641-bc31b793e89d
[ 7.861514]
[ 7.862563] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 7.863466] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.8 #5
[ 7.864117] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[ 7.865026] Call Trace:
[ 7.865379] dump_stack+0x46/0x5b
[ 7.865727] panic+0xd9/0x228
[ 7.866114] mount_block_root+0x184/0x248
[ 7.866714] ? set_debug_rodata+0xc/0xc
[ 7.867172] mount_root+0x121/0x13f
[ 7.867601] prepare_namespace+0x130/0x166
[ 7.868117] kernel_init_freeable+0x1e7/0x1f9
[ 7.868620] ? rest_init+0xb0/0xb0
[ 7.869075] kernel_init+0x5/0x100
[ 7.969105] ret_from_fork+0x35/0x40
[ ..882216 eennllOOffee::0033aa0000 rrmm00ffffffff88000000 rrllccttoo aagg::00ffffffff88000000--0xffffffffffffffff
[ 99228800]]---- nn eennllppnncc--nnttssyniigg: VFS:UUnable to mount root fs on unknown-block(0,0) ]---

Now, I'm a noob to kernel stuff, but from what I've read so far, it seems like if no root fs is specified in kernel parameters, but an initramfs either is specified or comes embedded in the kernel, then it's the job of either the initramfs or the init script inside it to specify and possibly mount the root fs. My init script, which I copied from the first tutorial listed above,
tries to mount the root fs, but even if it fails, it does still call the BusyBox shell, thus stalling the kernel boot process and perpetually keeping the system in the initramfs instead.

So, the fact that I'm seeing these error messages can only mean one of three things:
  • My initramfs is not recognized.
  • My initramfs is recognized, but init is not running.
  • Init is running, but for some reason, it's not calling the BusyBox shell.
From other things I've read, if the initramfs were recognized and init weren't running, I would've gotten a kernel panic about that at an earlier point, along the lines of "can't find init" or something. So I think we can rule that one out. I somewhat doubt the first one, too, because my initramfs is built into the kernel, but I'll leave it up to all y'all to decide if it's possible. Anyway, that left the third possibility, so I looked farther up in the serial pipe and found this:

[ 7.355143] console [netcon0] enabled
[ 7.355275] netconsole: network logging started

[ 7.355854] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 7.356933] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 7.357647] ALSA device list:
[ 7.358043] No soundcards found.

[ 7.358476] Warning: unable to open an initial console.

I've bolded the lines that have me concerned.

I have several questions:
  1. What is this "network console" my kernel is identifying? It can't be the host serial pipe, because that starts producing output well before that message.
  2. Do these messages mean it's preferring the network console (whatever that is) over an onscreen console?
  3. If 2, where can I find the messages logged to the network console?
  4. If 2, why is it doing this?
  5. If 2, could that have something to do with "unable to open an initial console?"
  6. If 5, would it be advisable to try to disable the network console to force the kernel to fall back on an onscreen console?
  7. If 6, how do I do this?




FOR REFERENCE

Trees

Here's the output of `tree boot` (boot is the root directory of my ISO):

boot
├── isolinux
│ ├── isolinux.bin
│ ├── isolinux.cfg
│ └── ldlinux.c32
└── vmlinuz

1 directory, 4 files

Here's the output of `tree initramfs`:

initramfs
├── bin
│ ├── busybox
│ └── sh -> busybox
├── dev
│ ├── console
│ └── tty0
├── etc
│ └── mdev.conf
├── newroot
├── proc
├── sbin
│ └── init
└── sys

7 directories, 6 files

File contents

Here are the contents of boot/isolinux/isolinux.cfg:

default 1
label 1
linux /vmlinuz
append console=ttyS0 console=tty0 ignore_loglevel

For the contents of /initramfs/sbin/init, see the first tutorial link in this post. It's unchanged from there.

Kernel config

I'm using Linux 4.18.8. I ran `make defconfig` to ensure the config was the default config provided, and then made only the change shown in the first tutorial linked above:

General Setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/root/initramfs.cpio) Initramfs source file(s)

Build scripts

Here's my script to build the initramfs to be embedded in the kernel:

#!/bin/bash
rm -f initramfs.cpio
find initramfs | cpio -H newc -o > initramfs.cpio

Here's my script to build the ISO to load into virtualbox:

#!/bin/bash
rm -f linux.iso
mkisofs -o linux.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table boot
cp linux.iso ~jaime
chown jaime:jaime ~jaime/linux.iso

I don't have a script to rebuild the kernel, but if I did, it would be run after rebuilding the initramfs but before rebuilding the ISO, and here's what it would contain, i.e. here's what I do by hand:

#!/bin/bash
pushd linux-4.18.8
make
cp arch/x86/boot/bzImage ~/boot/vmlinuz
popd




I know my situation is really idiosyncratic and weird, and what I'm trying to do that got me into this situation is even weirder, but does anyone see anything obvious that might be going wrong here? If anyone can help me out it would be much appreciated. Best regards
 


Yep ... as suspected, beyond my paygrade :(:D

But @JasKinasis may be interested in this, he will swing by when he is able, Jaime, since I have set his ears to burning.

Wiz
 
Thanks for taking a look, Wiz, and I look forward to hopefully hearing from Jas and/or others.

Also, for anyone who can help, here are some details I forgot to mention:
  • My mdev.conf is empty. Not sure if that's important. The tutorial I was following just said to leave it empty.
  • I'm aware my kernel command line in isolinux.cfg lacks a 'root='. I did try it with root=/dev/sda1 as well. No luck. No clearly noticeable or relevant difference in the kernel serial log.
  • The reason I think the "warning: unable to open an initial console" message may be related to the kernel panic is that I figure if the kernel tries to run init, first of all init's not going to produce any output without a console, and secondly, without a console, it's not going to receive any input, so even if it gets around to running BusyBox, first of all it's not going to leave any trace of having run, and secondly it's just going to terminate immediately due to receiving EOF the minute it tries to grab input. Please correct me if I'm thinking of this the wrong way.
 

Members online


Top