# kernel build - can't omit device



## Pfarthing6 (Jun 25, 2010)

Hey all,

I've followed the steps in the handbook for building a custom kernel to the letter. It's pretty straight forward really. I'm not getting any errors either, so don't know what to look for in the forums.

The skinny is that even though I've specified my own MYKERNEL file with said devices commented out, they still get compiled, still show up in the kernel.

So, I make my own MYKERNEL config and comment out the line:


```
#device ...yada yada...
```

...save it then do a: 

`make buildkernel KERNELCONF=MYKERNEL`

...wait for it...then: 

`make installkernel KERNEL=MYKERNEL`

I reboot, it's fine all is well ...except the devices are still there!

if I do a:
`strings KERNEL | grep <device>`

...a whole lot of entries show up.

If I do a:
`dmesg | grep <device>`

...again, there it is.


Another note is that I'm trying to compile an amd64 arch. The handbook doesn't seem to mention anything but to edit the kernel config in the right arch, and I have.

Just to be sure it's using the right one, as a last ditch effort, I deleted every reference in any file to the device in the /usr/src. I also removed the i386 arch completely. And I also removed the GENERIC config ...all easy to get back after synching the source, just trying to test here.

But now when I try to compile, I get an:

```
ERROR: Missing kernel configuration file(s) (GENERIC).
```

Why would it be looking for GENERIC at all? Should it be looking for MYKERNEL?

So, is there any more complete guide to help with this or any steps missing to "omit" a device from the build that may not be indicated in the guide? Something to do with the amd64?

I've been on this project for 3 days now and it's gotten pretty frustrating.

thanks!


----------



## Pfarthing6 (Jun 25, 2010)

oh snap, figured it out, 2 things:

must use: TARGET_ARCH=amd64 in the both the build and install

typo: KERNELCONF= should be KERNCONF (bad var was just ignored and so I ended up with a GENERIC kernel)

Hope this helps others =)


----------



## SirDice (Jun 25, 2010)

Pfarthing6 said:
			
		

> must use: TARGET_ARCH=amd64 in the both the build and install


This shouldn't be needed. Only if you were to build amd64 on a different architecture.


----------



## fairy (Jun 25, 2010)

there is *nodevice* in config(5) that should disable device even if it's in DEFAULTS (e.g. *isa*)


----------



## Pfarthing6 (Jun 25, 2010)

SirDice said:
			
		

> This shouldn't be needed. Only if you were to build amd64 on a different architecture.



Hmm, maybe you're right. When the make built a GENERIC kernel the last few times, it did default to amd64. But I guess it didn't hurt either =)


----------



## kdemidofff (Jun 26, 2010)

Hint: copy GENERIC to some file open it and replace all "device" with "nodevice" and then replace back on only needed devices
that's ur new kernel config 

make new kernel with 


```
include         GENERIC
ident           YOURKERNELNAME
nomakeoption   DEBUG
makeoptions     NO_MODULES
or
makeoptions    MODULES_OVERRIDE="modulename ... ..."
options ..
options ...
device ..

and all other stuff
nodevice ...
nodevice ...
nodevice ...
nodevice ...
```
all stuff u don't have
like SCSI controlers and unneeded NICs

this way u can end up with unbootable kernel but if u know what devices u need it will work
remember to include device for ur disk controller


for CPU optimizations add 

```
CPUTYPE?=native
and
KERNCONF=YOURKERNELNAME
```
to automate buildworld
to make.conf


----------



## morbit (Jun 27, 2010)

Speaking of kernel config, you generally should move things to modules only if they would not have been loaded on every boot (e.g. You have two NICs, only one driver is loaded at time depending where you are, and you want to preserve laptop battery by using hw.pci.do_power_nodriver=3 in /boot/loader.conf). Drivers compiled in kernel use less memory. (+ with all drivers in modules memory fragmentation occurs).


----------



## kdemidofff (Jun 28, 2010)

that what 
	
	



```
makeoptions     NO_MODULES
```
 do


----------

