# How can I disable compiling some modules when I compile my kernel?



## tanakorn (Apr 16, 2009)

I want to compile my kernel without compiling some device modules. These devices do not appear in my kernel config file but they are still compiled.

I comment these device source code files in /usr/src/sys/conf/files.i386 but it still compiled.

How can I compile my kernel without compiling the device modules that I do not want?

Thank you.


----------



## DutchDaemon (Apr 16, 2009)

Two ways:

1) build a custom kernel (edit the devices you do not need out of /usr/src/sys/i386/conf/GENERIC and save under a new name, then rebuild the kernel with that new configuration) -> http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html and/or see /usr/src/Makefile (you've done that, I see)

2) make.conf(5) -> 

```
MODULES_OVERRIDE
                   (str) Set to a list of modules to build instead of all of
                   them.
```


```
WITHOUT_MODULES
                   (str) Set to a list of modules to exclude from the build.
                   This provides a somewhat easier way to exclude modules you
                   are certain you will never need than specifying
                   MODULES_OVERRIDE.  This is applied after MODULES_OVERRIDE.
```


----------



## tanakorn (Apr 16, 2009)

For the first way, I tried it already. I found that in my GENERIC does not have that devices but it still compiled the source files. I am trying your second suggestion.

But this makes me confuse that why it still compiled when it does not appear in my GENERIC. And why it still compiled when I comment source files in /usr/src/sys/conf/files.i386

Thank you for help.


----------



## DutchDaemon (Apr 16, 2009)

All modules will always be compiled, whether they are used or not. Only the make.conf settings can alter that behaviour. I don't believe /usr/src/sys/conf/files.i386 is meant to be used in the way you describe.


----------



## tangram (Apr 16, 2009)

You might want to look at NOTES at /usr/src/sys/conf/NOTES. Or you could use LINT to see all options and use make.conf WITHOUT_MODULES to disable the ones you don't want.


----------



## SirDice (Apr 16, 2009)

tanakorn said:
			
		

> For the first way, I tried it already. I found that in my GENERIC does not have that devices but it still compiled the source files. I am trying your second suggestion.


Don't edit GENERIC, make a copy under a different name i.e. MYKERNEL and edit that.


----------



## rtoma (Jul 15, 2009)

Also try 





> man (5) make.conf


 in order to get more options for the build environment.


----------



## SIFE (Sep 29, 2009)

even i specified the modules that i won't be to be compiled with mu CUSTOM kernel i found it istalled with it .
my make.conf :

```
PERL_VER=5.8.8
OVERRIDE_LINUX_BASE_PORT=f9
PERL_VERSION=5.8.8
WITHOUT_MODULES = ciss cxgb_t3fw cmx coda cam mly digi digi_Xr digi_CX digi_CX_PCI digi_EPCX digi_EPCX_PCI digi_Xe digi_Xem dpt 
ipw iwi iwic iwi_bss ipfw ng_ipfw ips ipl ipmi iwi_ibss iwi_monitor snd_als4000 snd_atiixp snd_cmi snd_cs4281 snd_csa 
snd_driver snd_ds1 snd_emu10k1 snd_emu10kx snd_envy24 snd_envy24ht snd_es137x snd_ess snd_fm801 snd_hda snd_maestro 
snd_maestro3 snd_mss snd_neomagic snd_sb16 snd_sb8 snd_sbc snd_solo snd_spicds snd_t4dwave snd_uaudio snd_via8233 
snd_via82c686 snd_vibes snd_ad1816 ucom udf udf_iconv ufm xfs umodem uark uart ubsa ubsec ubser ubtbcmfw ums plip 
vpd bktr wlan_tkip wlan_wep wlan_xauth wpifw wlan_amrr wlan_ccmp wlan_scan_ap wlan_scan_sta wlan wlan_acl zfs 
zlib zyd aue axe bcmfw cdce cue kue ng_ubt rue rum snd_uaudio ubsa ubtbcmfw ucom ucycom udav udbp ufoma uftdi uftdi 
ukbd uplcom ural urio hptiop hptmv hptrr mxge_ethp_z8e mxge_rss_ethp_z8e mpt sym trm aic fbt ng_bt3c ng_btsocket 
ng_ubt ubtbcmfw twe pst mlx mfi mfi_linux mfip ida aac aac_linux ipfw_nat ispfw if_vx if_de if_em if_igb if_ixgb 
if_le if_txp if_age if_ale if_bce if_bfe if_bge if_dc if_et if_fxp if_jme if_lge if_msk if_nfe if_nge if_nve 
if_pcn if_re if_rl if_sf if_sk if_ste if_stge if_ti if_tl if_tx if_vge if_vr if_wb if_xl if_ed if_ex if_ep 
if_fe if_ie if_sn if_xe if_an if_ath if_awi if_ral
```
my CUSTON kernel file :

