rc.d script to load kernel modules

Doug Barton dougb at FreeBSD.org
Sat Jun 11 22:17:49 UTC 2011


Howdy,

Per discussion on -arch and the svn list about improving boot time and 
stripping down the kernel to just that-which-cannot-be-modularized I 
created the attached script to kldload modules that don't need to be in 
loader.conf. It cut quite a bit of time off my boot, so hopefully it 
will be useful to others as well.

To use it just put everything that is being _load'ed in loader.conf into 
kld_list in rc.conf[.local]. For example, mine has:

kld_list='umass coretemp ichwd linux nvidia if_wpi'

If there is agreement that this is a good direction to go I'll be happy 
to commit this along with the relevant /etc/defaults/rc.conf and 
rc.conf.5 changes.


hth,

Doug

-- 

	Nothin' ever doesn't change, but nothin' changes much.
			-- OK Go

	Breadth of IT experience, and depth of knowledge in the DNS.
	Yours for the right price.  :)  http://SupersetSolutions.com/

-------------- next part --------------
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: kld
# REQUIRE: FILESYSTEMS
# KEYWORD: nojail
# BEFORE: var

. /etc/rc.subr

name="kld"

start_cmd="${name}_start"
stop_cmd=':'

kld_start()
{
	[ -n "$kld_list" ] || return

	local _kld

	echo 'Loading kernel modules:'
	for _kld in $kld_list ; do
		load_kld -e ${_kld}.ko $_kld
	done
}

load_rc_config $name
run_rc_command "$1"


More information about the freebsd-current mailing list