Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am new to file system. 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). But I need a little bit more explanation.

share|improve this question
    
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 at 8:17

2 Answers 2

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>

etc.

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

share|improve this answer

@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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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