Thursday, April 12, 2012

How to add kernel module to RHEL/Centos to fix unsupport driver

When you setup RHEL/Centos on Server, may be some driver is missing or not support.
One easy solution is rebuild ISO to add new module. This article may help you.
- Prerequires:
+ RHEL/Centos DVD (or ISO).
+ Kernel module.
- First: Build kernel module.
- Second: Mount DVD to disk and copy entire disk to new location.
mkdir ~/rebuild/ISO
mount /dev/cdrom ~/rebuild/ISO
rsync -a ~/rebuild/ISO ~/rebuild/BUILD
- Third: add module to initrd.img
Copy initrd.img to /tmp and move to this directory, then:
gzip -dc initrd.img > initrd.unc.img
cpio -id < initrd.unc.img
cd modules
zcat modules.cgz | cpio -idvm
Copy module to modules/2.6.18-128.el5/x86_64 ( in case i use 64bit) then repacked:
find 2.6.18-128.el5 | cpio -H newc -ov | gzip -9 -c - > modules.cgz
sync
Edit pci.ids, module-info and modules.dep (if necessary). Then create initrd.img:
cd ..
find . | cpio -H newc -ov | gzip -9 -c - > initrd.img
- Final: replace with your new initrd.img, and move to ~/build/BUILD to rebuild ISO
mkisofs -o ../custom.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul- boot -boot- load-size 4 -boot-info-table -v -r -l -L -T -J -V "CUSTOM.X.X" .