# BusyBox - Kernel panic [solved]

## mcimaster

Hello,

I have got a problem with my initramfs.

I build my system using this tutorial: http://en.gentoo-wiki.com/wiki/Root_filesystem_over_LVM2,_DM-Crypt_and_RAID

It works well, but I want to change the manual password entry into a key-file that lies on a USB device. So I modified the init- script.

Here it is:

```
#!/bin/sh

mount -t proc proc /proc

CMDLINE=`cat /proc/cmdline`

mount -t sysfs sysfs /sys

#wait a little to avoid trailing kernel output

sleep 3

#If you don't have a qwerty keyboard, uncomment the next line 

loadkmap < /etc/kmap-de

#raid

/bin/mdadm --assemble /dev/md2 /dev/sda2 /dev/sdb2

# Mounting USB-Devices - sleep 10, to be sure that all usb devices are recognized.

sleep 10

mount -t devtmpfs none /dev

mount /dev/sdc1 /mnt

# Check if USB device is mounted

ls -la /mnt

# Encrypting device

/bin/cryptsetup luksOpen -d /mnt/top_secret_key /dev/md2 vault

# Waiting, just to see if something has shown up on the screen

sleep 5

umount /dev

#lvm

#/bin/vgscan

/bin/vgchange -ay vg

#root filesystem

mount /dev/mapper/vg-root /newroot

#unmount pseudo FS

umount /sys

umount /proc

#root switch

exec /bin/busybox switch_root /newroot /sbin/init ${CMDLINE}
```

After I started my system, I got this error messages and then the system hang up:

```
BusyBox v1.15.3 (2010-05-22 03:54:05 CEST) multi-call binary

Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]

Free initramfs and switch to another root fs:

chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,

execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.

Options:

        -c DEV  Reopen stdio to DEV after switch

[   15.233292] busybox used greatest stack depth: 4408 bytes left

[   15.233541] Kernel panic - not syncing: Attempted to kill init!

[   15.233787] Pid: 1, comm: busybox Not tainted 2.6.32-gentoo-r7 #3

[   15.234030] Call Trace:

[   15.234288]  [<ffffffff81569116>] panic+0xa0/0x152
```

After days of searching and trying around, I hope that somebody out there can help me.

greetz

mci

----------

## rh1

I used those same instructions. I had to change the first line to :

#!/bin/busybox sh

and then the last line to just:

exec switch_root /newroot /sbin/init

Not sure what the CMDLINE part is suppose to do but i had to remove it too.

----------

## mcimaster

Hello rh1,

tank you for your help, but unfortunately it didn't change anything. I think that the problem lies somewhere near the "used greatest stack depth". Before the server stops with the posted screen, it shows some more "used greatest stack depth"- messages in connection with other commands.

I hope we will find a solution.

Greetings

mci

----------

## x22

Why the script unmounts /dev before running vgchange and mounting /newroot?

"used greatest stack depth" is debug message from kernel and it is unlikely to be related to the problem.

----------

## mcimaster

Hello x22,

that was it! I took some lines from other tutorials, changed a little bit around and I forgot to place this line at the end.

Thank you very much. Have a nice summer day!

greetings

mci

----------