```
cpu		I686_CPU
ident		CUSTOM
options 	SCHED_ULE		# ULE scheduler
options 	PREEMPTION		# Enable kernel thread preemption
options 	INET			# InterNETworking
options 	SCTP			# Stream Control Transmission Protocol
options 	FFS			# Berkeley Fast Filesystem
options 	SOFTUPDATES		# Enable FFS soft updates support
options 	UFS_ACL			# Support for access control lists
options 	UFS_DIRHASH		# Improve performance on big directories
options 	UFS_GJOURNAL		# Enable gjournal-based UFS journaling
options 	MD_ROOT			# MD is a potential root device
options 	MSDOSFS			# MSDOS Filesystem
options 	CD9660			# ISO 9660 Filesystem
options 	PROCFS			# Process filesystem (requires PSEUDOFS)
options 	PSEUDOFS		# Pseudo-filesystem framework
options 	GEOM_PART_GPT		# GUID Partition Tables.
options 	GEOM_LABEL		# Provides labelization
options 	COMPAT_43TTY		# BSD 4.3 TTY compat [KEEP THIS!]
options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
options 	KTRACE			# ktrace(1) support
options 	STACK			# stack(9) support
options 	SYSVSHM			# SYSV-style shared memory
options 	SYSVMSG			# SYSV-style message queues
options 	SYSVSEM			# SYSV-style semaphores
options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
options 	ADAPTIVE_GIANT		# Giant mutex is adaptive.
options 	STOP_NMI		# Stop CPUS using NMI instead of IPI
options 	AUDIT			# Security event auditing
device		cpufreq
device		eisa
device		pci
device		ata
device		atadisk		# ATA disk drives
device		ataraid		# ATA RAID drives
device		atapicd		# ATAPI CDROM drives
device		atapist		# ATAPI tape drives
options 	ATA_STATIC_ID	# Static device numbering
					# output.  Adds ~128k to driver.
					# output.  Adds ~215k to driver.
device		scbus		# SCSI bus (required for SCSI)
device		ch		# SCSI media changers
device		da		# Direct Access (disks)
device		sa		# Sequential Access (tape etc)
device		cd		# CD
device		pass		# Passthrough device (direct SCSI access)
device		ses		# SCSI Environmental Services (and SAF-TE)
device		atkbdc		# AT keyboard controller
device		atkbd		# AT keyboard
device		psm		# PS/2 mouse
device		kbdmux		# keyboard multiplexer
device		vga		# VGA video card driver
device		splash		# Splash screen and screen saver support
device		sc
device		agp		# support several AGP chipsets
device		pmtimer
device		cbb		# cardbus (yenta) bridge
device		pccard		# PC Card (16-bit) bus
device		cardbus		# CardBus (32-bit) bus
device		sio		# 8250, 16[45]50 based serial ports
device		uart		# Generic UART driver
device		ppc
device		ppbus		# Parallel port bus (required)
device		lpt		# Printer
device		ppi		# Parallel port interface device
device		miibus		# MII bus support
device		sis		# Silicon Integrated Systems SiS 900/SiS 7016
device		cs		# Crystal Semiconductor CS89x0 NIC
device		loop		# Network loopback
device		random		# Entropy device
device		ether		# Ethernet support
device		tun		# Packet tunnel.
device		pty		# Pseudo-ttys (telnet etc)
device		md		# Memory "disks"
device		faith		# IPv6-to-IPv4 relaying (translation)
device		firmware	# firmware assist module
device		bpf
device		pf		# Berkeley packet filter
device		pflog
device		pfsync
options ALTQ
options ALTQ_CBQ         # Class Bases Queuing (CBQ)
options ALTQ_RED         # Random Early Detection (RED)
options ALTQ_RIO         # RED In/Out
options ALTQ_HFSC        # Hierarchical Packet Scheduler (HFSC)
options ALTQ_PRIQ        # Priority Queuing (PRIQ)
options ALTQ_NOPCC       # Required for SMP build
device		uhci		# UHCI PCI->USB interface
device		ohci		# OHCI PCI->USB interface
device		ehci		# EHCI PCI->USB interface (USB 2.0)
device		usb		# USB Bus (required)
device		ugen		# Generic
device		uhid		# "Human Interface Devices"
device		ulpt		# Printer
device		umass		# Disks/Mass storage - Requires scbus and da
device		firewire	# FireWire bus code
device		sbp		# SCSI over FireWire (Requires scbus and da)
device		fwe		# Ethernet over FireWire (non-standard!)
device		fwip		# IP over FireWire (RFC 2734,3146)
device		dcons		# Dumb console driver
device		dcons_crom	# Configuration ROM for dcons
```


----------



## aragon (Sep 29, 2009)

```
WITHOUT_MODULES =
```

Remove the space before the "=".


----------



## SIFE (Sep 30, 2009)

@aragon
i still have the problem .


> WITHOUT_MODULES
> (str) Set to a list of modules to exclude from the build.
> This provides a somewhat easier way to exclude modules you
> are certain you will never need than specifying
> MODULES_OVERRIDE.  This is applied after MODULES_OVERRIDE.


this is what the man make.conf said ,think i have to set MODULES_OVERRIDE too but the goal of WITHOUT_MODULES in this case !


----------



## aragon (Oct 1, 2009)

Is every single module that you've specified still being built?  Or are some being skipped, but not others?


----------



## gnemmi (Oct 1, 2009)

have you tried:


```
WITHOUT_MODULES="list of modules"
```

I've found some old info that suggests that WITHOUT_MODULES= could be set to a list of directories that contains the modules you want to exclude from the kernel compile, like so:


```
WITHOUT_MODULES= linux acpi sound/sound sound/driver/ds1 ntfs
```

those would be the directories found under /usr/src/sys/modules/

I, personally, never tried it though ...


----------



## aragon (Oct 2, 2009)

gnemmi said:
			
		

> ```
> WITHOUT_MODULES= linux acpi sound/sound sound/driver/ds1 ntfs
> ```


I believe that is the problem with SIFE's setup.  One can't specify just the module name.


----------



## gnemmi (Oct 2, 2009)

Yup ... I have that feeling too ..


----------



## SIFE (Oct 5, 2009)

may be like what he did say mr onemmi ,setting full path for modules may work since i am going to disable all wifi ,sound and net card but OVVERIDE_MODULES for now is solution .


----------

