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:
I'm experiencing a problem:
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:
I've bolded the lines that have me concerned.
I have several questions:
FOR REFERENCE
Trees
Here's the output of `tree boot` (boot is the root directory of my ISO):
Here's the output of `tree initramfs`:
File contents
Here are the contents of boot/isolinux/isolinux.cfg:
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:
Build scripts
Here's my script to build the initramfs to be embedded in the kernel:
Here's my script to build the ISO to load into virtualbox:
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:
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
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 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) ]---
[ 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.
[ 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.
[ 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:
- 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.
- Do these messages mean it's preferring the network console (whatever that is) over an onscreen console?
- If 2, where can I find the messages logged to the network console?
- If 2, why is it doing this?
- If 2, could that have something to do with "unable to open an initial console?"
- If 5, would it be advisable to try to disable the network console to force the kernel to fall back on an onscreen console?
- 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
├── 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
├── 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.label 1
linux /vmlinuz
append console=ttyS0 console=tty0 ignore_loglevel
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)
[*] 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
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
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
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