FreeBSD > How to load device driver (module) automatically every time system comes up?

by on December 1, 2004 · 5 comments· LAST UPDATED December 1, 2004

in

1. Check if your module exists or not in /boot/defaults/loader.conf file

2. If it exists then open file /boot/loader.conf and add entry in it. Do not add or modify /boot/defaults/loader.conf file. If entry does not exist then read step # 4.

3. Reboot system to see to take effect..

For example, we want to load NTFS file system driver everytime our FreeBSD box comes up. Here is procedure:

a) Find if ntfs module exist or not

grep -i "ntfs" /boot/defaults/loader.conf
ntfs_load="NO" # NTFS

b) We got above output i.e. module exists copy that line and paste it to /boot/loader.conf file:
vi /boot/loader.conf
ntfs_load="YES" # NTFS added by Vivek on fbsdx.test.com on dec07-04

c) Reboot system to see changes.

d) When system comes up type kldstat to see ntfs module is loaded or not.
kldstat

4) Ok so you don’t find entry then add module (this only required for 3rd party module or your own module) using:

a) Open /boot/loader.conf and add following lines to it, let say your module name is foo:

foo_load="YES" # loads module "foo"
foo_name="realname" # uses "realname" instead of "foo"
foo_type="type" # passes "-t type" to load
foo_flags="flags" # passes "flags" to the module
foo_before="cmd" # executes "cmd" before loading the module
foo_after="cmd" # executes "cmd" after loading the module
foo_error="cmd" # executes "cmd" if load fails

b) Reboot system

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 5 comments… read them below or add one }

1 Anonymous September 25, 2005 at 5:39 pm

foo_load=”YES” # loads module “foo”
foo_name=”realname” # uses “realname” instead of “foo”
foo_type=”type” # passes “-t type” to load
foo_flags=”flags” # passes “flags” to the module
foo_before=”cmd” # executes “cmd” before loading the module
foo_after=”cmd” # executes “cmd” after loading the module
foo_error=”cmd” # executes “cmd” if load fails

Reply

2 cyberciti September 25, 2005 at 10:01 pm

Thanks! I have updated text :)

Reply

3 neohiren November 12, 2006 at 12:31 pm

dear all . i m newbie to linux i want to know how do is set up a nat router on linux redhat fedora to forward all the traffic towards clients ,and how can i bind/block the clients via ip address

Reply

4 nixCraft November 12, 2006 at 12:45 pm

@neohiren,

Try following urls:
http://www.cyberciti.biz/tips/linux-as-router-for-dsl-t1-line-etc.html

If you have specific questions try our forum to get more personalized free tech support http://forums.cyberciti.biz/

Reply

5 Misbah Naveed December 5, 2007 at 4:57 am

hi
i am newbie to linux.i am using redhat enterprise with kernel-2.6.9-42 and used this module usbat02-2.6-0.5.0 but didnot no work maybe i did not used it correctly.
I did the following steps:
1. I downloaded the source rpm for kernel 2.6.9-42.EL and rebuild it.
2. I patch the file present in usbat02-2.6-0.5.0/patch/usb-integration.patch.
3. replace the exixting usb.c and usb.h with the usbat02-2.6-0.5.0’s usb.c and usb.h.
4. make menuconfig and select the option of USBAT/ support from USB mass storage option.
5. The setting are saved in new kernel and gave it the name usbat-2.6.9
6. Then use the command “make modules modules_install”.
7. run “make install”.
8. modprobe usb_storage
9. on demesg i got a meeage that i m sending u as attached file. named Error-old.doc
Should i do the steps 6 and 7 in new kernels? if i do these steps in new kernel usbat-2.6.9 ,the dmesg gives the detail that i couldnot understand attatched file with name error.doc.
also system configure the USB flash automatically i am confused how would i know that i have installed the new driver .
Using lsmod shows usb_storage with 0 before plugging the flash. and after plugging it turns to 1. what it means
pls help me i am so confused how would i know that new module is loaded in my system
waiting 4 reply

Reply

Leave a Comment

Previous post:

Next post: