Can somebody explain me what is happening in the following?

# This is a very simple, default initramfs

    dir /dev 0755 0 0
    nod /dev/console 0600 0 0 c 5 1
    nod /dev/tty 0666 0 0 c 5 0
    nod /dev/null 0600 0 0 c 1 3
    nod /dev/mem 0600 0 0 c 1 1
    nod /dev/kmem 0600 0 0 c 1 2
    nod /dev/zero 0600 0 0 c 1 5
    nod /dev/random 0600 0 0 c 1 8
    nod /dev/urandom 0600 0 0 c 1 9

    dir /dev/pts 0755 0 0
    nod /dev/ptmx 0666 0 0 c 5 2

    nod /dev/ttyS0 0666 0 0 c 4 64
    nod /dev/ttyS1 0666 0 0 c 4 65
    nod /dev/ttyS2 0666 0 0 c 4 66

    dir /bin 755 0 0
    dir /proc 755 0 0

    file /bin/hello ${INSTALL_ROOT}/projects/${SAMPLE}/hello/hello 755 0 0
    slink /bin/init hello 777 0 0

What are we trying to achieve here actually?

This is similar to this one

Generally it is clear to me that we are trying to run (hello ) from init (last line in code).

  • This looks like a configuration file for populating initramfs with various nodes, directories etc. We are not trying to achieve anything (assuming you refer to a combined effort between you and me). – Anthon Apr 7 '14 at 8:17

This file is an input file for the gen_init_cpio program in the kernel source tree.

It generates a cpio archive which is suitable for initramfs with the files/dirs/devices(=nodes)/... listed in the input file.

The syntax is

file <name> <location> <mode> <uid> <gid> [<hard links>]
dir <name> <mode> <uid> <gid>\n
nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
slink <name> <target> <mode> <uid> <gid>


Which programs are actually run on boot, depends on the init program in the initramfs. Here the init program is a symlink to hello.


@jofel has already answered the what it is question with admirable accuracy - what it should achieve, though, is the handoff from kernelspace to userspace. When the kernel loads it ensures all systems are operational then it looks for init. Without init your system's boot would never get off the ground - you would never be able to interact with the machine.

Some years ago the kernel developers decided they were tired of supporting 1001 and different possible configurations for root devices - it was simply becoming too complicated to handle booting a computer due to the sheer number of possible root file systems and root device type combinations. So they gave up trying.

Initramfs is builtin to every linux kernel since 2.6. In every case since then userspace begins there - the kernel hands control of the computer system over to init, sits back to watch the fireworks and washes its hands of the whole affair.

The directory tree described by the file in your question is a Linux root directory that is compiled into the kernel itself. It is the only root device the kernel will bother looking for; all of the rest is up to init.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.