Derwynd's Weblog

Derwynd's Weblog

Building modules for rhel5 kernel

Build modules for kernel instead of building the whole kernel

Download the kernel rpm
$ rpm -ivh kernel-2.6.18-x.x.x.el5.src.rpm
$ cd /usr/src/redhat/SPECS/
$ rpmbuild -bp kernel-2.6.spec

will take some time but less than rebuilding the entire kernel hopefully
$ cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.x86_64
$ cp /boot/config-2.6.18-x.x.x.el5 .config
$ make menuconfig

Here for examplepurpose i’m taking xfs and reiserfs module hopefully it works with whatever you chose
* For xfs/reiserfs make sure to chose xfs and reiserfs as the module
$ make fs/xfs/xfs.ko
In case of error run
$ make SUBDIRS=fs/xfs/ modules
and rerun
$ make fs/xfs/xfs.ko
$ mkdir -p /lib/modules/`uname -r`/kernel/fs/xfs
Copy the module into the /lib/modules/`uname -r`/kernel/fs/xfs
$ cp fs/xfs/xfs.ko /lib/modules/`uname -r`/kernel/fs/xfs
$ make fs/reiserfs/reiserfs.ko
In case of error run
$ make SUBDIRS=fs/reiserfs/ modules
and rerun
$ make fs/reiserfs/reiserfs.ko
$ mkdir -p /lib/modules/`uname -r`/kernel/fs/reiserfs
Copy the module into the /lib/modules/`uname -r`/kernel/fs/reiserfs
$ cp fs/reiserfs/reiserfs.ko /lib/modules/`uname -r`/kernel/fs/reiserfs

Change permissions
$ chmod 744 /lib/modules/`uname -r`/kernel/fs/reiserfs/reiserfs.ko
$ chmod 744 /lib/modules/`uname -r`/kernel/fs/xfs/xfs.ko

insmod the required module
$ insmod /lib/modules/`uname -r`/kernel/fs/reiserfs/reiserfs.ko
$ insmod /lib/modules/`uname -r`/kernel/fs/xfs/xfs.ko
Make entry into /etc/modules.conf
$ echo “install reiserfs /sbin/insmod /lib/modules/2.6.18-x.x.x.el5/kernel/fs/reiserfs/reiserfs.ko ” >> /etc/modules.conf
$ echo “install xfs /sbin/insmod /lib/modules/2.6.18-x.x.x.el5/kernel/fs/xfs/xfs.ko ” >> /etc/modules.conf

$ modprobe reiserfs
$ modprobe xfs
$ depmod -a
Should be done hopefully

Advertisements

January 14, 2010 - Posted by | Uncategorized

5 Comments »

  1. $ cp fs/xfs/xfs.ko /lib/modules/`uname -r`/kernel/fs/reiserfs

    should be

    reiserfs.ko instead of xfs.ko

    Comment by Ren | November 2, 2011 | Reply

  2. It does not boot….

    Scanning and configuring dmraid supported devices
    Scanning logical volumes
    Reading all physical volumes…
    No Volume groups found.
    Activating logical volumes
    Volume group “VolGroup00” not found
    Creating root device.
    Mounting root filesystem.
    mount: could not find filesystem ‘/dev/root’ <– Error
    Setting up other filesystems.
    Setting up new root fs
    setuproot: moving /dev failed: No such file or directory <– Error
    no fstab.sys, mounting internal defaults
    setuproot: error mounting /proc: No such file or directory <– Error
    setuproot: error mounting /sys: No such file or directory <– Error
    Switching to new root and running init.
    unmounting old /dev
    unmounting old /proc
    unmounting old /sys
    switchroot: mount failed: No such file or directory

    Kernel panic – not syncing: Attempted to kill init

    Comment by Van | May 12, 2012 | Reply

    • Can you be more specific on the module being built ….

      Comment by derwynd | May 14, 2012 | Reply

  3. make SUBDIRS=xx/xxx/ modules Always results in ” make *** No rule to make target ‘modules’. stop

    Around every corner there is guaranteed to be another error message to halt the proceedings 😦

    My understanding is that we were making the rule here?? So how to resolve this please

    Comment by Indy | November 22, 2012 | Reply

    • In case of error run
      $ make SUBDIRS=fs/xfs/ modules
      and rerun

      It’s been some time that I’ve tried this …
      But as far as my memory goes if you run the command once more the error should go away …..
      In the end just see if the xxx.ko module is present in the dir that you are trying to build and try doing a insmod on the xxx.ko
      If it wrks copy the xxx.ko to the /lib/modules/`uname -r`/dir
      rmmod and insmod and add line in moules.conf file.

      Comment by derwynd | November 24, 2012 | Reply


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: