When working with a Linux system being loaded through PXE / tftpboot / NFS in a device without hard disk it could happen that we need to understand or fix problems at boot time process, part of it is initramfs.

The procedure to unpack an initrd.img is simple:

Here we’ll have access to the scripts and configuration of initramfs. I’ve modified the init script and added echo and sleep whenever was necessary  to display the different stages of the execution. Also when starting Linux I’ve added the parameter “debug” to the kernel, so this “case statement” in the init script would be executed:

As you can see, errors will be redirected to initramfs.debug but also I wanted to see all the executions with set -x so I’ve commented the exec part.

After changes were made it’s time to pack everything again:

I’ve safely ignored those errors which correspond to broken symlinks. The modified initrd_12.04 was generated and it worked perfectly.

It’s important to notice that the last step of init will be executing:

In this case run-init which is executed from /usr/lib/klibc/bin/run-init won’t display errors so easily due the “exec”, in this case we must divide the debug process in “before run-init” and “after executing run-init”. If there’s not a “panic error” usually the startup scripts, certain udev rules and other processes will be executed through SystemV or Upstart.

If the system hangs at “Stopping Userspace bootsplash” and there is no text console to interact, run-init “somehow has finished” and we should look for issues on the startup processes of SystemV or Upstart located at /etc/init.d and /etc/init respectively, disabling heavy services like X, or pulseaudio  is a lucky shot.

In my case I was stuck at “Stopping Userspace bootsplash” with no X server or text console to interact with the device, the system was just “stuck” there. Using other machine and disabling X (in init.d) lead me to a text console and finally taking a look on the services that used  “X”  I found the one causing problems, which was a personalized binary to splash an image at the boot process, after disabling it I had “X” back and everything worked.