Derwynd's Weblog

Derwynd's Weblog

redhat/centos build kernel rpm

Preparing System

$ yum install gcc make bison ncurses-devel rpm-build

Downloading the kernel source linux-2.6.30.10.tar.gz from http://kernel.org

$ nohup wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.10.tar.gz &

After you have done it, extract to /usr/src

$ tar zxvf linux-2.6.30.10.tar.gz -C /usr/src

enter to /usr/src
create a symlink to source code called linux, do this:

$ cd /usr/src
$ ln -sf linux-2.6.30.10 linux
drwxr-xr-x 3 root root 4096 Jul 16 14:09 kernels
lrwxrwxrwx 1 root root 12 Jul 16 16:18 linux -> linux-2.6.31
drwxr-xr-x 23 root root 4096 Sep 10 2009 linux-2.6.31
drwxr-xr-x 7 root root 4096 Jul 16 14:11 redhat

Copying the stock config into the dir
$ cd /usr/src/linux
$ cp /boot/config-`uname -r` .config

Compiling the kernel
$ cd /usr/src/linux
$ make clean
$ make menuconfig

If you want to add a custom tag that will identify the new kernel (if you want or skip this) , to accomplish this, do that:
I did not enter anything here and skipped this step

* On initial screen, go to General setup —>
* Select Local version – append to kernel release

┌─────────────── Local version – append to kernel release ────────────────┐
│ Please enter a string value. Use the key to move from the input |
│ field to the buttons below it. │
│ ┌─────────────────────────────────────────────────────────────────────┐
│ │ │
│ └─────────────────────────────────────────────────────────────────────┘

With this done, the resulting kernel.rpm will have the tag identifying it.
It is time to customize the kernel configuration to fit with your hardware.

After this quit menuconfig and start the compilation.

While you get out the configuration, you will be asked to save the changes. Answer Yes.

Run make rpm

$ make rpm

The compilation will start, good time to grab a coffee cause this is going to be long
WROTE:…….
/usr/src/redhat/SRPMS/kernel-2.6.30.10-1.src.rpm
/usr/src/redhat/RPMS/x86_64/kernel-2.6.30.10-1.x86_64.rpm

Take a backup of /boot dir for safety

$ tar czvf boot.tgz /boot/ /etc/grub.conf

Installing the new kernel rpm
$ rpm -ivh rpm -ivh /usr/src/redhat/RPMS/x86_64/kernel-2.6.30.10-1.x86_64.rpm
Preparing… ########################################### [100%]
1:kernel ########################################### [100%]

Confirming that alls ok
$ ls /boot
config-2.6.18-128.el5 grub message System.map-2.6.18-128.el5 vmlinux-2.6.30.10.bz2 vmlinuz-2.6.30.10
config-2.6.30.10 initrd-2.6.18-128.el5.img lost+found symvers-2.6.18-128.el5.gz System.map-2.6.30.10 vmlinuz-2.6.18-128.el5

Hmmm no initrd-2.6.30.10.img

To create the dependencies for the modules:

$ depmod 2.6.30.10

Create a new initrd with mkinitrd

$ mkinitrd -v /boot/initrd-2.6.30.10.img 2.6.30.10
Creating initramfs
Looking for deps of module ehci-hcd
Looking for deps of module ohci-hcd
Looking for deps of module uhci-hcd
Looking for deps of module ext3: jbd
Looking for deps of module jbd
Found root device hda2 for LABEL=/
Looking for driver for device hda2
Looking for deps of module ide:m-disk
Looking for driver for device hda3
Looking for deps of module ide:m-disk
Looking for deps of module ips: scsi_mod
Looking for deps of module scsi_mod
Looking for deps of module sd_mod: scsi_mod
Looking for deps of module ata_piix: scsi_mod libata
Looking for deps of module libata: scsi_mod
Looking for deps of module ide-disk
Looking for deps of module dm-mem-cache
No module dm-mem-cache found for kernel 2.6.30.10, aborting.

Opps errors …… Need to fix this
$ echo “DMRAID=no” > /etc/sysconfig/mkinitrd/noraid
$ chmod 755 /etc/sysconfig/mkinitrd/noraid
$ mkinitrd -v /boot/initrd-2.6.30.10.img 2.6.30.10

Creating initramfs
Looking for deps of module ehci-hcd
Looking for deps of module ohci-hcd
Looking for deps of module uhci-hcd
Looking for deps of module ext3: jbd
Looking for deps of module jbd
Found root device hda2 for LABEL=/
Looking for driver for device hda2
Looking for deps of module ide:m-disk
Looking for driver for device hda3
Looking for deps of module ide:m-disk
Looking for deps of module ips: scsi_mod
Looking for deps of module scsi_mod
Looking for deps of module sd_mod: scsi_mod
Looking for deps of module ata_piix: scsi_mod libata
Looking for deps of module libata: scsi_mod
Looking for deps of module ide-disk
Using modules: /lib/modules/2.6.30.10/kernel/drivers/usb/host/ehci-hcd.ko /lib/modules/2.6.30.10/kernel/drivers/usb/host/ohci-hcd.ko /lib/modules/2.6.30.10/kernel/drivers/usb/host/uhci-hcd.ko /lib/modules/2.6.30.10/kernel/fs/jbd/jbd.ko /lib/modules/2.6.30.10/kernel/fs/ext3/ext3.ko /lib/modules/2.6.30.10/kernel/drivers/scsi/scsi_mod.ko /lib/modules/2.6.30.10/kernel/drivers/scsi/sd_mod.ko /lib/modules/2.6.30.10/kernel/drivers/scsi/ips.ko /lib/modules/2.6.30.10/kernel/drivers/ata/libata.ko /lib/modules/2.6.30.10/kernel/drivers/ata/ata_piix.ko
/sbin/nash -> /tmp/initrd.w19233/bin/nash
/sbin/insmod.static -> /tmp/initrd.w19233/bin/insmod
copy from `/lib/modules/2.6.30.10/kernel/drivers/usb/host/ehci-hcd.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/ehci-hcd.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/usb/host/ohci-hcd.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/ohci-hcd.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/usb/host/uhci-hcd.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/uhci-hcd.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/fs/jbd/jbd.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/jbd.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/fs/ext3/ext3.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/ext3.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/scsi/scsi_mod.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/scsi_mod.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/scsi/sd_mod.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/sd_mod.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/scsi/ips.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/ips.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/ata/libata.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/libata.ko’ [elf64-x86-64]
copy from `/lib/modules/2.6.30.10/kernel/drivers/ata/ata_piix.ko’ [elf64-x86-64] to `/tmp/initrd.w19233/lib/ata_piix.ko’ [elf64-x86-64]
Adding module ehci-hcd
Adding module ohci-hcd
Adding module uhci-hcd
Adding module jbd
Adding module ext3
Adding module scsi_mod
Adding module sd_mod
Adding module ips
Adding module libata
Adding module ata_piix

Checking …….

$ ls /boot/initrd-2.6.30.10.img
initrd-2.6.30.10.img

Editing grub

Final phase, it remains only edit the grub.conf to use the new kernel.

Add the lines in and change default to boot with new kernel

title CentOS (2.6.30.10)
root (hd0,0)
kernel /vmlinuz-2.6.30.10 ro root=LABEL=/ rhgb quiet noacpi irqpoll acpi=off
initrd /initrd-2.6.30.10.img

Reboot. and check
$ reboot

After reboot
$ uname -a
Linux localhost.localdomain 2.6.30.10 #1 SMP Sat Jul 17 13:25:46 IST 2010 x86_64 x86_64 x86_64 GNU/Linux

Advertisements

July 17, 2010 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: