# /usr/src updating #git pull, how to get the patch level installed?



## HL1234 (Dec 11, 2022)

Hello,
I have searching a long time, but have nothing found in the man pages and with Google. 

Before updating everything, I can do
`git branch`. It shows me:
* releng/13.1
But I have `uname -r` --> 13.1-RELEASE-p3; that means version 13.1 with patch level 3

With what `git` command can I identify, which patch level are in the sources of /usr/src ?

And with what `git` command can I identify, which patch level are actual in the online sources before I do an update of my local /usr/src sources?
Thanks!


----------



## driesm (Dec 11, 2022)

Here you see a commit where the patch level is bumped. Inspecting the version in sys/conf/newvers.sh will give you the patch level of the checked-out tree.


----------



## SirDice (Dec 12, 2022)

HL1234 said:


> But I have `uname -r` --> 13.1-RELEASE-p3; that means version 13.1 with patch level 3




```
dice@case:~ % freebsd-version -urk
13.1-RELEASE-p3
13.1-RELEASE-p3
13.1-RELEASE-p5
```
P4 and p5 solved issues in userland only. So the kernel hasn't been updated (it didn't need to be patched).

If you build from source, the kernel would get rebuild and would show p5 too. This version string is baked into the kernel at compile time.


----------



## HL1234 (Dec 12, 2022)

SirDice said:


> ```
> dice@case:~ % freebsd-version -urk
> 13.1-RELEASE-p3
> 13.1-RELEASE-p3
> ...


I think this is not correct. I have done a
`freebsd-update fetch` and it has shown me also kernel files *.ko to update. But I have this output not saved to show you.


----------



## HL1234 (Dec 12, 2022)

driesm said:


> Here you see a commit where the patch level is bumped. Inspecting the version in sys/conf/newvers.sh will give you the patch level of the checked-out tree.


I suppose there is no single git command to get this information, because of the kind how the repository keeps branch information? Am I right?


----------



## Phishfry (Dec 12, 2022)

HL1234 said:


> it has shown me also kernel files *.ko to update.


These are dynamically loadable kernel modules.
Not 'the kernel'.


----------



## HL1234 (Dec 12, 2022)

Phishfry said:


> These are dynamically loadable kernel modules.
> Not 'the kernel'


Will that change the files from /boot/kernel into /boot/kernel.old or just exchange the *.ko files in /boot/kernel directory?
Can this *.ko files are very different, if I has build an own kernel with `make buildkernel installkernel`?


----------



## Alain De Vos (Dec 12, 2022)

As far as i know when you do make installkernel ,
1./boot/kernel.old is removed
2./boot/kernel is renamed to /boot/kernel.old
3.The new kernel is installed in /boot/kernel

The bootloader loads /boot/kernel by default.


----------



## Phishfry (Dec 12, 2022)

Exactly.
My point about the kernel modules are they may be patched by freebsd-update and kernel patch level would stay the same. The modules are auxiliary files..


----------



## SirDice (Dec 13, 2022)

I don't have a p3 system anymore to show you, but I'm pretty sure p4 and p5 didn't have updates for kernel modules. If there was an update to one of the modules the whole kernel, modules and all would get patched (which is what happened with p3; https://www.freebsd.org/security/advisories/FreeBSD-EN-22:26.cam.asc).

P4 and p5 did update /rescue though, you may have confused this with a kernel update.


----------



## HL1234 (Dec 13, 2022)

I have it now installed with `freebsd-update install`. Result:
the installed and running kernel has: 13.1-RELEASE-p3.
the userland has 13.1-RELEASE-p5

`freebsd-version -ukr`
13.1-RELEASE-p3
13.1-RELEASE-p3
13.1-RELEASE-p5
/boot/kernel is go to /boot/kernel.old

I think I will now update the /usr/src tree and will build and install a new /kernel


----------



## SirDice (Dec 13, 2022)

HL1234 said:


> I think I will now update the /usr/src tree and will build and install a new /kernel


Why? Kernel is supposed to have p3 as your freebsd-version(8) shows.


----------



## HL1234 (Dec 13, 2022)

Alain De Vos said:


> As far as i know when you do make installkernel ,
> 1./boot/kernel.old is removed
> 2./boot/kernel is renamed to /boot/kernel.old
> 3.The new kernel is installed in /boot/kernel
> ...


before reboot you can test the new kernel. `mv /boot/kernel /boot/kernel.tst` and . `mv /boot/kernel.old /boot/kernel` and then:
`nextboot -k /boot/kernel.tst`
or another solution if there are boot problems with a new kernel (without the movings above):
On the console, if the loader start press [Space], an then the command
`OK#boot kernel.old`            //OK# it's the Bootloader-Prompt


----------



## HL1234 (Dec 13, 2022)

SirDice said:


> Why? Kernel is supposed to have p3 as your freebsd-version(8) shows.


I think me to remember that I had read that kernel and the userland should be in sync.


----------



## SirDice (Dec 13, 2022)

HL1234 said:


> I think me to remember that I had read that kernel and the userland should be in sync


They are. There have been no changes in the kernel between p3 and p5. All you're doing by recompiling the kernel is changing the version string. That's why the kernel isn't included with the updates, because it's only a cosmetic change.

Being 'in sync' refers to not running a 13.1 kernel and a 13.0 userland or some other weird version combination.


----------



## HL1234 (Dec 13, 2022)

SirDice said:


> They are. There have been no changes in the kernel between p3 and p5. All you're doing by recompiling the kernel is changing the version string. That's why the kernel isn't included with the updates, because it's only a cosmetic change.


I think I confused /boot/kernel directory with the file /boot/kernel/kernel. I think all what is in /kernel/* is the FreeBSD kernel. Some things a complied with the main file "kernel" and the others are kernel modules what can dynamically load after.


----------



## SirDice (Dec 13, 2022)

HL1234 said:


> Some things a complied with the main file "kernel" and the others are kernel modules what can dynamically load after.


The kernel config mostly defines which modules are statically compiled in. But even if it's statically in the kernel there would still be a module in /boot/kernel/, /boot/kernel/kernel is the actual kernel, everything else in that directory are all the modules.


----------



## bakul (Dec 13, 2022)

If your /usr/src is on the releng/13.1 git branch just do `git pull`. If you want to see what changed, do `git diff releng/13.1^ releng/13.1`. If you want to revert to the same sources as what your kernel was built from, look at the commit-hash in `uname -v` and do `git checkout <commithash-in-uname>`


----------

