This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

initramfs doesn't work



I'm having problems with initramfs on the DM8148 with linux-04.01.00.06
on the Mistral TMDXEVM8148 eval board.  For all cases except the one
mentioned I get "Kernel panic - not syncing: No init found".

First of all, I have been careful to prepare my initramfs subtree with a
/init script, the typical initrd/initramfs directories and files, all the
device nodes, programs and links needed, all the libraries needed by
/bin/busybox.  I have checked file permissions.  I have even simplified
things down to running a simple "/bin/hang" executable, which is a
statically-linked program consisting of "while (1);", which is intended
to stop execution only to prove I reached it.  I have read enough stuff
on initrd and initramfs to fill a desk drawer, and still don't see what I
could be missing.

If I prepare an initrd or initramfs filesystem and load it to 0x81600000
using u-boot, and add "initrd=0x81600000,2M" to the command line, the /init
script doesn't seem to execute.  I thought the initrd memory might be getting
corrupted, but I have used u-boot to prove that is not so.

If I prepare a normal initramfs and build it into the kernel, that fails.

If I prepare an initramfs with a single file, /init, which is a renamed
copy of my "hang" executable, and build that into the kernel, that works.
It "works", in the sense that it hangs rather than causing a kernel panic.
This case requires absolutely no resources other than the /init program
itself.  It is also small enough to sneak past a suspected cpio problem
described below.

If I take my normal initramfs with all its files, add /bin/hang, and
change /init to be a script which does nothing else but invoke /bin/hang,
(requiring no resources except /bin/busybox, its library files, and
/bin/hang), that does not work.

Most initramfs tutorials show /init as being a script, but one vaguely
implied that /init had to be an executable program.  Is this so?

Whenever I change the content of the initramfs kernel build input subtree
and rebuild the kernel, I get "section mismatch" warnings.  Is this a
serious problem for initramfs testing?  I would like to rebuild in 2 minutes
rather than doing a "make clean" and then waiting 20 minutes for a full
build.

I noticed that the initramfs cpio archive embedded in the kernel seems to
have a CPIO header, one or two files, followed by another CPIO header and
the rest of the files.  Is it possible that the build process did something
wrong and that the kernel is only reading the first part?  If I extract
the initramfs from the kernel image, a CPIO command seems to read the
entire thing seamlessly without even a warning.

I looked at the release notes for 04.00.01.07, and found nothing relating
to initramfs, so I would rather avoid that side trip right now.

Oh yeah, I should mention that linux boots just fine without an initramfs,
but I need one to change the root FS at boot time.


  • What's the command that you are using for creating the initramfs?

  • For the kernel-sourced initramfs, I am using menuconfig to set CONFIG_INITRAMFS_SOURCE to the base directory of my initramfs subtree.

    For the separate RAM image:

    cd <base of initramfs subtree>

    find . -print0 | cpio --null -ov --format=newc | gzip -c -9 > ../initramfs.igz

    I then copy the file to the DOS partition on my SD card, and move the card to the eval board.

    Then I power up and break out of the stage 2 u-boot countdown and issue the command:

    mmc rescan 0; fatload mmc 0 0x81600000 initramfs.igz

    I modify bootargs to include "initrd=0x81600000,2M", issue the other commands from my boot.scr file manually, and boot linux.

  • Does something like the following work?

    $ find . | cpio -H newc -o > ../initramfs.cpio
    $ cd ..
    $ cat initramfs.cpio | gzip > initramfs.igz

    (The find part is different)

  • Vaibhav,

    No, that gave me the same results, but I noticed a message "rootfs is not initramfs (junk in compressed archive)".

    As far as I can tell my command line:

    find . -print0 | cpio --null -ov --format=newc | gzip -c -9 > ../initramfs.igz

    Is legal.  The -print0 and --null thing allows filenames containing spaces to be processed by using a NUL character as file delimiter. 

    Not that I have any filenames with spaces in my initramfs, but running across the example, it seemed like a good thing to do.   And

    according to the cpio man page, "--format=newc" is the same as "-H newc".

    I have a shell script which extracts the kernel-built initramfs.   I used this script after a kernel build with initramfs, and extracted a cpio

    file consistent with what I handed to the kernel build.  But now that I reset CONFIG_INITRAMFS_SOURCE="", I was not expecting an

    embedded cpio file to still be there.  But there is, and it seems to be corrupted.  A "cpio -t" only reports files "/dev", "/dev/console", and "/root",

    before reaching the cpio "TRAILER!!!" string.  So I will be investigating the kernel initramfs makefiles.

    Erwin Kann

  • Hi,

    I have the same problem too,

    just can't get initramfs works and end up with

    RAMDISK: Couldn't find valid RAM disk image starting at 0.
    List of all partitions:
    1f00             128 mtdblock0  (driver?)
    1f01             256 mtdblock1  (driver?)
    1f02               8 mtdblock2  (driver?)
    1f03            2560 mtdblock3  (driver?)
    1f04            1144 mtdblock4  (driver?)
    b300         3872256 mmcblk0  driver: mmcblk
      b301           72261 mmcblk0p1 00000000-0000-0000-0000-000000000mmcblk0p1
      b302         3799372 mmcblk0p2 00000000-0000-0000-0000-000000000mmcblk0p2
    No filesystem could mount root, tried:  ext3 ext2 vfat msdos iso9660
    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

    Could anyone have any other suggestion??

    Thanks in advance

           Hong

  • Hi,

    I found out a few pieces of information:

    1. I built my initramfs.cpio separately, copied the file to the base of my linux source tree, and set CONFIG_INITRAMFS_SOURCE="./initramfs.cpio".

        This made my kernel image larger, but I got out of the problem of where to put/how to reference the initramfs.

    2. I discovered the hard way that busybox is not static-linked.  You need to include the libraries it needs in your initramfs /lib directory.

        I needed ld-2.8.so, libc-2.8.so, and libm-2.8.so, and symbolic links ld-linux.so.3, libc.so.6, and libm.so.6.

    3. I manually included the links for all busybox applets which I used in my init, e.g. /bin/echo, /bin/mount, /bin/umount, /sbin/modprobe, /sbin/switch_root.

    4. I also downloaded, built and installed a newer busybox (1.19?), but don't remember anymore why I needed it.

    5. I think I was able to use commands of the form 'echo "Just before modprobe" >/dev/console'  for debug.

    6. It is important to remember that initramfs is a very brain-dead environment.  Don't assume *ANY* resource exists--provide it explicitly.

    I hope this is a help.  Unfortunately, I am unable to offer anything beyond the above comments.  Good luck!