LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Modifying / replacing a kernel module (https://www.linuxquestions.org/questions/linux-general-1/modifying-replacing-a-kernel-module-345750/)

dplazz 07-22-2005 12:29 PM

Modifying / replacing a kernel module
 
I recently created a thread asking for input on how to increase the number of loop devices allowed by the kernel. I ended up find a solution after many hours of trolling forums and newgroups. The solution is to unload the "loop.ko" module (/sbin/./rmmod /lib/modules/2.6.9-11.ELsmp/kernel/drivers/block/loop.ko) and then reloading it with an additional "max_loop=255" parameter (/sbin/./insmod /lib/modules/2.6.9-11.ELsmp/kernel/drivers/block/loop.ko max_loop=255). This works perfectly, even the extra loop devices spawn in /dev. The problem is that everything reverts on reboot. After a reboot, it's back to only allowing 8 loop devices (instead of the 255 I changed it to).

Does anyone know a way that I can modify the loop.ko module, replace the loop.ko module, or add these commands to a startup script to make sure that I have access to all 255 loop devices on the next boot?

bruce ford 07-22-2005 03:14 PM

Quote:

Does anyone know a way that I can modify the loop.ko module, replace the loop.ko module, or add these commands to a startup script to make sure that I have access to all 255 loop devices on the next boot?
How about getting the kernel src, locating the file kernel/drivers/block/loop.c and changing your value there:

Code:

#include <asm/uaccess.h>

#include <linux/loop.h>               

#define MAJOR_NR LOOP_MAJOR

static int max_loop = 8;
static struct loop_device *loop_dev;
static int *loop_sizes;

After recompiling the kernel source, you can replace your module (/lib/modules/2.6.9-11.ELsmp/kernel/drivers/block/loop.ko)
by the newly compiled one.

Or: create a startup skript like (I don't know the exact syntax of the insmod/rmmod cmds in kernel 2.6.x):
Code:

case "$1" in
    start)
        echo -n "Reloading loopback module"
        /sbin/rmmod loop.ko
        /sbin/insmod loop.ko max_loop=255
      ;;
esac

and put it in your /etc/rc.d dir and reference it from an appropriate runlevel dir.

-bruce


All times are GMT -5. The time now is 03:07 PM.