Anleitung - Linux-Kernel kompilieren und installieren

Just found this GERMAN Guide to Compile a Linux-Kernel on pc-erfahrung. de Anleitung - Linux-Kernel kompilieren und installieren Manchmal ist es erforderlich, einen neuen bzw.

This topic was started by ,



data/avatar/default/avatar03.webp

1352 Posts
Location -
Joined 2004-02-01
Just found this GERMAN Guide to "Compile a Linux-Kernel" on pc-erfahrung.de

Anleitung - Linux-Kernel kompilieren und installieren


Manchmal ist es erforderlich, einen neuen bzw. anderen Linux-Kernel zu kompilieren und zu installieren. Sei es, weil die Entwickler einen neuen Kernel veröffentlicht haben oder vielleicht die eine oder andere Hardware nur mit einer bestimmten Kernel-Version funktioniert. Aber auch wenn man nur Änderungen an dem Kernel vornimmt, muss den Kernel neu kompilieren. Das Kompilieren stellt an sich gar keine große Schwierigkeiten dar, wenn man einmal die Routine und den Vorgang begriffen hat.

Zuerst muss man sich natürlich den geeigneten Kernel von www.kernel.org herunterladen. Hier sei gesagt, dass man von den ungeraden Kernel-Versionen die Finger lassen sollte, denn dies sind Entwickler-Versionen und es nicht garantiert, dass dieser Kernel stabil läuft. Ungerade bedeutet, dass die zweite Ziffer eine ungerade Zahl ist, also 2.3.xx oder 2.5.xx.



Step By Step


Gehen wir einfach mal davon aus, wir würden den 2.4.23-Kernel kompilieren. Natürlich ist dies nicht mehr der aktuellste Kernel, aber dieses Beispiel funktioniert auch für alle anderen Versionen. Wir laden also die Datei linux-2.4.23.tar.bz2 herunter und speichern diese in dem Verzeichnis /usr/src/ . Dieses Verzeichnis beinhaltet in der Regel die Quelldateien von Linux. Nachdem wir also die gepackte Linux-Datei dorthin gespeichert haben, müssen wir diese noch entpacken.

tar xvfj /usr/src/linux-2.4.23.tar.bz2


Nachdem dieser Schritt gemacht wurde, kann man nun mit "ls /usr/src/" kontrollieren, ob ein neues Verzeichnis angelegt wurde. Als nächstes müssen wir auf die neuen Linux-Quelldateien zeigen, damit das System weiß, dass in dem neuen Ordner der benötige Quellcode liegt. Das macht man mit folgendem Befehl:

Auf neuen Linux-Kernel zeigen
ln -s /usr/src/linux-2.4.23/ /usr/src/linux

Kontrolle
ls -n /usr/src/


Bei der Kontrolle müsste ein Eintrag vorhanden sein, der "... linux -> /usr/src/linux-2.4.23" lautet. Ist dies nicht der Fall, löschen Sie den aktuellen Zeiger mit "rm -r /usr/src/linux" und wiederholen Sie den oben genannten Vorgang.



Linux-Kernel konfigurieren


Der nächste Schritt ist der wohl meistgefürchtete Vorgang eines Linux-Users, denn man benötigt nun sämtliche Informationen zu seinem System. In der Konfigurationsdatei des Kernels müssen Sie nun sämtliche Angaben zu Ihrer Hardware machen und die entsprechenden Komponenten in den Kernel einbinden.

Dazu wechseln Sie in das Verzeichnis "/usr/src/linux" und geben den Befehl "make menuconfig" ein. Anschließend erscheint ein textbasierendes Konfigurationsmenü für den Kernel.

In das Linux-Verzeichnis wechseln
cd /usr/src/linux

Aufruf des Konfigurationsmenü
make menuconfig


Nun müssen Sie sich durch die vielen Einstellungsmöglichkeiten durchkämpfen und die entsprechenden Komponenten in den Kernel einbinden. Ist diese Arbeit erledigt, muss man den Kernel kompilieren. Das macht man mit folgendem Befehl:

Linux-Kernel kompilieren
make dep clean bzImage modules modules_install


