# Custom kernel build  for 8.2-RC3



## Kris (Feb 16, 2011)

Hello to all 

Have:

`uname-a`

```
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 # 1: Mon Feb 14 20:20:52 EET 2011 [email]root@gw-151-20.cnm.local[/email]: / 
usr/src/sys/amd64 / compile / GENERIC amd64
```

I want to recompile the kernel myself.


```
cd / usr/src/sys/amd64/conf /
[root @ gw-151-143 / usr/src/sys/amd64/conf] #
[root @ gw-151-143 / usr/src/sys/amd64/conf] # config AMD64_IPFW
Kernel build directory is ../compile/AMD64_IPFW
Don't forget to do `` make cleandepend & & make depend''
[root @ gw-151-143 / usr/src/sys/amd64/conf] # cd ../compile/AMD64_IPFW
[root @ gw-151-143 / usr/src/sys/amd64/compile/AMD64_IPFW] # make cleandepend & & make depend $ $ make & & make install
```

Reload
`uname-a`

```
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 # 1: Mon Feb 14 20:20:52 EET 2011 [email]root@gw-151-20.cnm.local[/email]: / 
usr/src/sys/amd64 / compile / GENERIC amd64
```

The file AMD64_IPFW

```
ident AMD64_IPFW
```

Technology type

```
make buildkernel KERNCONF = AMD64_IPFW
make installkernel KERNCONF = AMD64_IPFW
```

Also tried.

Someone tell me what to do .....:stud


----------



## Kris (Feb 16, 2011)

And in the process, such a nice looking line


```
>>> Kernel build for AMD64_IPFW completed on Wed Feb 16 01:38:46 EET 2011
```

Immediately do

`make installkernel KERNCONF = AMD64_IPFW`

Reboot and get

```
[root @ gw-151-143 / usr / home / kris] # uname-a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 # 1: Mon Feb 14 20:20:52 EET 2011 [email]root@gw-151-20.cnm.local[/email]: / 
usr/src/sys/amd64 / compile / GENERIC amd64
```

Word GENERIC - this is a global variable or something?


----------



## kisscool-fr (Feb 16, 2011)

Hi,

You should read the FreeBSD Handbook and specifically this page Building and Installing a Custom Kernel.


----------



## SirDice (Feb 16, 2011)

Kris said:
			
		

