# Kernel build number



## bsduck (May 3, 2022)

Hello,

What does the #0, #1, etc. found in the output of `uname -v` mean, exactly?
I guess it's a kernel build number?

Official builds all seem to be #0.
I currently have `FreeBSD 13.1-STABLE #4 stable/13-n250651-85983255c15`.

I upgraded my system today and went from a `FreeBSD 13.1-STABLE #2` to a `FreeBSD 13.1-STABLE #4`. Given that I interrupted the kernel build once (it was too slow because I forgot to set -j8), I guess the number starts at zero for the first build of a given kernel or branch and increments each time `make buildkernel` is run?

If this is correct, then:

When is that counter reset?
When switching branches (f.e. stable/13 --> stable/14)?
When building a custom kernel instead of GENERIC?

How to manually reset it?


----------



## Alain De Vos (May 3, 2022)

uname -v returns for me no #

```
FreeBSD 13.1-RC5 releng/13.1-n250141-2e9ad6042be MYKERNELOPT
```


----------



## Andriy (May 3, 2022)

I think that a _clean _kernel build should reset that sequence number.


----------



## grahamperrin@ (May 4, 2022)

Andriy said:


> I think that a _clean _kernel build should reset that sequence number.



Thanks, that's probably consistent with what I have here. `#1` at the time of writing. 

I do recall a `make clean` before one of my recent builds (recent weeks). `history` gives me times but not dates: 


```
bectl list -c creation | grep e140d551b78
n255078-e140d551b78-b -      -          309M  2022-04-30 18:28
n255078-e140d551b78-c NR     /          200G  2022-05-01 23:16
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #1 main-n255078-e140d551b78-dirty: Wed Apr 27 22:51:33 BST 2022     root@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1400057 1400057
% su -
Password:
root@mowa219-gjp4-8570p-freebsd:~ # history | grep make\ clean
   544  9:18    make clean
   550  10:00   make clean
  1268  17:50   make clean
  1270  17:50   make clean
  1275  17:51   make clean
  1278  17:52   make clean
  1305  15:29   cd /usr/src/tools/tools/net80211 && make clean && cd wlanstats && make
  1870  3:28    make clean
root@mowa219-gjp4-8570p-freebsd:~ #
```

Re: the fuller list of BEs (below), `n254693-d7696096209-a` was probably my first build after cleaning. d7696096209 was committed 2022-04-12. 


```
% bectl list -c creation
BE                    Active Mountpoint Space Created
n250511-5f73b3338ee-d -      -          4.94G 2021-11-13 15:43
n252381-75d20a5e386-b -      -          6.81G 2022-01-12 23:23
n252450-5efa7281a79-a -      -          6.49G 2022-01-14 19:27
n252483-c8f8299a230-b -      -          4.84G 2022-01-17 14:24
n252505-cc68614da82-a -      -          4.90G 2022-01-18 14:26
n252531-0ce7909cd0b-h -      -          5.71G 2022-02-06 12:24
n252997-b6724f7004c-c -      -          6.17G 2022-02-11 23:07
n253116-39a36707bd3-e -      -          5.66G 2022-02-20 07:03
n253343-9835900cb95-c -      -          1.54G 2022-02-27 14:58
n253776-d5ad1713cc3-b -      -          7.94G 2022-03-18 09:31
n253861-92e6b4712b5-e -      -          7.41G 2022-04-02 16:02
n254268-50e244964e9-d -      -          6.62G 2022-04-09 18:50
n254693-d7696096209-f -      -          1.92G 2022-04-27 17:41
n255078-e140d551b78-b -      -          309M  2022-04-30 18:28
n255078-e140d551b78-c NR     /          200G  2022-05-01 23:16
% ls -hl /usr/src/*.log
-rw-r--r--  1 root  wheel   7.4M 27 Apr 23:10 /usr/src/buildkernel.log
-rw-r--r--  1 root  wheel   3.4M 27 Apr 21:34 /usr/src/buildworld.log
-rw-r--r--  1 root  wheel   163K 28 Apr 01:50 /usr/src/installkernel.log
-rw-r--r--  1 root  wheel   4.7M 28 Apr 03:02 /usr/src/installworld.log
% su -
Password:
root@mowa219-gjp4-8570p-freebsd:~ # history | grep n254693-d7696096209-a
  1456  2:40    bectl destroy n254693-d7696096209-a
  2003  3:08    history | grep n254693-d7696096209-a
root@mowa219-gjp4-8570p-freebsd:~ #
```


----------



## PMc (May 4, 2022)

bsduck said:


> Hello,
> 
> What does the #0, #1, etc. found in the output of `uname -v` mean, exactly?
> I guess it's a kernel build number?
> ...


When the compile directory /usr/src/sys/*/compile/KERNELNAME is deleted/recreated. The counter is probably in there.


bsduck said:


> When switching branches (f.e. stable/13 --> stable/14)?
> When building a custom kernel instead of GENERIC?


Likely that is a different counter then.


bsduck said:


> How to manually reset it?


Find the counter file and change it.



Alain De Vos said:


> uname -v returns for me no #
> 
> ```
> FreeBSD 13.1-RC5 releng/13.1-n250141-2e9ad6042be MYKERNELOPT
> ```


There was an effort about reproducible builds, and it appears the counter is now only present in STABLE and CURRENT.


----------



## JohnnySorocil (Nov 6, 2022)

File is /usr/obj/usr/src/arm64.aarch64/sys/<KERNCONF>/version and it is incremented by command in the last line of /usr/src/sys/conf/newvers.sh


----------

