2

I've followed this tutorial when it comes to compiling a kernel for the Raspberry Pi. I'm installing onto a properly partitioned SD card, which I completely formatted first (it now has a fat32 boot partition and ext4 file system partition). However, I believe that, in the linked tutorial, they are installing their compiled kernel onto an SD card that already contained an image of Rasbpian. This is because when I boot my Pi with my SD card (the only directory in the file system in my SD is the lib/ directory containing firmware/ and modules/), the boot fails, saying:

PANIC: No init found

I figure that this is because there is because of a lack of a file system present on the SD card during the boot (or something of the like, I'm very new to this entire process). I've done some Googling and come across the concept of an initramfs--is my problem that I need one configured to allow the the boot process to continue? Should I be generating an initramfs, or is it best to just load my custom kernels onto SD cards that have already been imaged with the kernel I am customizing from?

SlySven
  • 3,631
  • 1
  • 20
  • 46
npp1993
  • 193
  • 1
  • 9

1 Answers1

1

No, you do not need an initramfs. The purpose of that is to facilitate the use of a wide variety of hardware; it enables the kernel to pick from a range of (potentially mutually exclusive) drivers needed in order to mount the root filesystem and proceed. Hence, they are the norm on general purpose linux distros because those are intended for use on a broad variety of hardware.

However, the pi uses its own special kernel that can't be used on anything else anyway, and pis are uniform WRT basic hardware, so an initramfs is not used. You could use one, but don't bother unless you have a particular reason to do so.

Init, as the wikipedia article says, is the first non-kernel process on a unix-style operating system. It is also the only one ever actually started by the kernel, and it cannot be killed; all other processes are descendants of init.

Note that an OS kernel all by itself won't do anything once loaded, because there is nothing for it to do.

I believe the linux kernel, after it mounts the root filesystem, looks for init in /sbin/init and if that doesn't exist may try /bin/sh instead. Since you don't have any root filesystem, you get this panic (but at least you know your kernel works).

On Raspbian wheezy, the init program used is a variant of SysV init (also described in that wikipedia article), and the executable is literally /sbin/init. Raspbian jessie, following Debian which switched from SysV after ~20 years, uses systemd; in this case /sbin/init is a symbolic link.

You can use, or at least try, anything via the same technique -- either just name the binary /sbin/init or use a symlink. You do not need to use a static binary since the kernel handles linking.

If you use a normal userland, it does not have to be from the same place as your kernel, but you do need to install the kernel modules onto it. If you built the kernel yourself, you should do this regardless.

goldilocks
  • 60,325
  • 17
  • 117
  • 234