TimeLinux1

Wednesday, May 8, 2013

Linux - Compiling a kernel steps:


[root@redhat4 ~]# cd /tmp
[root@redhat4 tmp]# mkdir mskernel
[root@redhat4 tmp]# cd mskernel
[root@redhat4 mskernel]# uname -a
Linux redhat4 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

[root@redhat4 mskernel]# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.12.tar.xz

--2013-05-08 09:56:32--  https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.12.tar.xz
Resolving www.kernel.org... 198.145.20.140, 149.20.4.69
Connecting to www.kernel.org|198.145.20.140|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71001428 (68M) [application/x-xz]
Saving to: “linux-3.8.12.tar.xz”

100%[===========================================================================>] 71,001,428  5.21M/s   in 12s  

2013-05-08 09:56:44 (5.70 MB/s) - “linux-3.8.12.tar.xz” saved [71001428/71001428]


[root@redhat4 mskernel]# tar xvJf linux-3.8.12.tar.xz 
linux-3.8.12/
linux-3.8.12/.gitignore
linux-3.8.12/.mailmap
linux-3.8.12/COPYING
linux-3.8.12/CREDITS
linux-3.8.12/Documentation/
linux-3.8.12/Documentation/.gitignore
linux-3.8.12/Documentation/00-INDEX
linux-3.8.12/Documentation/ABI/
linux-3.8.12/Documentation/ABI/README
linux-3.8.12/Documentation/ABI/obsolete/
linux-3.8.12/Documentation/ABI/obsolete/proc-sys-vm-nr_pdflush_threads
linux-3.8.12/Documentation/ABI/obsolete/sysfs-bus-usb
linux-3.8.12/Documentation/ABI/obsolete/sysfs-class-rfkill
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus
linux-3.8.12/Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra
linux-3.8.12/Documentation/ABI/removed/
linux-3.8.12/Documentation/ABI/removed/devfs
linux-3.8.12/Documentation/ABI/removed/dv1394
linux-3.8.12/Documentation/ABI/removed/ip_queue
linux-3.8.12/Documentation/ABI/removed/o2cb
linux-3.8.12/Documentation/ABI/removed/raw1394
linux-3.8.12/Documentation/ABI/removed/video1394
.....



[root@redhat4 linux-3.8.12]# make menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 ***
 *** Install ncurses (ncurses-devel) and try again.
 ***
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2

To overcome this error, I ran -
[root@redhat4 linux-3.8.12]# yum install ncurses-devel -y
This installed the missing packages and then re-ran menuconfig (see below):


[root@redhat4 linux-3.8.12]# make menuconfig
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig
#
# using defaults found in /boot/config-2.6.32-220.el6.x86_64
#
/boot/config-2.6.32-220.el6.x86_64:555:warning: symbol value 'm' invalid for PCCARD_NONSTATIC
/boot/config-2.6.32-220.el6.x86_64:2567:warning: symbol value 'm' invalid for MFD_WM8400
/boot/config-2.6.32-220.el6.x86_64:2568:warning: symbol value 'm' invalid for MFD_WM831X
/boot/config-2.6.32-220.el6.x86_64:2569:warning: symbol value 'm' invalid for MFD_WM8350
/boot/config-2.6.32-220.el6.x86_64:2582:warning: symbol value 'm' invalid for MFD_WM8350_I2C
/boot/config-2.6.32-220.el6.x86_64:2584:warning: symbol value 'm' invalid for AB3100_CORE
/boot/config-2.6.32-220.el6.x86_64:3502:warning: symbol value 'm' invalid for MMC_RICOH_MMC

The menuconfig option allows gui based kernel configuration (see sample config menus here)

...
Once satisfied, save changes

...

#
# configuration written to .config
#

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.


Then run make..
[root@redhat4 linux-3.8.12]# make
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_64.h
  HOSTCC  arch/x86/tools/relocs
  WRAP    arch/x86/include/generated/asm/clkdev.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/genksyms/genksyms.o

.....
after about 2 hours...
.....

 IHEX    firmware/mts_gsm.fw
  IHEX    firmware/mts_edge.fw
  H16TOFW firmware/edgeport/boot.fw
  H16TOFW firmware/edgeport/boot2.fw
  H16TOFW firmware/edgeport/down.fw
  H16TOFW firmware/edgeport/down2.fw
  IHEX    firmware/edgeport/down3.bin
  IHEX2FW firmware/whiteheat_loader.fw
  IHEX2FW firmware/whiteheat.fw
  IHEX2FW firmware/keyspan_pda/keyspan_pda.fw
  IHEX2FW firmware/keyspan_pda/xircom_pgs.fw
[root@redhat4 linux-3.8.12]#

[root@redhat4 linux-3.8.12]# make modules_install
  INSTALL Documentation/connector/cn_test.ko
  INSTALL Documentation/filesystems/configfs/configfs_example_explicit.ko
  INSTALL Documentation/filesystems/configfs/configfs_example_macros.ko
  INSTALL arch/x86/crypto/ablk_helper.ko
  INSTALL arch/x86/crypto/aes-x86_64.ko
  INSTALL arch/x86/crypto/aesni-intel.ko
  INSTALL arch/x86/crypto/crc32c-intel.ko
  INSTALL arch/x86/crypto/ghash-clmulni-intel.ko
  INSTALL arch/x86/crypto/salsa20-x86_64.ko
  INSTALL arch/x86/crypto/twofish-x86_64.ko
  INSTALL arch/x86/kernel/cpu/mcheck/mce-inject.ko
  INSTALL arch/x86/kernel/microcode.ko
  INSTALL arch/x86/kernel/test_nx.ko
  INSTALL arch/x86/kvm/kvm-amd.ko
  INSTALL arch/x86/kvm/kvm-intel.ko
  INSTALL arch/x86/kvm/kvm.ko
  INSTALL arch/x86/oprofile/oprofile.ko
  INSTALL crypto/ansi_cprng.ko
  INSTALL crypto/anubis.ko
  INSTALL crypto/arc4.ko
  INSTALL crypto/async_tx/async_memcpy.ko
  INSTALL crypto/async_tx/async_pq.ko
  INSTALL crypto/async_tx/async_raid6_recov.ko
