You are not logged in.

#1 2011-04-26 06:46:21

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Understanding init and inittab

I'm trying to enhance the wiki page https://wiki.archlinux.org/index.php/Inittab by making some points clearer, according my understanding. But before that, I'd like to ensure what I understand is correct. I'm not a native speaker so language polishing is also appreciated.

* The first process started by kernel, after the kernel image("/boot/kernel26.img") has been fully loaded, is init. This behavior, however, can be modified by specifying kernel parameter(is it the correct term?) init=path/to/fancyinit in the bootloader if you'd like to use "fancyinit". (Question: how is the default init determined? Is it hard-coded into kernel26.img?)

* Arch by default uses sysvinit (pacman package core/sysvinit) as the init program. sysvinit(the program is sbin/init in Arch) reads /etc/inittab to decide what to do according to the runlevel specified in the kernel parameter as "ro x", where x is the desired runlevel. When not explicitly specified, sysvinit enters the default runlevel specified in /etc/inittab.

* What the wiki page especially lacks (and confused me a lot) is the control flow of init. The name "inittab" tends to make people think it's order-free table; but as I understand, init performs actions specified in /etc/inittab in order as in the file, so it's really "sysvinitscript" (in Arch the name "initscript" already refers to the /etc/rc.* scripts). However, except for entries with action "sysinit", "bootwait" and "wait", the commands are executed asynchronously, somehow making the order less important.

* However, most importantly, Arch use sysvinit only as the init program; it handles most actual work to /etc/rc.{sysinit,single,...} and scripts under /etc/rc.d. This can be found out by examining /etc/inittab:

rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
rh:06:wait:/etc/rc.shutdown
su:S:wait:/sbin/sulogin -p

Offline

#2 2011-04-26 07:52:53

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: Understanding init and inittab

(Question: how is the default init determined? Is it hard-coded into kernel26.img?)

If an initramfs is used the kernel will first execute /init after the image is decompressed. In our case that's a busybox script (link). It determines /sbin/init as standard init process unless $init is determined. You can change $init in /lib/initcpio/init which is what mkinitcpio will copy to the initramfs image (kernel26.img).
If there's no initramfs, kernel default is to use /sbin/init on the root file system.

The way i see it, /sbin/init in Arch is used more as a bootstrap process. Probably very early in /sbin/init (you'd have to get the sourcecode) there will be a check for the runtime level leading to /etc/inittab which as you've stated sets that level but also delegates to the startup scripts used by Arch. From then on it's BSD style startup. Most work is done by /etc/rc.sysinit.
There is an archwiki article specific to the boot process: https://wiki.archlinux.org/index.php/Arch_Boot_Process
Maybe your findings will better fit there.

Last edited by demian (2011-04-26 08:35:29)


no place like /home
github

Offline

#3 2011-04-26 08:13:11

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Re: Understanding init and inittab

demian wrote:

(Question: how is the default init determined? Is it hard-coded into kernel26.img?)

As i understand it, if kernel26.img is used, the init process will be started by /init (link), a busybox script on the initial ram disk. It determines /sbin/init as standard init process unless $init is determined. You can change $init in /lib/initcpio/init which is what mkinitcpio will copy to the initrd (kernel26.img).

Thanks!

But overall /sbin/init is a very small part of the boot process. Arch uses a BSD style init process instead of sysvinit which means most work is done by /etc/rc.sysinit. Probably very early in /sbin/init (you'd have to get the sourcecode) there will be a check for the runtime level leading to /etc/inittab which as you've stated sets that level but also delegates to the startup scripts used by Arch. From then on it's BSD style startup.
There is an archwiki article specific to the boot process: https://wiki.archlinux.org/index.php/Arch_Boot_Process
Maybe your findings will better fit there.

I knew of the BSD-style booting process; I'm trying to make sysvinit things clearer because it's useful sometimes(like https://wiki.archlinux.org/index.php/St … 2Finittab). I think I should change the word "handle" to "delegate" to avoid confusion.

Another issue concerning the wiki and inittab: https://wiki.archlinux.org/index.php/St … .2Finittab states:

Warning: This method will not use /bin/login or register your session, therefore no session will appear in `who` or `w`. Your session will also not be authorized as 'local' by consolekit, so you will be unable to shutdown/suspend/reboot or mount drives without using sudo or su.

Only the first statement, which doesn't matter too much, is true. Am I missing something (I'm not familiar with consolekit) or is the warning out-dated so I should update it?

Offline

#4 2011-04-26 08:29:14

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: Understanding init and inittab

I use the inittab method. /usr/bin/who doesn't show my session and ck-history reports them all as "session-is-local=FALSE". I'd say the warning is up-to-date. I don't know the implications of that though. Only ever had one user so there is no need for me to bother with CK tongue.

Last edited by demian (2011-04-26 08:50:00)


no place like /home
github

Offline

#5 2011-04-26 09:10:06

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Re: Understanding init and inittab

demian wrote:

I use the inittab method. /usr/bin/who doesn't show my session and ck-history reports them all as "session-is-local=FALSE". I'd say the warning is up-to-date. I don't know the implications of that though. Only ever had one user so there is no need for me to bother with CK tongue.

It also stated you're unable to reboot/shutdown and mount without sudo or su. But, for example, I'm able to reboot using

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

I guess it's because I use a login manager (lxdm) which takes care of ConsoleKit. Will my consolekit sesions become local ones? How do I find out the type of my consolekit session? Thanks!

Offline

Board footer

Powered by FluxBB