2

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.

Leonardo
  • 124
  • 1
  • 8

3 Answers3

1

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.

Andrey
  • 162
  • 1
  • 6
0

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

Anton Glukhov
  • 3,507
  • 1
  • 15
  • 16
  • The /init in my initramfs is just a shell script. There's no /etc/inittab. As far as I know, inittab is part of sysvinit, right? I have sysvinit only in my rootfs. – Leonardo May 08 '15 at 15:06
  • Oh, sorry. You are right! Could you show command line(bootargs) for kernel? – Anton Glukhov May 08 '15 at 21:24
  • console=ttyS0,115200 console=tty0 root=/dev/mmcblk0p1 rootwait panic=10 consoleblank=0 I know there's no reference to the initrd here, but it's not necessary, as I'm using U-Boot as bootloader. It somehow tells the kernel about the initrd. – Leonardo May 09 '15 at 14:39
  • Could you look at this doc: https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt? Section: "What is initramfs?". It looks like your case. – Anton Glukhov May 09 '15 at 14:46
0

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

user2743554
  • 491
  • 2
  • 11