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 :)

January 2, 2011

Linux force reboot/shutdown

Filed under: Linux — Tags: , , , , — admin @ 1:53 am

Forcing reboot

Linux is not Windows XP and if reboot fail you usually still connect by SSH and do something. This commands will show you how to remotely hard reboot machine. Hard reboot mean that shutdown scripts will not run and machine reboot immediately without syncing hard disk drives, shutdown applications etc, it’s more like hitting the reset button.

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

This commands enable sysrq and after this calls fast reboot. If you want to force shutdown machine try this.

Force shutdown

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger

Pasted from
This came handy, when I had a server that had some IO error and it can no longer read from disk, only few cached binaries into memory kept it running (kernel, SSHD, bash), I could still access the machine via SSH but can no longer do anything, forcing the reboot as mentioned above was my only resort, and it worked like charm…

« Newer Posts

Powered by WordPress