# Build a new kernel in 8.1



## krilen (Jul 30, 2010)

Hi.

Having problem buildning a new kernel, have followed the handbook and searched this forum with no luck.

uname: 

```
FreeBSD xxxxxxxxxxx 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     
[email]root@mason.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  amd64
```

What I have done:
--------------------------------
`srv# cd /usr/src/sys/i386/conf`
`srv# mkdir /root/kernels`
`srv# cp GENERIC /root/kernels/MYKERNEL`
`srv# ln -s /root/kernels/MYKERNEL`

edited MYKERNEL and remove IPv6

`srv# cd /usr/src`

```
srv# make buildkernel KERNCONF=MYKERNEL
ERROR: Missing kernel configuration file(s) (MYKERNEL).
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
```
What am I doing wrong, what is missing? Can anyone help me to build my first kernel in FreeBSD.

Thanks in advanced
/Krister


----------



## SirDice (Jul 30, 2010)

You are running amd64, why are you copying a i386 kernel config? Copy the GENERIC in /usr/src/sys/amd64/conf/. Your custom kernel config _must_ also be stored in /usr/src/sys/amd64/conf/.


----------



## krilen (Jul 30, 2010)

Thank you, thats what I get for following the handbook 

My kernel is building as we speak.

Thansk again.

/Krister


----------



## jgh@ (Jul 30, 2010)

You are building a custom kernel to only remove ipv6. Sounds like a lot of effort for not much gain to me. Any particular reason you are doing this?


----------



## chrcol (Jul 31, 2010)

why not just do


```
cd /usr/src/sys/amd64/conf
cp GENERIC MYKERNEL
<edit MYKERNEL>
cd /usr/src
make buildkernel KERNCONF=MYKERNEL 
make installkernel KERNCONF=MYKERNEL
```


----------



## UNIXgod (Jul 31, 2010)

You need to alias it away from the conf dir as it would get blown away on make world upgrades.


----------



## fronclynne (Jul 31, 2010)

Unless you're a dev, you needn't back up your source tree, since you can just pull down a new copy when you're restoring your system.  Keeping your custom kernel conf files elsewhere and linking is a nice way to avoid losing them.


----------



## wblock@ (Jul 31, 2010)

fronclynne said:
			
		

> Unless you're a dev, you needn't back up your source tree, since you can just pull down a new copy when you're restoring your system.  Keeping your custom kernel conf files elsewhere and linking is a nice way to avoid losing them.



How would that happen?  I've never kept a kernel config anywhere but in conf, and never had one deleted.  They're outside CVS.  I do back up the conf directory.


----------



## fender0107401 (Aug 1, 2010)

Handbook Chapter 8.


----------



## chrcol (Aug 6, 2010)

UNIXgod said:
			
		

> You need to alias it away from the conf dir as it would get blown away on make world upgrades.



never happened to me in years of using freebsd.

GENERIC gets overwritten sure, but not custom files.

also makeworld doesnt touch the src dir its csup.


----------



## phoenix (Aug 6, 2010)

UNIXgod said:
			
		

> You need to alias it away from the conf dir as it would get blown away on make world upgrades.



No it doesn't, if you use a new name (MYKERNEL, for example).  And, if it did get blown away during a buildworld or a source tree update, a link to an external file wouldn't save it.

The only time a custom kernel config file gets deleted/overwritten is if you name it GENERIC, NOTES, SMP (aka any of the existing files) or you manually delete /usr/src.


----------



## UNIXgod (Aug 6, 2010)

I stand corrected... once again. =) I guess linking it to /root/kernels/ simply makes a nice shortcut to save typing out vi /usr/src/sys/{arch}/conf/MYKERNALCONFIG


----------

