# trying to build a kernel



## Desreguard (May 31, 2011)

Ok, I have a book called Absolute BSD but it's the first edition and maybe it uses some old commands that aren't revelant to 8.1. According to the book it tells me to move my Generic kernel from /sys/i386/conf to my /usr/src directory and rename it, in my case I called it ServKern. After moving it I edit the file in vi and remove any unwanted drivers that I dont need. Once completed with the editing it tells me to use the config command:

`config ServKern`

But when I do this it just spits out 
	
	



```
Specifiy machine type "e.g. machine i386"
```
Then the book tells me to do a `make depend && make all install` When I run this command it just compiles for a few hours and then compile crashes and spits out a bunch of Error code 1 errors in different directories. 

As far as I understand kernels, building one should be a very straight forward process.
-Copy your GENERIC kernel to your /usr/src directory
- Edit the Generic kernel to your liking and rename it to whatever.
- Compile the new kernel and install it over the GENERIC one.
- Then reboot and it should be using your new kernel. 

I have also tried using a different command: `make buildkernel KERNCONF=ServKern`
But when I tried this it just spits out:


```
Missing kernel configuration files.
```

I use this command while im in my /usr/src directory. Is this not the right command or did I just do it wrong? Do we not use the config command anymore for building kernels? Did I skip a step or something? Is there a different way of doing this for 8.1?

FreeBSD 8.1 installs just fine on my machine which is an old Dell Dimension 4600 single core Pentium 4 2.6 proc, with an Intel 865PE chip set, A simple ATA 80GB Seagate hard drive. An ATA cd-rom. 

Any advice from the experts would be awesome.


----------



## wblock@ (May 31, 2011)

The Handbook shows the somewhat-newer way to create a kernel config file.  The even newer way is to include the GENERIC kernel and override any settings you like.  I have a preliminary article on that: Simplifying FreeBSD Kernel Config Files


----------



## dthomas53 (May 31, 2011)

Desreguard said:
			
		

> As far as I understand kernels, building one should be a very straight forward process.
> -Copy your GENERIC kernel to your /usr/src directory
> - Edit the Generic kernel to your liking and rename it to whatever.
> - Compile the new kernel and install it over the GENERIC one.
> - Then reboot and it should be using your new kernel.



As the previous poster mentioned, the Handbook is the best resource for rebuilding your kernel. But in my experience, it boils down to:


*cd /usr/src/sys/<arch>/conf/*
*cp GENERIC <name_of_your_custom_kernel>*
modify kernel to your liking
*rm -r /boot/kernel.old && cp -rp /boot/kernel /boot/kernel.old*
*cd /usr/src*
*make buildworld KERNCONF=<name_of_your_custom_kernel>*
*make kernel KERNCONF=<name_of_your_custom_kernel>*
*reboot*
*cd /usr/src*
*mergemaster -p*
*make installworld KERNCONF=<name_of_your_custom_kernel>*
*mergemaster*

I've done this countless times now, so (unless I've overlooked something) this should be all you need. 

Out of curiosity, why are you looking to rebuild the kernel?


----------



## SirDice (May 31, 2011)

Step number 4 isn't needed. The same thing is done during the installkernel phase


----------



## carlton_draught (May 31, 2011)

You might like this. I walk through compiling a kernel with the help of folks like UNIXgod and wblock.


----------



## Desreguard (Jun 1, 2011)

Just learning BSD in general. I just like fast boot times, and learing to build firewalls and the like, thanks for the step by step, but I used *make buildkernel KERNCONF=whatever* and *make installkernel KERNCONF=whatever*. What's the difference between yours and what I did?


----------



## SirDice (Jun 1, 2011)

Desreguard said:
			
		

> Whats the difference between yours and what i did?


*make kernel* is the same as *make buildkernel && make installkernel*.


----------



## razixx (Jun 3, 2011)

I highly recommend the 2nd edition of this book.  I've yet to run into an example that hasn't worked and it describes how to properly build a kernel using the handbook method along with the "include the GENERIC kernel" trick.

It sounds like the 1st edition of the book is a bit dated.  I would stick with the handbook and or purchase the 2nd edition


----------

