Log in


Forgot your password?
prijatelji LUGoNSa
gnu.gif
linuxzasve.jpg
hulk.jpg
zextras_logo.png
 
You are here: Home / Uputstva / Opšte / Kompajliranje kernela

Kompajliranje kernela

by milobit last modified May 01, 2008 03:38 AM
Kako se kompajlira kernel

Većina današnjiha distribucija nudi već pečovan vanilla kernel za svoj disto. Instalirajte source kernela za Vašu distribuciju. Ime ovog paketa može biti različito: kernel-sources, linux-sources, gentoo-sources (ili druga slična distro-specifična imena), itd. Ovim ste skinuli aktuelni source kernela u /usr/src i, možda će kernel biti automacki otpakovan i linux link će pokazivati na aktuelni direktoriujum otpakovanog source-a (zavisi od distribucije).


Vanilla Kernel

Sve naredne komande morate pokrenuti kao root korisnik.

# cd /usr/src/
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.4.tar.bz2
# tar -jxvf linux-2.6.24.4.tar.bz2
# rm linux
# ln -s linux-2.6.24.4 linux
# cd linux

# make mrproper (se koristi kada hoćete da očistite sve predhodne konfig fajlove koje ste imali)
# make oldconfig (u slucaju da već imate kernel koji radi, dovoljno je odraditi ovu komandu)

Startovati jednu od tri mogućnosti:

# make xconfig ( X bazirna verzija, radi samo pod dignutim X-om) 
# make menuconfig ( meni bazirana verzija radi pod shell-om u konzoli)
# make config ( text bazirana verzija )

Iskompajlirati kernel i module, a nakon toga i instalirati to što je iskompajlirano i na kraju make install stavlja novi kernel automacki u grub ili lilo:

# make all
# make modules_install
# make install

P.S. Posle odabira podrške za Vaš hardware, (xconfig, menuconfig, config) cela konfiguracija kernela je memorisana /usr/src/linux/.config fajlu. Taj fajl će biti sačuvan i kao /boot/config nakon što uradite make install.

Za sve one koje interesuje korak po korak, ovde je prikazano jedno matoro upustvo za 2.4 seriju kernela:


01. /* skinuti kernel */
wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.24.tar.bz2

02. /* postati root */
bash-2.05# su

03. /* kopirati kernel u /usr/src
bash-2.05b# cp linux-2.4.24.tar.bz2 /usr/src

04. bash-2.05b# cd /usr/src

05. /* gde se nalazim!? */
bash-2.05b# pwd
/usr/src

06. bash-2.05b# ls -al
total 29149
drwxr-xr-x 6 root root 264 Jan 6 20:53 .
drwxr-xr-x 18 root root 544 Jan 14 15:29 ..
-rw-r--r-- 1 root root 567 Sep 3 02:12 2.4.22.nat.diff
lrwxrwxrwx 1 root root 12 Jan 6 20:53 linux -> linux-2.4.22
drwxr-xr-x 15 root root 744 Dec 25 22:53 linux-2.4.22
drwxr-xr-x 7 root root 168 Oct 12 21:08 rpm
-rw------- 1 root root 29837818 Jan 6 20:51 linux-2.4.24.tar.bz2
drwxr-xr-x 2 root root 432 Sep 5 00:03 xfs-2.4.22

07. /* otpakovati kernel */
bash-2.05b#tar -xjvf linux-2.4.24.tar.bz2

08. bash-2.05b# ls -al
total 29149
drwxr-xr-x 6 root root 264 Jan 6 20:53 .
drwxr-xr-x 18 root root 544 Jan 14 15:29 ..
-rw-r--r-- 1 root root 567 Sep 3 02:12 2.4.22.nat.diff
lrwxrwxrwx 1 root root 12 Jan 6 20:53 linux -> linux-2.4.22
drwxr-xr-x 15 root root 744 Dec 25 22:53 linux-2.4.22
drwxr-xr-x 15 573 573 712 Jan 8 02:00 linux-2.4.24
-rw------- 1 root root 29837818 Jan 6 20:51 linux-2.4.24.tar.bz2
drwxr-xr-x 7 root root 168 Oct 12 21:08 rpm
drwxr-xr-x 2 root root 432 Sep 5 00:03 xfs-2.4.22

09. /* obrisati link */
bash-2.05b# rm link

10. /* neuen link setzen */
bash-2.05b# ln -s linux-2.4.24/ linux

11. bash-2.05b# ls -al
total 29149
drwxr-xr-x 6 root root 264 Jan 6 20:53 .
drwxr-xr-x 18 root root 544 Jan 14 15:29 ..
-rw-r--r-- 1 root root 567 Sep 3 02:12 2.4.22.nat.diff
lrwxrwxrwx 1 root root 12 Jan 6 20:53 linux -> linux-2.4.24
drwxr-xr-x 15 root root 744 Dec 25 22:53 linux-2.4.22
drwxr-xr-x 15 root root 712 Jan 8 02:00 linux-2.4.24
-rw------- 1 root root 29837818 Jan 6 20:51 linux-2.4.24.tar.bz2
drwxr-xr-x 7 root root 168 Oct 12 21:08 rpm
drwxr-xr-x 2 root root 432 Sep 5 00:03 xfs-2.4.22

12. bash-2.05b# cd linux

13. bash-2.05b# pwd
/usr/src/linux

14. bash-2.05b# make mrproper

15. bash-2.05b# make clean

16. bash-2.05b# make xconfig

17. bash-2.05b# make dep

18. bash-2.05b# make bzImage

19. bash-2.05b# make modules

20. bash-2.05b# make modules_install

21. bash-2.05b# cat arch/i386/boot/bzImage > /boot/vmlinuz.novi

22. bash-2.05b# cp Sytem.map /boot/

23. /* editovati lilo */
bash-2.05b# vim /etc/lilo.conf

24. /* /etc/lilo.conf */
# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
boot = /dev/hda
message = /boot/boot_message.txt
# prompt
timeout = 1200
append = "hdc=ide-scsi"
# Override dangerous defaults that rewrite the partition table:
change-rules
reset
# VESA framebuffer console @ 1400x1050x64k
VGA=828
#
#
# VESA framebuffer console @ 1024x768x256
# vga = 791
# Normal VGA console
# vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# End LILO global section
# Linux bootable partition config begins
image = /boot/vmlinuz.novi # pogledaj korak 21. kako nazoves vmlinuz tako i u lilu mora stojati
root = /dev/hda3 # /* /dev/hda se razlikuje kod svakoga koja je root particija (#original) conf */
label = Linux-2.4.24 # ime kako ce se zvati krenel
 read-only # mora postojati

 image = /boot/vmlinuz
root = /dev/hda2 # orginal
label = Linux-2.4.22
read-only

# Linux bootable partition config ends
other=/dev/hda1
label=Doze
table=/dev/hda

25. bash-2.05b# lilo
Added Linux-2.4.22 *
Added Linux-2.4.24
Added Doze
bash-2.05b#

26. /*primer kako se cuva .config fajl*/
bash-2.05b# mkdir /lib/kernel
bash-2.05b# cd /usr/src/linux/
bash-2.05b# cp .config /lib/kernel/

27. /* novi kernel sredjen portreban reboot */

28. bash-2.05b# reboot

Document Actions

Filed under: