initrd + busybox error

richard at nezumi.plus.com richard at nezumi.plus.com
Fri Jul 4 11:11:33 PDT 2003


On 2003-07-04 14:57:26 +0000, Pedro Salazar wrote:
> Greetings,
> 
> I already manage to boot and *run* the initrd image of my LFS. 
> However, I'm getting problems running the initrd. I'm using the hints
> described made by Jim Gifford (my thanks to Jim) with busybox.
> 
> I'm getting the busybox message screen when loading the initrd:
> 
> "
> BusyBox v0.60.5 (2003.06.23-16:22+0000) multi-call binary
> 
> Usage: busybox [function] [arguments]...
>    or: [function] [arguments]...
> 
>         BusyBox is a multi-call binary that combines many common Unix
>         utilities into a single executable.  Most people will create a
>         link to busybox for each function they wish to use, and BusyBox
>         will act like whatever it was invoked as.
> 
> Currently defined functions:
>         [, ash, busybox, chroot, echo, insmod, mkdir, modprobe, mount,
>         pivot_root, sh, test, umount
> "
> 
> and after that I got a kernel panic message:
> 
> "Kernel Panic: Attempted to kill init"
> 
> My linuxrc:
> 
> "
> #!/bin/sh
> 
At a guess, things are going wrong here. /bin/sh is a link to busybox,
which will be called with argv[0]="linuxrc". If you did not comment
out #define BB_FEATURE_LINUXRC in busybox-*/Config.h busybox will
try to run init.

I think you did comment out #define BB_INIT, so linuxrc crashes.

Last time I checked (busybox-0.60.5) busybox assumed linuxrc runs as
process 1. This has not been true since linux 2.4.20, you cannot test
an initial ramdisc with BB_INIT.

>
> However, I already tried remove the linuxrc from my initrd, and I still
> got the same message!!! Shouldn't the error be anything else like
> "linuxrc not found in initrd image"???
>
No. If linuxrc does not exist, the thread set up for it silently
terminates. Then the kernel gets on with some things that you were
not expecting because the documentation is out of date.

Things will get a bit unpredictable at this point because I do not know
which root device is specified on the command line. As you are
following ancient documentation, you probably specified the initial
ramdisc as root. These days you should specify the required final
root device. If you did not specify on the command line, you will get
the device set into the kernel image with rdev.

At this point, process 1 is chrooted to /root, which is where
the ram disc is mounted. Process 1 escapes from the chroot
jail, and remounts the ram disc at /old. It then unmounts
/old/dev (devfs).

If the final root device is the ram disc, process 1 changes
directory to /old, and returns intead of this:

    mount the final root device at /root
    if the depended on missing modules you would get an error message:
       "VFS: Cannot open root device \"%s\" or %s\n"
    if the filesystem depended on missing modules:
        "VFS: Unable to mount root fs on %s"
    Otherwise:
        "VFS: Mounted root (%s filesystem)%s.\n"
    change directory to /root
    if /root/initrd exists
        remount ramdisc at /root/initrd
    else
        unmount ramdisc
        free ramdisc

unount /dev (devfs) from / (rootfs)
remount the filesystem at the current directory (/old or /root) at /
chroot to /
mount devfs
free the kernel initialisation code.
Try to run "/sbin/init"
Try to run "/etc/init"
Try to run "/bin/init"
Try to run "/bin/sh"
That last one should work - as you have probably set root to the initrd

busybox is now running as process 1 and decides it should be init,
but you did not compile init into busybox, so it crashes:
"Kernel Panic: Attempted to kill init"


In case I guessed wrong, here are some clues from a workinig initrd
system:

...
<6>NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
<5>RAMDISK: Compressed image found at block 0
<6>Freeing initrd memory: 209k freed
<4>VFS: Mounted root (romfs filesystem) readonly.
<6>Mounted devfs on /dev

My linuxrx starts here, it mounts /proc and scans for logical
volumes. LVM and devfs do not fit together perfectly so I get
this mess:

<3>devfs_mk_dir(urusai): using old entry in dir: c7fa15c0 ""
<3>devfs_register(group): could not append to parent, err: -17
<3>devfs_register(stable): could not append to parent, err: -17
<3>devfs_register(var_s): could not append to parent, err: -17
<3>devfs_register(swap1): could not append to parent, err: -17
<3>devfs_register(home): could not append to parent, err: -17
<3>devfs_register(swap2): could not append to parent, err: -17
<3>devfs_register(var_t): could not append to parent, err: -17
<3>devfs_register(test): could not append to parent, err: -17
<3>devfs_register(spare): could not append to parent, err: -17
<3>devfs_register(backup): could not append to parent, err: -17

My linuxrc then exits. It does not mount the root device, 3a:00
(/dev/urusai/stable), or pivot root.

<4>reiserfs: checking transaction log (device 3a:00) ...
<4>Using r5 hash to sort names
<4>ReiserFS version 3.6.25
<4>VFS: Mounted root (reiserfs filesystem) readonly.
<5>Trying to move old root to /initrd ... okay
<6>Mounted devfs on /dev
<6>Freeing unused kernel memory: 116k freed

The documentation you read about linuxrc applies to kernels before
2.4.20. Modern ones do the work for you. Now my custom init scripts
start doing things:

<6>Adding Swap: 1150968k swap-space (priority -1)
...


Back to you linuxrc:

> echo "Initial RAMDISK Loading Starting..."
> insmod /lib/scsi_mod.o
> insmod /lib/sd_mod.o
> insmod /lib/usbcore.o
> insmod /lib/usb-storage.o
> insmod /lib/usb-ohci.o
> insmod /lib/ehci-hcd.o
> echo "Initial RAMDISK Loading Completed..."
> mkdir /new_root
not needed

> echo "Mounting proc..."
> mount -n -t proc none /proc
I hope /proc exists

> echo 0x0100 > /proc/sys/kernel/real-root-dev
I prefer root=... in grub's menu.


> echo "Mounting real root dev..."
> mount -n -o ro /dev/sda1 /new_root
not needed

> umount /proc
might help, depened is /initrd/ exists.


delete the rest:
> cd /new_root
> echo "Running pivot_root..."
> pivot_root . initrd
> if [ -c initrd/dev/.devfsd ]
>         then
>                 echo "Mounting devfs..."
>                 mount -n -t devfs none dev
> fi
> if [ $$ = 1 ]
>         then
>                 echo "Running init..."
>                 exec chroot . sbin/init dev/console 2>&1
>         else
>                 echo "Using bug circumvention for busybox..."
>                 exec chroot . sbin/linuxrc dev/console 2>&1
> fi
> "

> 
> However, I already tried remove the linuxrc from my initrd, and I still
> got the same message!!! Shouldn't the error be anything else like
> "linuxrc not found in initrd image"???
> 
> I appreciate any help with this subject,
> 
Does that explain things?

Richard
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list