.....
  INSTALL /lib/firmware/ti_3410.fw
  INSTALL /lib/firmware/ti_5052.fw
  INSTALL /lib/firmware/mts_cdma.fw
  INSTALL /lib/firmware/mts_gsm.fw
  INSTALL /lib/firmware/mts_edge.fw
  INSTALL /lib/firmware/edgeport/boot.fw
  INSTALL /lib/firmware/edgeport/boot2.fw
  INSTALL /lib/firmware/edgeport/down.fw
  INSTALL /lib/firmware/edgeport/down2.fw
  INSTALL /lib/firmware/edgeport/down3.bin
  INSTALL /lib/firmware/whiteheat_loader.fw
  INSTALL /lib/firmware/whiteheat.fw
  INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw
  INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
  DEPMOD  3.8.12
[root@redhat4 linux-3.8.12]# 

[root@redhat4 linux-3.8.12]# make install
sh /tmp/mskernel/linux-3.8.12/arch/x86/boot/install.sh 3.8.12 arch/x86/boot/bzImage \
System.map "/boot"
[root@redhat4 grub]# 

Then you can cd to /boot dir and verify the new kernel is present there..
[root@redhat4 boot]# cd /boot
[root@redhat4 boot]# ls -lart
total 45631
-rw-r--r--.  1 root root      166 Nov  9  2011 .vmlinuz-2.6.32-220.el6.x86_64.hmac
-rw-r--r--.  1 root root  2312369 Nov  9  2011 System.map-2.6.32-220.el6.x86_64
-rw-r--r--.  1 root root   100943 Nov  9  2011 config-2.6.32-220.el6.x86_64
-rwxr-xr-x.  1 root root  3938800 Nov  9  2011 vmlinuz-2.6.32-220.el6.x86_64
-rw-r--r--.  1 root root   171087 Nov  9  2011 symvers-2.6.32-220.el6.x86_64.gz
drwx------.  2 root root    12288 Jun 19  2012 lost+found
drwxr-xr-x.  3 root root     1024 Jun 19  2012 efi
-rw-r--r--.  1 root root 15558855 Jun 19  2012 initramfs-2.6.32-220.el6.x86_64.img
-rw-------.  1 root root  4301773 Jun 19  2012 initrd-2.6.32-220.el6.x86_64kdump.img
dr-xr-xr-x. 25 root root     4096 Mar  5 08:56 ..
-rw-r--r--.  1 root root  4272784 May  8 11:36 vmlinuz-3.8.12
lrwxrwxrwx.  1 root root       20 May  8 11:36 vmlinuz -> /boot/vmlinuz-3.8.12
-rw-r--r--.  1 root root  2621147 May  8 11:36 System.map-3.8.12
lrwxrwxrwx.  1 root root       23 May  8 11:36 System.map -> /boot/System.map-3.8.12
dr-xr-xr-x.  5 root root     1024 May  8 11:37 .
-rw-r--r--.  1 root root 13406914 May  8 11:37 initramfs-3.8.12.img
drwxr-xr-x.  2 root root     1024 May  8 11:37 grub

[root@redhat4 grub]# cd /boot/grub
[root@redhat4 grub]# ls -lart
total 279
-rw-r--r--. 1 root root   1341 May  6  2010 splash.xpm.gz
-rw-r--r--. 1 root root  13964 Jun 19  2012 xfs_stage1_5
-rw-r--r--. 1 root root  11364 Jun 19  2012 vstafs_stage1_5
-rw-r--r--. 1 root root  12024 Jun 19  2012 ufs2_stage1_5
-rw-r--r--. 1 root root    512 Jun 19  2012 stage1
-rw-r--r--. 1 root root  14412 Jun 19  2012 reiserfs_stage1_5
-rw-r--r--. 1 root root  11956 Jun 19  2012 minix_stage1_5
lrwxrwxrwx. 1 root root     11 Jun 19  2012 menu.lst -> ./grub.conf
-rw-r--r--. 1 root root  13268 Jun 19  2012 jfs_stage1_5
-rw-r--r--. 1 root root  11756 Jun 19  2012 iso9660_stage1_5
-rw-r--r--. 1 root root  11748 Jun 19  2012 ffs_stage1_5
-rw-r--r--. 1 root root  12620 Jun 19  2012 fat_stage1_5
-rw-r--r--. 1 root root  13380 Jun 19  2012 e2fs_stage1_5
-rw-r--r--. 1 root root     63 Jun 19  2012 device.map
-rw-r--r--. 1 root root 125976 Jun 19  2012 stage2
dr-xr-xr-x. 5 root root   1024 May  8 11:37 ..
-rw-------. 1 root root   1172 May  8 11:37 grub.conf
drwxr-xr-x. 2 root root   1024 May  8 11:37 .
[root@redhat4 grub]# 

You can verify that the new kernel is now in the grub.conf:
[root@redhat4 grub]# vim grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (3.8.12)
        root (hd0,0)
        kernel /vmlinuz-3.8.12 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-3.8.12.img
title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img
~                                                


And thats it.
There is tons of useful links on the net eg: this one at wikihow





No comments:

Post a Comment