Nun können Sie sich kurz entspannen, einen heißen Tee trinken oder vielleicht eine Zigarette anzünden, denn dieser Vorgang dauert ein paar Minuten. Nachdem der Kernel kompiliert wurde, legt das System den Kernel in dem Verzeichnis "/usr/src/linux/arch/i386/boot" die Datei bzImage an. Diese müssen wir nun in das Bootverzeichnis kopieren:

Kernel ins Bootverzeichnis kopieren
cp /usr/src/linux/arch/i386/boot/bzImage /boot/linux-2.4.23


Hinweis: Der letzte Teil des Befehls (.../boot/linux-2.4.23) sagt, dass die Datei kopiert und unter dem Namen linux-2.4.23 gespeichert wird. Wählen Sie also einen beliebigen Namen aus, den Sie sich merken können. Haben Sie bis hier alle Punkte erfolgreich durchführen können, können Sie stolz von sich behaupten, dass sie einen Linux-Kernel kompiliert haben ;-)



Bootloader einrichten


All diese Vorgänge bleiben wirkungslos, wenn wir dem System nicht sagen, dass er auch den neuen Kernel booten soll. Dazu müssen wir die Booteinstellungen ändern, was wir in diesem Fall über "LILO" machen. LILO ist ein Bootmanager, über den wir Booteinstellungen vornehmen können. Es gibt aber noch einige andere Bootmanager (Grub, etc). Wenn Sie also über einen anderen Bootmanager verfügen, müssen Sie mal einen Blick in die Readme werfen. Das Prinzip ist aber immer dasselbe.

Zuerst öffnen wir mit einem Texteditor die Konfigurationsdatei von Lilo, nämlich "lilo.conf". Dazu geben wir folgenden Befehl ein:

LILO-Konfigurationsdatei
nano -w /etc/lilo.conf


Daraufhin sehen wir die Bootroutine, die wir nun ändern müssen. Um auf der sicheren Seite zu sein, legen wir den neu kompilierten Kernel als zusätzliche Bootmöglichkeit an. Sollte der neue Kernel fehlerhaft sein, kann man dann noch von dem altem, funktionierendem Kernel starten. Hier ein Ausschnitt aus der lilo.conf:

image = /boot/bzImage #alter Kernel
root = /dev/hda1
label = linux
read-only

image = /boot/linux-2.4.23 #neuer Kernel
root = /dev/hda1
label = linux
read-only


Wie man gut erkennen kann, haben wir zu dem alten Kernel noch eine alternative Bootmöglichkeit abgegeben. Dazu sollten Sie nach "image =" den Pfad zum neuen Kernel angeben. Da wir im vorigen Schritt den Kernel nach /boot kopiert und ihn linux-2.4.23 genannt haben, müssen wir diesen Pfad nun auch in der lilo.conf angeben. Beim Neustart erscheint dann das Auswahlmenü, wo Sie entscheiden können, ob Sie von dem neuen Kernel oder vom alten Kernel starten möchten.

Die Änderungen in der lilo.conf müssen nun noch gespeichert werden. Dies macht man mithilfe folgendem Befehl:

Speichern von lilo
/sbin/lilo


Nun können Sie Ihr System neustarten und die vom neuen Kernel booten!



Schlussworte


Lassen Sie sich nicht von dem komplexen Vorgehen entmutigen. Hat man einmal einen Kernel erfolgreich kompiliert und installiert, stellen die nächsten Änderungen am Kernel für Sie keine Probleme mehr da.

Diese Anleitung müssen Sie nicht nur beim installieren eines komplett neuen Kernels benutzen, sondern auch, wenn Sie Änderungen a, aktuellen Kernel vornehmen.


Source: Link (German)

Google Tranlated:

Guidance - Linux Kernel compile and install are necessary sometimes it to compile and install a new and/or other Linux Kernel. Is it, because the developers published a new Kernel or perhaps or other hardware functions only with a certain Kernel version. In addition, if one only changes at the Kernel makes, must again compile the Kernel. Compiling represents actually no large difficulties, if one understood the routine and the procedure. First one must naturally download oneself the suitable Kernel of www.kernel.org. Here it is said that one should leave the fingers from the odd Kernel versions, because these are developer versions and it does not guarantee that this Kernel runs stably. Oddly that the second number is an odd number, thus 2.3.xx or 2.5.xx means. Steps By step going we simply times of it out, we would compile the 2.4.23-Kernel. This no more is natural the most current Kernel, but this example functions also for all other versions. We download thus the file linux-2.4.23.tar.bz2 and store these in the listing/usr/src/. This listing usually contains the source files of Linux. After we stored thus the packed Linux file there, we must still unpack these. tar xvfj/usr/src/linux-2.4.23.tar.bz2 after this step was made, can one now with "LS/usr/src/" check whether a new listing was put on. Next we must point to the new Linux source files, so that the system knows that in the new file need source code lies. One makes that with the following instruction: To new Linux Kernel LN s/usr/src/linux-2.4.23 show// usr/src/linux control of LS n/usr/src/with control would have an entry to be present, "... linux - >/usr/src/linux-2.4.23 "reads. If this is not the case, delete the current pointer with "rm r/usr/src/linux" and repeat you the procedure specified above. Linux Kernel configure the next step are the probably which was afraid procedure Linux users, because one needs now all information for its system. In the configuration file of the Kernels you must give now all data your hardware and merge the appropriate components in the Kernel. In addition you change into the listing "/usr/src/linux "and enter the instruction" make menuconfig ". A text-based configuration menu for the Kernel appears subsequently. Into the Linux listing CD changes/usr/src/linux call configuration menu make menuconfig now must you by the many attitude possibilities fight out themselves and the appropriate components in the Kernel merge. If this work is settled, one must compile the Kernel. One makes that with the following instruction: Perhaps Linux Kernel compile make dep clean bzImage modules modules_install now can you relax briefly, hot dte drink or a cigarette ignite, because this procedure takes a few minutes. After the Kernel was compiled, the system puts on the Kernel in the listing "/usr/src/linux/arch/i386/boot "the file bzImage. We must copy these now into the boat listing: Kernel in the boat listing copy cp/usr/src/linux/arch/i386/boot/bzImage/boot/linux-2.4.23 reference: The last part of the instruction (... /boot/linux-2.4.23) says that the file is copied and stored under the name linux-2.4.23. Select thus any name, which you can note. If you could successfully accomplish until here all points, you can state proudly from itself that they compiled a Linux Kernel; -) Bootloader furnish these procedures to universe remain ineffective, if we do not say to the system that it also the new Kernel boats is. In addition we must change the boat attitudes, which we make in this case over "LILO". LILO is a boat manager, over whom we can make boat attitudes. There are however still some other boat managers (, etc. dug). If you have thus another boat manager, you must throw times a view into the Readme. The principle is however always the same. First we open the configuration file of Lilo with a text editor, i.e. "lilo.conf". In addition we enter the following instruction: LILO Konfigurationsdatei nano w/etc/lilo.conf thereupon we see the boat routine, which we must change now. In order to be on the safe side, we put on the again compiled Kernel as additional boat possibility. If the new Kernel should be incorrect, one can start then still from that old, functioning Kernel. Here a cutout from lilo.conf: image =/boot/bzImage # of old Kernel roots =/dev/hda1 label = linux READ only image =/boot/linux-2.4.23 # of new Kernel roots =/dev/hda1 label = linux READ only as one well to recognize knows, we to the old Kernel still another alternative boat possibility delivered. In addition you should indicate the path after "image =" to the new Kernel. Since we copied boat in the previous step from the Kernel/and called it linux-2.4.23, we must indicate this path now also in lilo.conf. With the restart then the selection menu appears, where you can decide whether you would like to start from the new Kernel or from the old Kernel. The changes in lilo.conf must be still stored now. This makes one assistance for the following instruction: Memory of lilo/sbin/lilo now can start you again your system and from the new Kernel boats! Conclusions leaving it from the complex procedure not to discourage itself. If one successfully compiled once a Kernel and installs, the next changes at the Kernel for you place no more problems there. You must install this guidance not only with a completely new Kernels to use, but also, if you make changes at current Kernel.


Participate on our website and join the conversation

You have already an account on our website? Use the link below to login.
Login
Create a new user account. Registration is free and takes only a few seconds.
Register


This topic is archived. New comments cannot be posted and votes cannot be cast.