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

Ok, so I finally got my new Asus Eee Box B202 with Linux preinstalled, however, I didn’t like the distribution that came installed even for a bit, and I had other plans in mind for this machine…

So 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 this post

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:

r8168
        eth
        "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🙂

12 Responses

  1. Thanks for the easy step-by-step ..

  2. […] Adding a new driver to CentOS/RHEL 5.x initrd.img … « Sameh M. Shaker’s Weblog (tags: linux kickstart tips) […]

  3. Thank you very much! you saved my week -)

  4. Thanks for this.
    I could succesfully update the faulty intel e1000e in rhel6 (scientific linux 6) for the network install initrd.img.
    The driver came from the elrepo

    There is just a difference with redhat6: there is no module.cgz. Each file is gzipped individualy.

    Now network install works fine!

    Thanks again

  5. There is something strange with

    “–make-directories”

    in this line:

    “cd initrd && cpio -i –make-directories < ../initrd.img"

    I think it should start with two hyphens:

    "–make-directories"

    • actually, it’s two dashes –, it’s the silly blog writer i’m using that converted it to that character …
      Thanks for the heads up

  6. When adding to the pci.ids, modules.alias, module-info files, how do you know what to enter? How/where did you get the details for the lines you entered?

  7. […] had to update some initrd used for our PXE infrastructure. I found some blog posts on the web (here and here and here) but none of them were flawless in my case, i then decided to add my point of […]

  8. Hi,

    I know that this is an old post, but this is exactly what i have been looking for.
    I have a problem with the last step involving updating the 3 files – pci.ids, modules.alias, module-info.

    My scenario:
    I have a Dell Workstation with a network card that my Red-hat 5.8 is not supporting, and i want to use my PXE for install. I have found the right Driver to use (I installed from CD and used the driver and it is working) – the network driver is e1000e.

    My question:
    How do i know how to update this 3 files Correctly?
    especially if you take into consideration that this driver was already exists and this is an update for it.

    Thanks in advance🙂

    • Hi Leo,
      Thank you for taking the time reaching out, and thank you for posting back your findings. Greatly appreciated🙂

      Best regards,
      N

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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: