Kroko Just another WordPress weblog

January 4, 2011

Adding a new driver to CentOS/RHEL 5.x initrd.img

Filed under: Uncategorized — admin @ 8:00 am

I wanted to install CentOS on it (my favorite), using PXE of course since I don’t an external CD/DVD drive…

However, during boot up the kernel wouldn’t recognize the 1Gbit Ethernet interface, so it was unable to retrieve the rest of the setup files…

I found that Realtek has put some drivers as source code on thier site, compiling it to the target kernel (2.6.18-53.el5) was not a problem at all…

I wanted to embed this driver into initrd so the setup would recognize and initialize the interface automatically…

Googling around, I couldn’t find much resources or how-tos, the best one was thispost…

However, he was talking about CentOS/RHEL 4.x, since CentOS/RHEL things have changed just a bit…

So, here’s what I’ve done to include r8168 driver into the CentOS 5.1 initrd.img …

We start with unpacking initrd.img

cd /tftpboot
mv initrd.img initrd.img.gz
gunzip initrd.img.gz
mkdir initrd
cd initrd && cpio -i –make-directories < ../initrd.img

And then extract the archive the holds the kernel modules

cd modules/
mkdir unpacked
gunzip < modules.cgz | (cd /tftpboot/initrd/modules/unpacked && cpio -idv)

Now, we copy the kernel module into the proper location, and then repack the archive

cp /root/r8168-8.011.00/src/r8168.ko unpacked/2.6.18-53.el5/i686/r8168.ko
cd unpacked
find 2.6.18-53.el5 | cpio -ov -H crc | gzip > /tftpboot/initrd/modules/modules.cgz
cd .. && rm -rf unpacked

Now we need to add the meta data required for loading this module, unlike what has been mentioned the post, CentOS/RHEL 5 have this information now spread in 3 files; pci.ids, modules.alias, module-info

In pci.ids, add these lines:

10ec  Realtek Semiconductor Co., Ltd.
8168  RTL8111/8168B Gigabit Ethernet

In modules.alias, add this line:

alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168

In module-info, add this line:

“RTL8111/8168B PCI Express Gigabit Ethernet”

Now let’s repack the initrd.img

cd /tftpboot/initrd
(find . | cpio –quiet -c -o) > ../initrd.img
cd .. && rm -rf initrd
gzip initrd.img
mv initrd.img.gz initrd.img

And we’re done :)

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress