[SOLVED] Kernel panic upon simple rebuild of initramfs !

Post questions about how to make a customized SystemRescueCd, and if you have problems to install new packages. Please read the handbook first.
Post Reply
Sithlord
Posts: 21
Joined: 03 Jan 2008, 14:24

[SOLVED] Kernel panic upon simple rebuild of initramfs !

Post by Sithlord » 06 Jul 2014, 14:43

Hi,

I first wanted to tweak few things here and here in the "init" script of "initramfs.igz" and everytime, I wasn't able to boot the test system afterwards. I ended up reducing everything to a simple test drive and I'm stuck with something I can't understand !

I have a simple script to build a test ISO for a virtual machine looking like this :

- Step 1 : Copy needed files from "/path/to/OriginalSRCD" to "/path/to/custSRCD"
- Step 2 : Customize the initramfs contents
- Step 3 : Build the initramfs and the ISO file
- Step 4 : Test on the virtual machine to see if everything goes as expected

I'm stuck at step 2 ! I've reduced it to :

mkdir /tmp/initramfs_$$
cd /tmp/initramfs_$$
cat /path/to/OriginalSRCD/initramfs.igz | xz -d | cpio -id
# This is where I did my customization. Everything is now commented so NO changes applied!
find . | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > /path/to/custSRCD/initramfs.igz

Now, everytime I boot the VM with the built ISO I get a kernel panic "no init found" ! If I replace Step 3 with a simple "cp -p /path/to/OriginalSRCD/initramfs.igz /path/to/custSRCD/initramfs.igz" everything works fine of course!

I even tried to fallback to a good old legacy "gzip" compression to end up with the same result :-(

What am I missing here? What's wrong in this simple unpack/repack procedure?

I've captured the output of the kernel boot ( console=tty console=ttyS0,9600n8) and all I see here is this :

Code: Select all

[    2.695612] Unpacking initramfs...
[    2.894270] Freeing initrd memory: 15396k freed

...more kernel messages...

[    3.611977] Freeing unused kernel memory: 11820k freed
[    3.614106] Write protecting the kernel read-only data: 12288k
[    3.616747] Freeing unused kernel memory: 716k freed
[    3.618761] Freeing unused kernel memory: 604k freed
[    3.668717] request_module: runaway loop modprobe binfmt-0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000

...lots of repetition for this one...

[    3.711428] input: ImPS/2 Generic Wheel Mouse as /devices/platform/i8042/serio1/input/input2
[    3.726652] request_module: runaway loop modprobe binfmt-0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
[    3.786372] Failed to execute /init
[    3.828761] request_module: runaway loop modprobe binfmt-0000

...same repetition stuff...

modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
[    3.998816] request_module: runaway loop modprobe binfmt-0000
modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000

...again and again...

modprobe: FATAL: Error running install command for binfmt_0000
modprobe: FATAL: Error running install command for binfmt_0000
[    4.053675] Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[    4.056142] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.35-std420-amd64 #2 
[    4.057567] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013
[    4.059684]  0000000000000000 ffff88007b7e5eb8 ffffffff8173d17b ffff88007b7e5f38
[    4.061450]  ffffffff8173ce29 0000000000000008 ffff88007b7e5f48 ffff88007b7e5ee8
[    4.063133]  0000000000000000 0000000000000000 ffffea0000089d10 0000000180200006
[    4.064699] Call Trace:
[    4.065121]  [<ffffffff8173d17b>] dump_stack+0x19/0x1e
[    4.066041]  [<ffffffff8173ce29>] panic+0xbf/0x1db
[    4.066986]  [<ffffffff8172ded0>] ? rest_init+0x74/0x74
[    4.067915]  [<ffffffff8172dfa2>] kernel_init+0xd2/0xd6
[    4.068837]  [<ffffffff81745dbc>] ret_from_fork+0x7c/0xb0
[    4.069699]  [<ffffffff8172ded0>] ? rest_init+0x74/0x74
Last edited by Sithlord on 06 Jul 2014, 15:37, edited 1 time in total.

Sithlord
Posts: 21
Joined: 03 Jan 2008, 14:24

Re: Kernel panic upon simple rebuild of initramfs !

Post by Sithlord » 06 Jul 2014, 15:37

Hi,

Problem solved thanks to lbohan719 on his post modprobe: FATAL: Error running ...binfmt_000 [SOLVED] !

Indeed, I slightly changed Step 2 to change "cpio" by "busybox cpio"

Everything is fine now :-)

kks3311
Posts: 5
Joined: 26 Mar 2016, 19:38

Re: [SOLVED] Kernel panic upon simple rebuild of initramfs !

Post by kks3311 » 26 Mar 2016, 19:45

Can you please explain in detail how you did that?

dvdakker
Posts: 1
Joined: 29 Nov 2016, 09:25

Re: [SOLVED] Kernel panic upon simple rebuild of initramfs !

Post by dvdakker » 29 Nov 2016, 09:47

I encountered the same issue today and the pointers in this and the referenced threads allowed me to solve it. The trick is to use the busybox binary embedded *in* the original cpio archive to build the new one. From what I can gather this is because busybox's cpio implementation isn't entirely compatible with the GNU one. For future reference below are the steps I used to extract and then rebuild the initramfs.igz file:

Assuming the initramfs.igz file is located in the current directory, extracting the initramfs.igz file is done as follows:
  • mkdir initram_ext
  • cd initram_ext
  • xz -d --stdout ../initram.igz | cpio -div
You can now make the necessary modifications.

Rebuilding is done as follows (assuming you are still in the initramfs_ext directory)
  • find . | ./bin/busybox cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > ../initramfs_new.igz
As shown in the above command, the busybox cpio implementation is used. Otherwise the procedure is exactly the same as explained in the manual.

Post Reply