Leonardo
Leonardo

Reputation: 174

Kernel does not call /init script on initrd

everyone. I'm working on my first embedded Linux and I would like to have a nice bootsplash. I've decided to use an initrd to get it up as early as possible, but it looks like the kernel is not calling the /init script. It mounts my ram disk and proceeds with the usual booting sequence.

<5>RAMDISK: squashfs filesystem found at block 0
<5>RAMDISK: Loading 16643KiB [1 disk] into ram disk... 
<6>VFS: Mounted root (squashfs filesystem) readonly on device 1:0.
<6>kjournald starting.  Commit interval 5 seconds
<6>EXT3-fs (mmcblk0p1): using internal journal
<6>EXT3-fs (mmcblk0p1): mounted filesystem with ordered data mode
<6>VFS: Mounted root (ext3 filesystem) on device 179:1.
<5>Trying to move old root to /initrd ... okay
<6>devtmpfs: mounted
<6>Freeing init memory: 180K
<30>udevd[79]: starting version 182

I have tried without success all sorts of debugging I knew of to test whether the script was being called. I get no error at all. After logging in, I can see the ram disk mounted at /initrd, as it was supposed to be.

I'm using a Cubieboard 2 with the drivers and kernel (3.4) provided by the community. I know it's an old version, but it's the one with the best support for sunxi SoCs so far. I'm also using both file systems (rootfs and initramfs) provided by Linaro as a base.

Could anyone help me?

Thank you.

Upvotes: 3

Views: 2431

Answers (3)

Andrey
Andrey

Reputation: 172

Short answer: I think, you need to use /linuxrc or /sbin/init instead of /init. Or, better, use initramfs instead of initrd.

Long answer.

/init is used in case of initramfs while it seems you're using initrd (because of ramdisk and squashfs image being loaded into it).

There are three options for getting early userspace and mounting the root filesystem: 2 with initrd and 1 with initramfs.

  1. initrd is a filesystem (ext[234], squashfs, etc.) image, which is copied by the kernel into ramdisk (/dev/ram*).
    • (obsolete) The kernel mounts the ramdisk, calls /linuxrc; /linuxrc loads required modules, writes to /proc/sys/kernel/real-root-dev and exits. The kernel then mounts the real root and calls the real /sbin/init
    • The kernel mounts the ramdisk, calls /sbin/init; /sbin/init mounts the real root, calls pivot_root, execs the real /sbin/init
  2. initramfs is a cpio archive, that is extracted by the kernel into tmpfs. The kernel calls /init, which is responsible for mounting the real root and exec'ing the real /sbin/init (via possibly via switch_root utility, which cleans up the tmpfs).

Also, you can check Gentoo wiki Initramfs page for a more information.

Upvotes: 2

user2743554
user2743554

Reputation: 543

Shell binary should be static. Otherwise, /lib should be present on the RAMFS.

Upvotes: 0

Anton Glukhov
Anton Glukhov

Reputation: 3707

What about /etc/inittab? Did you initialize console in this file? Maybe tty init just missed. Could you show it?

Upvotes: 0

Related Questions