> I want to recompile the kernel yourself.
> 
> ```
> cd / usr/src/sys/amd64/conf /
> ...


This is a really old and unsupported way of doing it. This went out the window sometime during the 4.x era.


----------



## DutchDaemon (Feb 16, 2011)

And can you do something about the weird whitespace everywhere? It's hard to see whether you are making mistakes or that you're copy-pasting weird stuff.


----------



## Kris (Feb 16, 2011)

I've already read this page. But after a successful build and install of kernel its name is Generic.

I am trying cvsup my /usr/src/. I am clearing /usr/obj before building kernel. 

All stages of compiling and instalation of kernel - over handbook. But nothing. My kernel name after reboot - GENERIC.


----------



## Kris (Feb 16, 2011)

Ok. What I am doing.


```
cp /sys/amd64/conf/GENERIC AMD64_IPFW
rm -rf /usr/obj/*

cd /usr/src/

make buildkernel KERNCONF=AMD64_IPFW
make installkernel KERNCONF=AMD64_IPFW

reboot
```
BUT after reboot

```
uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     [email]root@gw-151-
20.cnm.local[/email]:/usr/src/sys/amd64/compile/GENERIC  amd64
```


----------



## Kris (Feb 16, 2011)

Sorry first

`cp /sys/amd64/conf/GENERIC /sys/amd64/conf/AMD64_IPFW`


----------



## jalla (Feb 16, 2011)

What's the output of 

```
sysctl kern.bootfile
```

Are you somehow booting from a non-standard path?

(While your way of compiling is no longer preferred, I do this myself occationally and has never seen it to fail. The downside is that you have to manually make a backup of /boot/kernel if you want it).


----------



## SirDice (Feb 16, 2011)

Change the ident line in your custom kernel config.


----------



## Kris (Feb 16, 2011)

My kern.bootfile


```
[root@gw-151-143 /etc/ipfw]# sysctl kern.bootfile
kern.bootfile: /boot/kernel/kernel
```

My ident in custom kernel


```
[root@gw-151-143 /etc/ipfw]# cat /sys/amd64/conf/AMD64_IPFW|grep ident
ident           AMD64_IPFW
```

No, nothing ... standart boot configuration ...


----------



## SirDice (Feb 16, 2011)

Make sure everything is cleaned out correctly.

`# cd /usr/src && make clean`

Then start over using the proper way.


----------



## Kris (Feb 16, 2011)

Ok.
I am doing


```
cd /usr/src && make clean

make buildkernel KERNCONF=AMD64_IPFW
make installkernel KERNCONF=AMD64_IPFW

reboot
```
And nothing


```
[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     [email]root@gw-151-
20.cnm.local[/email]:/usr/src/sys/amd64/compile/GENERIC  amd64
```

I thought perhaps version of binary files differ from the version of the kernel.
But no.


```
[root@gw-151-143 /usr/home/kris]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, stripped
```

I am already out of ideas ....


----------



## SirDice (Feb 16, 2011)

Can you look at the timestamp on the /boot/kernel/kernel file? I have a feeling your installkernel actually fails somewhere and isn't overwriting the kernel.

Are there any errors when doing installkernel?


----------



## Kris (Feb 16, 2011)

```
[root@gw-151-143 /usr/home/kris]# ls -la /boot/kernel/kernel
-r-xr-xr-x  1 root  wheel  10440897 Feb 16 16:30 /boot/kernel/kernel
```

Its my correct time at Ukraine


----------



## Kris (Feb 16, 2011)

```
Kernel install log

--------------------------------------------------------------
>>> Installing kernel
--------------------------------------------------------------
cd /usr/obj/usr/src/sys/AMD64_IPFW;  MAKEOBJDIRPREFIX=/usr/obj  MACHINE_ARCH=amd64  MACHINE=amd64  CPUTYPE=   
GROFF_BIN_PATH=/usr/obj/usr/src/tmp/legacy/usr/bin  GROFF_FONT_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/groff_font  
GROFF_TMAC_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/tmac 
PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/usr/games:/usr/obj/usr/src/tmp/usr/sb
in:/usr/obj/usr/src/tmp/usr/bin:/usr/obj/usr/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin  make KERNEL=kernel install
thiskernel=`sysctl -n kern.bootfile` ;  if [ ! "`dirname "$thiskernel"`" -ef /boot/kernel ] ; then  chflags -R noschg /boot/kernel ;  rm -rf 
/boot/kernel ;  else  if [ -d /boot/kernel.old ] ; then  chflags -R noschg /boot/kernel.old ;  rm -rf /boot/kernel.old ;  fi ;  mv /boot/kernel 
/boot/kernel.old ;  sysctl kern.bootfile=/boot/kernel.old/"`basename "$thiskernel"`" ;  fi
mkdir -p /boot/kernel
install -p -m 555 -o root -g wheel kernel /boot/kernel
install -p -m 555 -o root -g wheel kernel.symbols /boot/kernel
cd /usr/src/sys/modules; MAKEOBJDIRPREFIX=/usr/obj/usr/src/sys/AMD64_IPFW/modules KMODDIR=/boot/kernel DEBUG_FLAGS="-g" MACHINE=amd64 
KERNBUILDDIR="/usr/obj/usr/src/sys/AMD64_IPFW" SYSDIR="/usr/src/sys" make  install
===> aac (install)
install -o root -g wheel -m 555   aac.ko /boot/kernel
install -o root -g wheel -m 555   aac.ko.symbols /boot/kernel
===> accf_data (install)
install -o root -g wheel -m 555   accf_data.ko /boot/kernel
install -o root -g wheel -m 555   accf_data.ko.symbols /boot/kernel
===> accf_dns (install)
.................
..................
===> zlib (install)
install -o root -g wheel -m 555   zlib.ko /boot/kernel
install -o root -g wheel -m 555   zlib.ko.symbols /boot/kernel
kldxref /boot/kernel
```


----------



## DutchDaemon (Feb 16, 2011)

Kris, *format your posts!*


----------



## SirDice (Feb 16, 2011)

Is there anything in /etc/make.conf or /etc/src.conf that might interfere?


----------



## Kris (Feb 16, 2011)

Nothing wrong


```
[root@gw-151-143 /usr/src]# cat /etc/make.conf
# added by use.perl 2002-01-01 03:03:08
PERL_VERSION=5.8.9
[root@gw-151-143 /usr/src]# cat /etc/src.conf
cat: /etc/src.conf: No such file or directory
[root@gw-151-143 /usr/src]#
```


----------



## phoenix (Feb 16, 2011)

What happens if you remove the underscore from the kernel name, install it to a separate directory, and then tell the system to boot from that directory?


```
# cd /usr/src/sys/amd64/conf
# mv AMD64_IPFW MYKERNEL
# ee MYKERNEL
<set ident line to MYKERNEL>
# cd /usr/src
# make cleanworld
# make KERNCONF=MYKERNEL buildkernel
# make KERNCONF=MYKERNEL KODIR=/boot/MYKERNEL installkernel
<check the output to make sure it's installing to [file]/boot/MYKERNEL/[/file]
# nextboot -k MYKERNEL
# shutdown -r now
```
It should boot using /boot/MYKERNEL/kernel.  Check the sysctl to make sure.  And then check the output of uname(1).

If that works, then rename /boot/kernel to /boot/GENERIC and rename (or copy) /boot/MYKERNEL to /boot/kernel and reboot to make it permanent.


----------



## Kris (Feb 16, 2011)

I did everything as you wrote step by step.
but


```
[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64
[root@gw-151-143 /usr/home/kris]# sysctl -a|grep kernel.boot
[root@gw-151-143 /usr/home/kris]# sysctl -a|grep kernel
kern.bootfile: /boot/kernel/kernel
kern.module_path: /boot/kernel;/boot/modules
```

I do not know what to think .... This poltergeist ..... How can this be?


----------



## phoenix (Feb 16, 2011)

What's in your /boot/loader.conf file?


----------



## DutchDaemon (Feb 16, 2011)

The kernel basically hasn't been recompiled since the first post in this topic. 

Post #1

```
#1: Mon Feb 14 20:20:52 EET 2011
```

Post #21

```
#1: Mon Feb 14 20:20:52 EET 2011
```


----------



## Kris (Feb 16, 2011)

About loader.conf


```
[root@gw-151-143 /usr/home/kris]# cat /boot/loader.conf
geom_mirror_load=YES
if_em_load="YES"
if_bge_load="YES"
```

About hasn't been recompiled


```
[root@gw-151-143 /usr/home/kris]# date
Wed Feb 16 23:45:09 EET 2011
[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64
[root@gw-151-143 /usr/home/kris]#
```

Yes it's true. But why???? After all, I see the process of compiling the kernel, see the installation process according to the parameters in the make commands.
After rebooting the impression that nothing happened ....


----------



## DutchDaemon (Feb 17, 2011)

It's like it doesn't end up in /boot/kernel/kernel at all. Maybe try a find(1) on files called kernel (initially) in /boot and /usr?


----------



## Kris (Feb 17, 2011)

Info about find:


```
[root@gw-151-143 /usr/home/kris]# df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
/dev/mirror/gm0s1a    284G     56G    205G    21%    /
devfs                 1.0K    1.0K      0B   100%    /dev
```


```
[root@gw-151-143 /usr/home/kris]# find / -name kernel
/boot/kernel
/boot/kernel/kernel
/boot/kernel.old/kernel
/boot/MYKERNEL/kernel
/usr/src/contrib/ntp/kernel
/usr/obj/usr/src/sys/MYKERNEL/kernel
/usr/ports/net/ntp/work/ntp-4.2.4p7/kernel
```


```
[root@gw-151-143 /usr/home/kris]# sysctl -a|grep kernel
kern.bootfile: /boot/kernel/kernel
kern.module_path: /boot/kernel;/boot/modules
[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64
```


----------



## DutchDaemon (Feb 17, 2011)

What is the timestamp of /boot/kernel/kernel? Does it correspond with the *uname* time? If you used what Phoenix advised in post #20, your updated kernel lives in /boot/MYKERNEL/, so it needs to be moved to /boot/kernel/ or it will only be used once, of course..


----------



## Kris (Feb 17, 2011)

Ok. I am doing:


```
[root@gw-151-143 /usr/home/kris]# ls -la /boot/kernel/kernel
-r-xr-xr-x  1 root  wheel  10440897 Feb 16 16:30 /boot/kernel/kernel

[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-
20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64

[root@gw-151-143 /usr/home/kris]# ls -la /boot/kernel/kernel
-r-xr-xr-x  1 root  wheel  10440897 Feb 16 16:30 /boot/kernel/kernel

[root@gw-151-143 /usr/home/kris]# ls -la /boot/MYKERNEL/kernel
-r-xr-xr-x  1 root  wheel  10440897 Feb 16 19:45 /boot/MYKERNEL/kernel

[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-
20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64

[root@gw-151-143 /usr/home/kris]# rm -rf /boot/kernel

[root@gw-151-143 /usr/home/kris]#

[root@gw-151-143 /usr/home/kris]#

[root@gw-151-143 /usr/home/kris]#

[root@gw-151-143 /usr/home/kris]# mv /boot/MYKERNEL /boot/kernel

[root@gw-151-143 /usr/home/kris]# ls -la /boot/kernel
kernel/     kernel.old/

[root@gw-151-143 /usr/home/kris]# ls -la /boot/kernel/kernel
-r-xr-xr-x  1 root  wheel  10440897 Feb 16 19:45 /boot/kernel/kernel

[root@gw-151-143 /usr/home/kris]# reboot
```

AND after reboot


```
[root@gw-151-143 /usr/home/kris]# uname -a
FreeBSD gw-151-143.cnm.local 8.2-RC3 FreeBSD 8.2-RC3 #1: Mon Feb 14 20:20:52 EET 2011     root@gw-151-
20.cnm.local:/usr/src/sys/amd64/compile/GENERIC  amd64
```


----------



## DutchDaemon (Feb 17, 2011)

Kris said:
			
		

> I am trying cvsup my /usr/src/. I am clearing /usr/obj before building kernel.



This is actually making me wonder: can one remove /usr/obj and then only build and install a kernel _without_ first building the world? 

I myself _either_ do a full world/kernel build, _or_ a rebuild/reinstall of the kernel based on an already existing and filled /usr/obj. 

I don't think I've ever removed /usr/obj and built/installed a kernel without a world. ..

This may be why nothing ever gets updated, though I don't quite see why or why not. I guess you should try a full build (buildworld, buildkernel, installkernel, installwordl) run.

This is what I use for that:


```
(check out or update the source tree if you like)

# cd /usr/src
# make cleanworld && make cleandir
# rm -rf /usr/obj
# make -j 4 buildworld
# make -j 4 buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL DESTDIR=/boot/kernel.NEW
# nextboot -k kernel.NEW/boot/kernel
# mergemaster -p

Reboot in single-user mode

# make installworld
# make delete-old
# mergemaster -U -i

Reboot.

You must run [B]make delete-old-libs[/B] from [B]/usr/src[/B] after the reboot.

You must also move the working kernel to its proper and final location when everything boots ok, i.e.
remove /boot/kernel and then move /boot/kernel.NEW/boot/kernel to /boot/
```


----------



## Kris (Feb 17, 2011)

Thank you very much. 
The Problem is SOLVED.

Problem was that at the time of building and installing the kernel on my system was DEGRADED gmirror. While at the same time, both the hard drives were connected to the computer.

I do not know why, but all this time, the system for some reason at the time of loading look data from the second removed from the gmirror HDD.

Never make and do not install the kernel on the degraded gmirror if both hard drives connected to the system.

All thanks for the help !!!


----------



## DutchDaemon (Feb 18, 2011)

Yeah, that was my next suggestion! (jk) ...


----------

