# Working with WITHOUT_MODULES and custom kernels



## attilagyorffy (Aug 7, 2016)

Hi all,

I'm experimenting with a custom kernel configuration for my limited VPS resources. I have been manually copying GENERIC and taking out options and devices manually until I realsied that /etc/make.conf can be used to achieve something similar.

Can someone enlighten me what WITHOUT_MODULES will accept? This is not documented in the make conf man page. I'm also curious to know whether there is a way to exclude different options and devices using a similar config flag instead of having to manually edit the copy of the GENERIC kernel config.

Seems like an exclusion list would be perfect as the kernel changes over time and maintaining a list of exclusions would be more handy than the manual options.

Thanks in advance,

-- Attila


----------



## ondra_knezour (Aug 7, 2016)

Regarding editing of the GENERIC config - you can create your own file, include GENERIC and change only options/flags/whatever you want. See http://www.wonkity.com/~wblock/docs/html/kernelconfig.html https://www.freebsd.org/doc/en/books/handbook/kernelconfig-config.html and config(5).

As I understand it, the WITHOUT_MODULES knob accept path in the src/sys/modules directory, see https://www.freebsd.org/doc/en/books/handbook/kernelconfig-building.html https://lists.freebsd.org/pipermail/freebsd-doc/2007-August/012915.html and https://lists.freebsd.org/pipermail/freebsd-questions/2012-July/243078.html


----------



## attilagyorffy (Aug 7, 2016)

yes, someone over twitter pointed me to that article and have been following that plan. I included GENERIC in my kernel conf and then issued a few 
	
	



```
nodevice
```
 and 
	
	



```
nooption
```
 too. I've excluded sound and wlan devices for example from my config but when I install the newly built kernel to the system using 
`sudo make buildkernel KERNCONF=REWIREMIN` and then `sudo make installkernel KERNCONF=REWIREMIN` I am getting the same amount of files installed under /boot/kernel as GENERIC. These even seem to include wlan and sound objects.

What am I missing?

I've cleared /usr/obj prior to compiling and installing the new kernel, so I'm a bit lost here. Here's my kernel configuration as a reference.


----------



## wblock@ (Aug 7, 2016)

The modules are still built even when not a part of the kernel.  To prevent parts of source from being built at all, see src.conf(5).

I have never tried WITHOUT_MODULES and the man page description in make.conf(5) is kind of vague.


----------



## attilagyorffy (Aug 7, 2016)

I'm just wondering... How come that the file count is significantly in case I use a slimmed down version of GENERIC instead of importing it and applying exclusions afterwards?

The diff is significant between these kernel builds. The first 2 are slim versions of GENERIC, the 3rd (current one) is a kernel built with the exclusion technique mentioned above:


```
attila@cloud ~> ls -la /boot/kernel.old | wc -l
     778
attila@cloud ~> ls -la /boot/kernel.old1/ | wc -l
     778
attila@cloud ~> ls -la /boot/kernel/ | wc -l
    1552
```

I'm puzzled.


----------



## grahamperrin@ (Jul 4, 2021)

Reading this topic alongside <https://forums.FreeBSD.org/threads/81015/post-520451> and subsequent posts



ondra_knezour said:


> … See http://www.wonkity.com/~wblock/docs/html/kernelconfig.html …



– connections time out ∴ <https://web.archive.org/web/2012020...nkity.com/~wblock/docs/html/kernelconfig.html>



ondra_knezour said:


> https://www.freebsd.org/doc/en/books/handbook/kernelconfig-config.html



– redirects to <https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config> where some corrections are required.

Also, <https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-custom-kernel> states:



> … Kernel modules exist in /boot/kernel and may be dynamically loaded into the running kernel using kldload(8). …



– however neither chapter eight of the Handbook, nor the manual page, mentions /boot/modules for the same purpose:


```
% uname -KrU
14.0-CURRENT 1400024 1400024
% pkg provides /boot/modules/drm.ko
Name    : drm-devel-kmod-5.4.92.g20210526
Desc    : DRM modules for the linuxkpi-based KMS components (development version)
Repo    : FreeBSD
Filename: boot/modules/drm.ko

Name    : drm-current-kmod-5.4.92.g20210526
Desc    : DRM modules for the linuxkpi-based KMS components
Repo    : FreeBSD
Filename: boot/modules/drm.ko
%
```

– and so on. 

<https://www.freebsd.org/cgi/man.cgi?query=kldload&sektion=8&manpath=FreeBSD+14.0-current>


----------

