ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi
I made a decision that it is inevitably for me to go into the deepest corners of the Linux code. I am prepared to read the codes as long as there is a variable which I didn't understand. I know that it is a task which has to be completed only by me but ...
What is the best entry point?
I use Slackware for my desktops and servers. It seems to me that the best point is the linux kernel.
Please, if anybody knows about some good links or documentations post it. I want to find the best sources of information.
Starting with the kernel itself is probably not the best way. Id start by studying the intrd used by the Slackware installer. Then start studying the 'real' system by begiining at /etc/rc.d/rc.S, while peeking at some kernel code related to what happens just before and as the root '/' partition gets mounted by the kernel. That'll keep you busy for a while....
Depending on how much knowledge you have already it might be best to start by studying a simple external command such as /bin/tail (the link s to the BSD version because GNU versions are generally harder to understand). That might sound trivial but even something as trivial as tail has over 2000 lines of source code. You will definitely want a good understanding of the process model, good pages: here (userland), here (userland programming) and here (kernel space overview).
I use linux approximately 10 years. I know all basic user operations (shell commands, kernel compilation ...) and run several servers. I also wrote already some C++ applications. My point here is to dig deeper and follow the hierarchy in the source code. I mean if there is a process which starts first at the beginning (boot) I want to understand that process before I continue to the second.
Quote:
Id start by studying the intrd used by the Slackware installer
Yes, I am already doing it. I study right now the main.c in the source code of the init. I want to follow the exact order of the processes as the system is booting up, the setup process.
Thorough the years of my technical experience I found out that the most important thing is to find the best source of information. Something like this: http://www.ibm.com/developerworks/li...y/l-linuxboot/
The init process can be best understood by studying the init scripts. 'init' itself is pretty simple in what it does. It sometimes is called the 'mother of all processes'. It's main purpose is to run the startup scripts and keep daemons running -restarting them if they die, etc. What is harder to understand is how init gets started -there I'd suggest working backwards a little into the kernel code to see how init gets started. Studying a very simple initrd helps you to understand what is most basic to a running system. grep in the kernel source code for '/sbin/init' and you'll soon find the critical things which are needed to make the transition from a fully loaded kernel to a running system -via 'init'.
Once the kernel is loaded into RAM, it looks for a very few things in the root partition. The bootloader has told the kernel where the root partition is located, so the kernel tries to mount that partition and tries to figure out if it really is a bootable system by looking for three things: /dev/console, /bin/sh and init which must be located at either /sbin/init, /bin/init or /etc/init. The kernel also looks to see if there is a /linuxrc file. If there is, it will try to run that before turning over execution to 'init'. /linuxrc was/is typically used in an initrd to perform some extra jobs before the normal init runs. Modern kernels use pivot_root to make the transition from the initrd to the 'real' system. An initrd is typically used to do some fancy things like creating a ramdisk which can then have a filesystem image mounted in it -this is how LiveCD's work by fooling the kernel into thinking it has a 'real' writable system to work with. initrd's are also used to load any kernel modules needed to access the real filesystem, when those modules are not hard-linked into the kernel. Once you've understood what happens when the kernel transitions to init, you'll find it much easier to understand what happens before and after that point.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.