Compile Kernel

From OnnoWiki
Revision as of 10:30, 24 August 2012 by Onnowpurbo (talk | contribs)
Jump to navigation Jump to search

Source code kernel (inti) sistem operasi Linux dapat di ambil secara bebas dari situs http://www.kernel.org. Proses / langkah membuat sistem operasi Linux dengan cara meng-compile kernel dapat di lakukan di sistem operasi linux yang kita operasikan dan menjalankan perintah-perintah berikut.

Jika baru install, ubah password root

$ sudo passwd root
	Password:
	Password:

Masuk sebagai root

$ su -
#

update source

# apt-get update
$ sudo apt-get update


Set supaya /bin/sh menjadi /bin/bash jika di perlukan

# rm -f /bin/sh
# ln -s /bin/bash /bin/sh

Siapkan kernel package

apt-get update
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 \
fakeroot kernel-wedge build-essential makedumpfile libncurses5
apt-get build-dep linux

Copy source code kernel

cd /usr/src
rm -Rf /usr/src/linux
wget http://www.kernel.org/pub/linux/kernel/v3.x/patch-3.5.2.bz2
tar xjf linux-3.5.2.tar.bz2 -C /usr/src
ln -s /usr/src/linux-3.5.2 /usr/src/linux

Compile kernel 3.5 di Linux

cd /usr/src/linux
cp -vi /boot/config-`uname -r` ./.config

Langkah cp /boot/config* dibutuhkan jika kita ingin konfigurasi kernel yang digunakan sama dengan konfigurasi kernel dari system operasi yang sedang kita gunakan. Kita dapat meloncati hal ini dan langsung ke make menuconfig.

make menuconfig
make-kpkg clean

Mungkin akan lebih mudah untuk memaksa compile semua source code melalui perintah

make all

baru di lanjutkan dengan perintah

fakeroot make-kpkg --initrd --append-to-version=-custom kernel-image kernel-headers
cd /usr/src
dpkg -i linux-image-2.6.32.3-custom_2.6.32.3-custom-10.00.Custom_i386.deb 
dpkg -i linux-headers-2.6.32.3-custom_2.6.32.3-custom-10.00.Custom_i386.deb

GRUB di Ubuntu 9.04 ke bawah

Ubah GRUB untuk menambahkan menu untuk booting

vi /boot/grub/menu.lst

Pastikan ada menu untuk booting dari kernel yang baru seperti

title           Ubuntu 9.04, kernel 2.6.29.2-custom
uuid            d0a32d6c-3176-4b92-8cac-6e75acc4348a
kernel          /boot/vmlinuz-2.6.29.2-custom root=UUID=d0a32d6c-3176-4b92-8cac-6e75acc4348a ro quiet splash
initrd          /boot/initrd.img-2.6.29.2-custom
quiet
title           Ubuntu 9.04, kernel 2.6.29.2-custom (recovery mode)
uuid            d0a32d6c-3176-4b92-8cac-6e75acc4348a
kernel          /boot/vmlinuz-2.6.29.2-custom root=UUID=d0a32d6c-3176-4b92-8cac-6e75acc4348a ro  single
initrd          /boot/initrd.img-2.6.29.2-custom

GRUB di Ubuntu 9.10 ke atas

Cara nekad

update-grub

Cara yang lebih elegan - Ubah file

vi /boot/grub/grub.cfg

Isi informasi kernel yang baru

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "Ubuntu, Linux 2.6.32.3-custom" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        set quiet=1
        insmod ext2
        set root=(hd0,6)
        search --no-floppy --fs-uuid --set e2482ccc-1480-4c25-adf8-bc77a255b3b3
        linux   /boot/vmlinuz-2.6.32.3-custom root=UUID=e2482ccc-1480-4c25-adf8-bc77a255b3b3 ro    crashkernel=384M-2G:64M,2G-:128M quiet splash
        initrd  /boot/initrd.img-2.6.32.3-custom
}
menuentry "Ubuntu, Linux 2.6.32.3-custom (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        insmod ext2
        set root=(hd0,6)
        search --no-floppy --fs-uuid --set e2482ccc-1480-4c25-adf8-bc77a255b3b3
        linux   /boot/vmlinuz-2.6.32.3-custom root=UUID=e2482ccc-1480-4c25-adf8-bc77a255b3b3 ro single
        initrd  /boot/initrd.img-2.6.32.3-custom
}
### END /etc/grub.d/40_custom ###

Shutdown dan Reboot komputer

shutdown -r now

Setelah reboot & masuk lagi ke shell lakukan ..

uname -r

Pranala Menarik