B
B
BloodSucker2014-02-07 17:33:17
linux
BloodSucker, 2014-02-07 17:33:17

Linux from scratch: how to attach programs to a clean kernel?

Hello. I decided to torture myself a little and collect a small distribution kit.
Really, all I need is Bash, GCC, and a notepad, what else do I need to be happy?
There were no problems with setting up and compiling the kernel, but already with mounting Bash, GRUB and GCC, let's say, I began to have questions.
Actually, how to attach it all to the core? How should it look?
For example, GRUB, how to register your distribution kit in it? And in general, how to shove it there?
Bash, for example, I compiled, threw in the tools, the next folder, the folders with the kernel, is that all you need? Or is there something else that needs to be done to get the kernel to recognize Bash as the default sh shell?
Well, actually GCC, with it the same as with Bash?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
J
jcmvbkbc, 2014-02-07
@jcmvbkbc

If you have questions about booting the kernel and running userspace, you might be interested in reading the following:
https://www.kernel.org/doc/Documentation/filesyste...
https://www.kernel.org/doc/Documentation /early-use...
https://www.kernel.org/doc/Documentation/x86/boot.txt

A
Andrey Gurtovoy, 2014-02-07
@jt3k

linux from scratch honor

N
Nikolai Turnaviotov, 2014-02-08
@foxmuldercp

I would advise you to figure out how this is done in a ready-made distribution - debian, gento. The latter is generally a very good constructor, but very complex and interesting

K
kenny_opennix, 2014-02-13
@kenny_opennix

Somehow I collected a distribution kit for pos terminals, it was enough to read the docks from the site www.linuxfromscratch.org
And write an automatic installer.
Or we take gentoo in the minimum configuration, so to speak, install the necessary components, make an archive and an installer, I also did this option in my time.

A
Alexander Burov, 2014-03-03
@AquiHostStrider

Programs are attached directly to the kernel (at the lowest level) using kernel system calls . There, everything is done directly, there are no joys of life like printf () or scanf () and other stdio. To do this, you need to study the Linux kernel API well. To ease the development of this complex topic, you can start with numerous tutorials "Writing a Linux driver", gradually moving on to more complex things.
But practically no one does this, even embedders. To "attach" programs to the kernel, there is a basic C library, to learn how to configure and build which is a much more socially useful thing than building the kernel, stupidly poking the necessary options with the mouse. It is the basic C library that gives us that very inexpressible “Linux-ness” of the system environment.
For regular distributions, the GNU C library, better known as glibc, is used, with which all programs are linked, it provides all the joys of stdio life, it comes with all sorts of low initializations crt0.o, crt1.o, etc. and dynamic linker. For special applications, alternative core C libraries are used, eg uClibc, dietlibc, alibc. If you really want to use the kernel functions directly, you can study their source codes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question