LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Where is 'init' run from? (slackware 9.0) (http://www.linuxquestions.org/questions/slackware-14/where-is-init-run-from-slackware-9-0-a-60472/)

itsjustme 05-18-2003 11:22 AM

Where is 'init' run from? (slackware 9.0)
 
In the Slackware Linux Essentials book there is:

"The first program to run under Slackware besides the Linux kernel is init(8)."

I haven't been able to find what calls this program. Is this called from /boot/vmlinuz?

In the man pages for init it says:

"Init is the parent of all processes."

So, I assume that vmlinuz is the first thing that happens after boot up, or as a part of boot up. And then init is called from there and the system setup branches out from that point. Or is init called from some other program that /boot/vmlinuz launches?

Thanks...

itsjustme 05-18-2003 12:34 PM

Uh.. Actually, I can't find 'init' either. I did find several 'init.c' files in /usr/src/linux-2.4.20/arch'. So, I am assuming (again) that vmlinuz (the actual kernel ??) calls, or runs, the 'init.c' in

'/usr/src/linux-2.4.20/arch/i386/mm'

on this Pentium III machine.

Thanks for any comments/input as I get into this 'guts' level investigation of linux.


Hmmmm... Now I don't know. I searched through init.c for the string 'inittab' and didn't get a hit. And, I read:

"The first program to run under Slackware besides the Linux kernel is init(8). This program reads the /etc/inittab(5) file to see how to run the system."

:confused:

MasterC 05-18-2003 12:50 PM

whereis init
I get:
Code:

bash-2.05a$ whereis init
init: /usr/src/linux-2.4.20-lq1/init /usr/src/linux/init /sbin/init /usr/man/man8/init.8.gz /usr/share/man/man8/init.8.gz

One pointing to my kernel source, another to the symlink to my kernel source, and finally the init program itself:
/sbin/init

HTH

Cool

itsjustme 05-18-2003 01:08 PM

d'oh!!

here's what I did:
[root@bsslack ~] $ find / -name 'init' -print
/usr/src/linux-2.4.20/init
/usr/src/linux-2.4.20/include/config/msndclas/init
/usr/src/linux-2.4.20/include/config/msndpin/init
/sbin/init
[root@bsslack ~] $

I just overlooked that tiny /sbin/init. (my eyeballs didn't do their customary carriage return/line feed!! :rolleyes: ) The others are init directories.

So, anyway, I see it's a complicated process. Is my assumption correct that /sbin/init is called from /boot/vmlinuz ?

And, then, does the /sbin/init use the init.c in /usr/src/linux-2.4.20/arch/i386/mm ? I can't view init since it is a binary file, so I don't know what's in it.

Thanks for your patience and for bearing with me while I try to get a grasp of the initialization process.

MasterC 05-18-2003 01:13 PM

I doubt that /sbin/init calls anything from /usr/src since on many distros (and even on slack) this directory is/can be empty. You don't have to have your kernel source available for booting up.

As for my guess on what it calls (since I have no real idea):
/sbin/init
calls
/etc/inittab
which in turns calls it's respective runlevel defined there with the default entry;
which then calls the appropriate /etc/rc.d scripts to get the system rolling.

This is of course after the kernel (/vmlinuz or /boot/vmlinuz depending on which release you are running) has done it's thing (everything before the runlevel).

Cool

itsjustme 05-18-2003 01:22 PM

Quote:

Originally posted by MasterC
As for my guess on what it calls (since I have no real idea):
/sbin/init
calls
/etc/inittab
which in turns calls it's respective runlevel defined there with the default entry;
which then calls the appropriate /etc/rc.d scripts to get the system rolling.
Cool

I got this from the info I was reading, but the initial question (which is not answered in the info I was reading) remains about my assumption.

"Is my assumption correct that /sbin/init is called from /boot/vmlinuz ?"

I'm just trying to be careful with my assumptions. ;)

Thanks...

MasterC 05-18-2003 01:31 PM

Looking around for the bootup to bash how to, I found this one:
http://www.tldp.org/HOWTO/BootPrompt-HOWTO.html
Which has some info on this. I'll keep looking.

Cool

MasterC 05-18-2003 01:32 PM

Ahh, here it is:
http://axiom.anu.edu.au/~okeefe/p2b/ (Curteousy if www.linuxfromscratch.org )

Cool

itsjustme 05-18-2003 01:52 PM

AH!!! I found it. I was just looking in the slackware documentation. I almost forgot I had this "Running Linux" book. (another d'oh!)

Anyway, it says quite clearly, " Once the device drivers are initialized, the kernel executes the program init , which is found in /etc, /bin, or /sbin (it's /sbin/init on most systems). init is a general-purpose program that spawns new processes.... etc."

So, RTFM applies! I was just shying away from "Running Linux" because my initial foray into it scrambled my brains as a rank newbie.
I guess I am starting to pass out of that phase. :)

regards...

Edit: This is in the boot prompt howto:
"Any remaining arguments that were not picked up by the kernel and were not interpreted as environment variables are then passed onto process one, which is usually the init program."
This, of course, pushed the question "where is process one called from?' onto the WTF stack. ;) The statement didn't actaully say init was called from the kernel. It made it appear that the call to process one was after the kernel. Anyway, moot point now.

itsjustme 05-18-2003 02:02 PM

AH!! some more.

That power up to bash prompt howto has some good info on init also.

Thanks...!

edit: from that howto:
"Once the kernel is loaded, the first thing it does is look for an init program to run."

MasterC 05-18-2003 02:15 PM

No, thank you. I needed to add that how-to to my bookmarks.

Cool

itsjustme 05-18-2003 02:52 PM

Added for future searchers:

I also found the rute manual

http://linux.tnc.edu.tw/techdoc/linu...rute/rute.html

and looked up init in there. Of course, it says the last thing the kernel does involves the /sbin/init file.

Quote:

After the kernel has been unpacked into memory, it begins to execute, initializing hardware. The last thing it does is mount the root file system, which necessarily contains a program /sbin/init, which the kernel executes. init is one of the only programs the kernel ever executes explicitly; the onus is then on init to bring the UNIX system up. init always has the process ID 1.
So, last thing, first thing, who's counting? :rolleyes:

I'm gonna understand this before I move on to runlevels!! ;)

MasterC 05-18-2003 03:14 PM

I think it's confusing the 2 terms:
Once the kernel is loaded the first thing it executes is init VS
The very last thing the kernel does during loading is execute init

:)

Cool


All times are GMT -5. The time now is 04:59 AM.