Tuesday, August 2, 2016

Kernel Compilation

Kernel Compilation   

Steps to compile kernel - Redhat 9  (download all package from net)

Install dependencies
kernel-source-2.4.20-8.i386.rpm  -------download
binutils-2.13.90.0.18-9.i386.rpm    -------download
glibc-kernheaders-2.4-8.10.i386.rpm    -------download
cpp-3.2.2-5.i386.rpm                      -------download
gcc-3.2.2-5.i386.rpm                    -------download
glibc-2.3.2-11.9.i386.rpm         -------download
libgcc-3.2.2-5.i386.rpm             -------download
glibc-common-2.3.2-11.9.i386.rpm   -------download
glibc-devel-2.3.2-11.9.i386.rpm     -------download

Download separately for graphic menu
ncurses-devel-5.3-4.i386.rpm     -------download
ncurses-5.3-4.i386.rpm                  -------download

Once these all dependencies are installed:
1) Go to /usr/src/linux-2.4/
2) edit Makefile [Top-Level] parameter EXTRAVERSION=-8champu
3) make mrproper [delete the .config] architecture
4) cp /usr/src/linux-2.4/configs/kernel-2.4.18-i686.config [see uname -m] /usr/src/linux-  2.4/.config or simply  or  cp -p configs/kernel-2.4.18-i686.config .config
5) make oldconfig - To update the .config with running kernel parameters
6) make config / make menuconfig (for Text) / make xconfig - make
necessary changes – enable ntfs – disable sound & bluetooth
7) make dep - checks dependecies & construts MAKEFILE.
8) make clean - cleans unwanted files form memory loaded by above
commands.
9) make bzImage - Actual kernel compilation process
10) make modules – Actual KLM compilation process
11) make modules_install #check in /lib/modules/2.4.20-8champu/
12) cp /usr/src/linux-2.4.20-8/arch/i386/boot/bzImage
/boot/vmlinuz-2.4.20-8champu
13) cp /usr/src/linux-2.4.18-14/System.map
/boot/System.map-2.4.20-8champu
14) cp /usr/src/linux-2.4.20-8/.config /boot/config-2.4.20-8champu
[OPTIONAL]
15) mkintrd /boot/initrd-2.4.20-8champu.img 2.4.20-8champu
16) vi /etc/grub.conf #Add the new customized kernel entries
title REDHAT 9champu (customized)
root (hd0,8)
kernel /vmlinuz-2.4.20-8champu ro root=/dev/hda11 rhgb quiet
initrd /initrd-2.4.20-8champu.img
note – hd0,8 for boot partition - (/dev/hda9 -1=hda8) (/de/hda11 is “/”)
17) reboot

How to configure the IP address


At the command prompt type /sbin/ifconfig to see what the IP address is, and other information on your network card.
There are two sections - eth0 and lo.

·         Eth0 is information about your network card. The 2nd line in the eth0 section shows you the IP address assigned to that network card (in this case it's 192.168.1.2).
·         lo is information about the loopback device (we won't go into this here).

Use /usr/sbin/netconfig to configure your network card.
You should get a GUI like this....
If you wish to continue, press ENTER.
You will get a window where you can enter the address you want....
Check Use dynamic if you want your IP address assigned automatically. I recommend leaving it unchecked at this stage.
Type in an IP address
The netmask of 255.255.255.0 should work
Enter the IP address of the gateway you use, if you use one.
Enter the IP address of the DNS nameserver you wish to use.
---------------------------------------------------------------------------------------------------------------------------------------------------
Practice of kernel compilation
[root@localhost root]# ls /boot/
boot.b               kernel.h     module-info-2.4.20-8  vmlinuz
chain.b              lost+found   os2_d.b               vmlinuz-2.4.20-8
config-2.4.20-8      message      System.map
grub                 message.ja   System.map-2.4.20-8
initrd-2.4.20-8.img     --------inited file version
vmlinux-2.4.20-8   ------my kernel version

Kernal dependencies

binutils-2.13.90.0.18-9.i386.rpm     |    cpp-3.2.2-5.i386.rpm                        |   
gcc-3.2.2-5.i386.rpm                         |    kernel-2.4.20-8.src.rpm
glibc-2.3.2-11.9.i386.rpm                 |    kernel-source-2.4.20-8.i386.rpm
glibc-common-2.3.2-11.9.i386.rpm  |   libgcc-3.2.2-5.i386.rpm
glibc-devel-2.3.2-11.9.i386.rpm       |    glibc-kernheaders-2.4-8.10.i386.rpm  

ncurses-devel-5.3-4.i386.rpm  | ncurses-5.3-4.i386.rpm   ---for graphic menu

[root@localhost soft]# rpm -ivh kernel-source-2.4.20-8.i386.rpm
warning: kernel-source-2.4.20-8.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
        gcc >= 2.96-98 is needed by kernel-source-2.4.20-8   -----need gcc


[root@localhost soft]# rpm -ivh gcc-3.2.2-5.i386.rpm
warning: gcc-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
        binutils >= 2.12.90.0.7-1 is needed by gcc-3.2.2-5   ------need binutils, cpp, glibc-devel
        cpp = 3.2.2-5 is needed by gcc-3.2.2-5
        glibc-devel >= 2.2.90-12 is needed by gcc-3.2.2-5

[root@localhost soft]# rpm -ivh binutils-2.13.90.0.18-9.i386.rpm  -----installed dependencies.
warning: binutils-2.13.90.0.18-9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:binutils               ########################################### [100%]

[root@localhost soft]# rpm -ivh cpp-3.2.2-5.i386.rpm    ---------installed dependencies.
warning: cpp-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:cpp                    ########################################### [100%]

[root@localhost soft]# rpm -ivh glibc-devel-2.3.2-11.9.i386.rpm
warning: glibc-devel-2.3.2-11.9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
        kernel-headers is needed by glibc-devel-2.3.2-11.9   ----------need kernel header
        kernel-headers >= 2.2.1 is needed by glibc-devel-2.3.2-11.9

[root@localhost soft]# rpm -ivh glibc-kernheaders-2.4-8.10.i386.rpm—install dependencies.
warning: glibc-kernheaders-2.4-8.10.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:glibc-kernheaders      ########################################### [100%]

[root@localhost soft]# rpm -ivh glibc-devel-2.3.2-11.9.i386.rpm -------installed dependencies
warning: glibc-devel-2.3.2-11.9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:glibc-devel            ########################################### [100%]

[root@localhost soft]#  rpm -ivh gcc-3.2.2-5.i386.rpm  -------installed dependencies
warning: gcc-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:gcc                    ########################################### [100%]

[root@localhost soft]# rpm -ivh kernel-source-2.4.20-8.i386.rpm   ---installed Kernel
warning: kernel-source-2.4.20-8.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:kernel-source          ########################################### [100%]

[root@localhost soft]# rpm -ivh ncurses-devel-5.3-4.i386.rpm  ---installed separately
warning: ncurses-devel-5.3-4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
1:ncurses-devel          ########################################### [100%]


[root@localhost soft]# rpm -ivh ncurses-5.3-4.i386.rpm   ---installed separately
warning: ncurses-5.3-4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
1:ncurses-devel          ########################################### [100%]


[root@localhost soft]# cd /usr/src/linux-2.4   -----------Go to /usr/src/linux-2.4/

[root@localhost linux-2.4]# ls
arch     COPYING          CREDITS  Documentation  fs       init  kernel  MAINTAINERS  mm   README          Rules.make  tmp_include_depends
configs  COPYING.modules  crypto   drivers        include  ipc   lib     Makefile     net  REPORTING-BUGS  scripts

[root@localhost linux-2.4]# vi Makefile   -edit Makefile -------give Kernel Name.
(parameter EXTRAVERSION=-8champu

VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 20
EXTRAVERSION = -8ROCK --------------------change Kernel name ( like – ROCK)
wq!

[root@localhost linux-2.4]# make mrproper [delete the .config] architecture

[root@localhost linux-2.4]# pwd  --------current location
/usr/src/linux-2.4

[root@localhost linux-2.4]# cd configs/  ------go to configs file and copy .config
[root@localhost configs]# ll
total 544
-rw-r--r--    1 root     root        44252 Mar 14  2003 kernel-2.4.20-athlon.config
-rw-r--r--    1 root     root        44253 Mar 14  2003 kernel-2.4.20-athlon-smp.config
-rw-r--r--    1 root     root        53868 Mar 14  2003 kernel-2.4.20-i386-BOOT.config
-rw-r--r--    1 root     root        44438 Mar 14  2003 kernel-2.4.20-i386.config
-rw-r--r--    1 root     root        44379 Mar 14  2003 kernel-2.4.20-i386-smp.config
-rw-r--r--    1 root     root        44291 Mar 14  2003 kernel-2.4.20-i586.config
-rw-r--r--    1 root     root        44278 Mar 14  2003 kernel-2.4.20-i586-smp.config
-rw-r--r--    1 root     root        44402 Mar 14  2003 kernel-2.4.20-i686-bigmem.config
-rw-r--r--    1 root     root        44309 Mar 14  2003 kernel-2.4.20-i686.config
-rw-r--r--    1 root     root        44361 Mar 14  2003 kernel-2.4.20-i686-smp.config
-rw-r--r--    1 root     root        44194 Mar 14  2003 kernel-2.4.20-x86_64.config
-rw-r--r--    1 root     root        44209 Mar 14  2003 kernel-2.4.20-x86_64-smp.config

[root@localhost configs]# cp kernel-2.4.20-i386.config /usr/src/linux-2.4/.config  --copy kernel-2.4.20-i386.config file and .config name given
OR
[root@localhost linux-2.4]# cp -p configs/kernel-2.4.20-i386.config .config   ---

[root@localhost configs]# cd ..  -----back to dir

[root@localhost linux-2.4]# l.  ------check hidden files form Path: /usr/src/linux-2.4
.  ..  .config  --------------------------file copy successfully

[root@localhost linux-2.4]# make oldconfig  -----To update the .config with running kernel parameters

[root@localhost linux-2.4]# make menuconfig------------------make necessary changes
        Select from menu base                (Toot utility )– enable ntfs – disable sound



 [root@localhost linux-2.4]# make dep -checks dependencies & constructs MAKEFILE.(same as ./configure file )

[root@localhost linux-2.4]# echo $?   -----to check command run successful
0
[root@localhost linux-2.4]# make clean -cleans unwanted files form memory loaded by above
commands.   (It’s clean to junk files)

[root@localhost linux-2.4]# l.  -----------------After changes create below updated files
.  ..  .config  .config.old  .depend  .hdepend  .version

[root@localhost linux-2.4]# make bzImage -Actual kernel compilation process  (It’s Create Kernel)   Importance file

[root@localhost linux-2.4]# make modules  - Actual KLM compilation process Importance file  (it’s create kernel drivers)

  
[root@localhost boot]# cd /usr/src/linux-2.4/arch/i386/boot

[root@localhost boot]# ls
bbootsect  bbootsect.o  bbootsect.s  bootsect.S  bsetup  bsetup.o  bsetup.s  bzImage  compressed  install.sh  Makefile  setup.S  tools  video.S

[root@localhost linux-2.4]# make modules_install -#check in /lib/modules/2.4.20-8  2.4.20-8ROCK/   create kernel file

[root@localhost modules]# ls /lib/modules/
2.4.20-8  2.4.20-8ROCK   ----------------------------cheated update kernel name

[root@localhost modules]# cp /usr/src/linux-2.4.20-8/arch/i386/boot/bzImage /boot/vmlinuz-2.4.20-8ROCK   (copy kernel file “bzImage” give vmlinuz-2.4.20-8ROCK file name.)

OR
[root@localhost boot]# cd /usr/src/linux-2.4/arch/i386/boot  -----go to this path

[root@localhost boot]# ls
 bzImage  ----------------------copy this kernel file and paste to /boot/ path and given
updated kernel    2.4.20-8  2.4.20-8ROCK  

[root@localhost boot]# cp bzImage /boot/vmlinuz-2.4.20-8ROCK   ---copy kernel files\

[root@localhost boot]# cp /usr/src/linux-2.4/System.map /boot/System.map-2.4.20-8ROCK

[root@localhost boot]# cp /usr/src/linux-2.4.20-8/.config /boot/config-2.4.20-8ROCK   ----copy manul file of kernel (.config-2.4.20-8ROCK )

[root@localhost boot]# mkinitrd /boot/initrd-2.4.20-8ROCK.img 2.4.20-8ROCK   ----(create initrd file)  (need for mount, dev, ext drivers, etc)  IMP

[root@localhost boot]# ll
root     root        44309 Mar 14  2003 config-2.4.20-8
root     root        36384 Jan 12 15:06 config-2.4.20-8ROCK  ---updated manual file
root     root         1024 Jan 12  2016 grub
root     root          253217 Jan 12  2016 initrd-2.4.20-8.img
root     root          248674 Jan 12 15:21 initrd-2.4.20-8ROCK.img  ----new updated initrd file
root     root          19 Jan 12  2016 System.map -> System.map-2.4.20-8
root     root          520129 Mar 14  2003 System.map-2.4.20-8
root     root         526436 Jan 12 15:12 System.map-2.4.20-8ROCK---updated map file
root     root         3193503 Mar 14  2003 vmlinux-2.4.20-8
root     root         16 Jan 12  2016 vmlinuz -> vmlinuz-2.4.20-8
root     root         1122186 Mar 14  2003 vmlinuz-2.4.20-8
root     root         1103176 Jan 12 15:03 vmlinuz-2.4.20-8ROCK  ----updated KERNEL File
[root@localhost boot]# vi /boot/grub/grub.conf   - Add the new customized kernel entries
  

#boot=/dev/sda
default=1  -----------------------change default
timeout=10  -------------------splash screen display time

splashimage=(hd0,0)/grub/splash.xpm.gz ----------------splash display image
title Red Hat Linux (2.4.20-8)
        root (hd0,0)
        kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ hdc=ide-scsi
        initrd /initrd-2.4.20-8.img

Update kernel entry added in grup.conf file

title Red Hat Linux (2.4.20-8ROCK)
        root (hd0,0)
        kernel /vmlinuz-2.4.20-8ROCK ro root=LABEL=/ hdc=ide-scsi
        initrd /initrd-2.4.20-8ROCK.img

note – hd0,8 for boot partition - (/dev/hda9 -1=hda8) (/de/hda11 is “/”)

 17) reboot

Select 2 kernal

[root@localhost root]# uname -a
Linux localhost.localdomain 2.4.20-8ROCK #1 Tue Jan 12 14:35:56 IST 2016 i686 i686 i386 GNU/Linux

  
Mount pen drive and test

# mount  /dev/sdd  /mnt  ----------mount pen driver to check NTFS enable or not


 Latest version of kernel

2.4.20.8  ------stable version

2.4.21.8   -----beta version

2.4.22.8

3.X  ------latest version
4.X

Always download even number of kernel versions






No comments:

Post a Comment