Need help for first time updating FreeBSD stable from source

Hi, first time ever im trying to update/upgrade FreeBSD 14.2 stable with custom patch for nvidia passtrough.
Using these sources: https://docs.freebsd.org/en/books/handbook/cutting-edge/#updating-src-obtaining-src and https://dflund.se/~getz/Notes/2024/freebsd-gpu/ and https://github.com/Beckhoff/freebsd-src/tree/phab/corvink/14.2/nvidia-wip
but i have some issues.
Obtaining the source:
If the output says fatal: not a git repository, the files there are missing or were installed with a different method. A new checkout of the source is required.
So i have this issue which means i have to take few extra steps.
mv /usr/src /usr/src.bak
im doing this command as root but i have error:
mv: rename /usr/src to /usr/src.bak: Operation not supported

also it states:
Move the old directory out of the way. If there are no local modifications in this directory, it can be deleted.
So if i cant move and i have to delete it ... but im a bit worried/scared as i have tendencies to f**k up things specially at first try. Is there another way to rename /usr/src or i should exit from Xorg and do it in TTY( login shell) ?

Next thing:
Once i get rid of /usr/scr i should do this ? ( Obviously i have to change releng to stable)
Code:
A.1) If you do not have the source, you can clone:
git clone -b releng/14.1 https://git.freebsd.org/src.git /usr/src cd /usr/src
B.1) Next, edit the file sys/amd64/vmm/x86.c and find the following line:
static const char bhyve_id[12] = "Bhyve Bhyve ";
B.2) Change it to:
static const char bhyve_id[12] = "KVMKVMKVM\0\0\0";
B.3) Then, build and install the kernel:
make -j$(nproc) buildkernel make -j$(nproc) installkernel
Or just get corvins 14.2 patched
git clone --depth 1 --branch phab/corvink/14.2/nvidia-wip https://github.com/Beckhoff/freebsd-src

Links im using shows a bit different ways of doing it. Official handbook includes world and kernel and link im using for passtrough - only kernel.
Im so confused.
 
Are you using ZFS? Basically "If you are using ZFS and /usr/src is a separate dataset, you'll need to do different steps"
The error message on the mv indicates that or simply the user trying to do that does not have appropriate permissions.
 
Are you using ZFS? Basically "If you are using ZFS and /usr/src is a separate dataset, you'll need to do different steps"
The error message on the mv indicates that or simply the user trying to do that does not have appropriate permissions.
Yes, im using ZFS and im also doing it as root.
 
There's no need to keep a backup of the original tree.

Code:
cd /usr/src
rm -r * .??*
git clone ... src
mv src/* src/.??* .
rmdir src
 
I would recommend not getting a shallow clone (--depth 1), do a full clone instead. You can't switch branches (not easy anyway) on a shallow clone. And you might want to switch back and forth between stable/14 and the phab/corvink/14.2/nvidia-wip branches. Or checkout a stable/14 branch, make a new develop branch and merge the changes from phab/corvink/14.2/nvidia-wip.
 
GlitchyDot , I too, read the handbook, but like your questions, I need additional help and practice to do this: clone update /usr/src and then build a new version of FreeBSD 14.2 or my favorite: a new version of GhostBSD github clone of kernel source code for /usr/src. I wrote notes about my choices to perform the simple steps to git clone update /usr/src kernel source code.
search on word 'compile' at my blog ghostbsd-arm64
https://ghostbsd-arm64.blogspot.com/search?q=compile
Compiling GhostBSD kernel /usr/src code. I also put in the steps for compiling FreeBSD /usr/src code. So learn from the examples.
HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src SOLVED Jan20 2024 Learn from more, similar examples about updating source code and compiling.



Search on word 'poudriere' or on word 'patch' at that same blog. You can find tips on setting up poudriere package builder.

I place these as examples in my personal blog, so that I might go back and repeat these same steps again in my near future. When I need to update/clone new version of FreeBSD source code and compile again.

GlitchyDot
you can follow along here and blog your own steps and test setup that work.
Your comments and suggestions will be helpful to us all. We all can practice and learn. What is working for you?

Standard update to /usr/src code to the latest​

git -C /usr/src pull --ff-only

Compiling to see if errors show up.​

MAKE buildKERNEL KERNCONF=GENERIC​

time make -j4 buildkernel KERNCONF=GENERIC -DNO_CLEAN



make installkernel KERNCONF=GENERIC

If a custom kernel was built, KERNCONF must also be set to use the new custom kernel:

Keep your own notes as you go along. Lets compare notes on Telegram or other medium as you like, GlitchyDot . Hope I was helpful to your success in updating kernel source code. Fred Finster

ps. I am learning about using GIT and github or gitxxxx to save my source code before editing and adding changes.
 
im not sure if i did it right, but when i type uname -v i get this
FreeBSD 14.2-STABLE #0 stable/14-n270286-b40f5ebc4581-dirty: Tue Feb 4 08:21:06 CST 2025 root@kodasBSD:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
Did i miss something ?
 
im not sure if i did it right, but when i type uname -v i get this
FreeBSD 14.2-STABLE #0 stable/14-n270286-b40f5ebc4581-dirty: Tue Feb 4 08:21:06 CST 2025 root@kodasBSD:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
Did i miss something ?
This looks good as FreeBSD version, number-dirty, date, email root@NameBSD:/usr/obj/usr/src/amd64.amd64/sys/GENERIC, but I am NOT an EXPERT, on HOW this WORKS!! So, other REAL EXPERTS, please do comment and explain.

uname -v

FreeBSD 14.2-STABLE #0 stable/14-n270286-b40f5ebc4581-dirty: Tue Feb 4 08:21:06 CST 2025 root@kodasBSD:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
~~~~~ Arm64 FreeBSD example below

fred@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ $ uname -v
FreeBSD 14.0-STABLE #1 stable-arm64/14-n230716-18b4bf31e36-dirty: Fri Feb 16 00:17:20 PST 2024 root@Ghost14-selfbuilt-rpi4B-nginx-tst1:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ
fred@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ $ date
Fri Feb 14 06:04:46 UTC 2025
fred@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ $ uname -K
1400500
fred@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ $ uname -r
14.0-STABLE
fred@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ $ su -
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -v
FreeBSD 14.0-STABLE #1 stable-arm64/14-n230716-18b4bf31e36-dirty: Fri Feb 16 00:17:20 PST 2024 root@Ghost14-selfbuilt-rpi4B-nginx-tst1:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -k
uname: illegal option -- k
usage: uname [-abiKmnoprsUv]
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -K
1400500
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -r
14.0-STABLE
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -U
1500001
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -KUR
uname: illegal option -- R
usage: uname [-abiKmnoprsUv]
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -KUv
FreeBSD 14.0-STABLE #1 stable-arm64/14-n230716-18b4bf31e36-dirty: Fri Feb 16 00:17:20 PST 2024 root@Ghost14-selfbuilt-rpi4B-nginx-tst1:/usr/obj/usr/ghost14/ghostbsd-src/arm64.aarch64/sys/GENERIC-VCHIQ 1400500 1500001
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # uname -KUmnoprs
FreeBSD Ghost14-selfbuilt-rpi4B-nginx-tst1 14.0-STABLE arm64 aarch64 1400500 1500001
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ #



I am sharing what comes from testing on the FreeBSD/GhostBSD build I performed last year on the Raspberry Pi 4B from FreeBSD operating system 14.x compiling kernel source code at
FreeBSD code source
/usr/src

or at
GhostBSD code source
/usr/ghost14/ghostbsd-src


~~~~~~~~~~~ performed on a Raspberry Pi 4B hardware running GhostBSD/FreeBSD operating system


root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # ghostbsd-version -fkv
14.0-STABLE
1400500
24.01.1
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # freebsd-version -dru
Illegal option -d
usage: freebsd-version [-kru] [-j jail]
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ # freebsd-version -kru
14.0-STABLE
14.0-STABLE
15.0-CURRENT
root@Ghost14-selfbuilt-rpi4B-nginx-tst1:~ #

I share these as examples that you, GlitchyDot or others, can compare with their own output on their own systems. Fred Finster, says, We all get better learning together.
 
Or checkout a stable/14 branch, make a new develop branch and merge the changes from phab/corvink/14.2/nvidia-wip.
How would i do it ? Im kinda lost inside command line with checkout, never created dev branch and merged changes - basically git usage is very minimal ( git clone - thats it )
I know i can clone whole branch and get it done ( did it, tested, worked ), but i want to try to using stable/14 branch and merge changes phab/corvink/14.2/nvidia-wip and also see what was there changed and in the future maybe i can do these changes myself and or apply patches ( C illiterate but thats not a concern for me )
This looks good as FreeBSD version, number-dirty, date, email
....

Well, the way i did - worked fine no issues... im still trying to understand whats the meaning of DIRTY but its not really important.
 
Can you confirm the actions you took that did work for you to compile from source code? and share which documents or websites you followed to build a new kernel from /usr/src source code
su - # get a root login
mkdir /usr/src ; cd /usr
git clone http://github.com/freebsd/freebsd-src /usr/src
cd /usr/src
make buildworld
make buildkernel kernconf=GENERIC
make installkernel kernconf=GENERIC

https://ghostbsd-arm64.blogspot.com
Compiling FreeBSD /usr/src source code
My first post states sources im using.
Handbook and https://dflund.se/~getz/Notes/2024/freebsd-gpu/ for updating Kernel.
Actual source - https://github.com/Beckhoff/freebsd-src/tree/phab/corvink/14.2/nvidia-wip (Its for 14.2 )
To make sure you wont have What, why no nVidia module loaded - Corvink patch disables nvidia module loading ( as far as i noted ) so you have to have iGPU ( intel,amd ) or another gpu from Intel or AMD or integrated to your motherboard ( i have Aspeed - but never used )
First time i did it - i had AMD as my main GPU and second time i had 2 nVidia gpus ( one for monitors and one for passtrough ) but kldstat and Xorg showed - no nVidia modules are loaded.
 
How would i do it ? Im kinda lost inside command line with checkout, never created dev branch and merged changes - basically git usage is very minimal ( git clone - thats it )
So... why not educate yourself on using Git? I'd say that's kind of a requirement if you want to work with Git managed source trees. And well, Git has excellent documentation.

Anyway, first things first... others already mentioned the issue of /usr/src possibly being its own file system, this is actually common practice because it would allow you to both compress the system as well as keep it read-only, which is an excellent safety precaution:

Code:
peter@bsd:/home/peter $ zfs get mountpoint,compression,readonly zroot/src
NAME       PROPERTY     VALUE           SOURCE
zroot/src  mountpoint   /usr/src        local
zroot/src  compression  on              local
zroot/src  readonly     on              local
See what I mean?

Anyway, Git... once you have a repository going for yourself you can easily use git-branch(1) to create a new section which you can dedicate to patching that repository. Best part is that you can continue doing other operations (like updating the source tree with git-pull(1)) and apply those operations on the official trees. And of course, eventually when everything is done and ready git-merge(1) can be used to bring things together and/or use git-checkout(1) to switch between branches.

Though I would strongly suggest that you only merge an official branch with yours, and not the other way around.

Another option, much safer, is to continue working with a separate branch and simply keep using git-pull(1) but specifically on your local branch (this is actually standard behavior). So basically; get Git to merge new official updates with your local patched setup.

Anywhoo...

Code:
peter@bsd:/opt/repos/PowerShell $ git branch
* master
peter@bsd:/opt/repos/PowerShell $ git branch MyLocalPatch master
peter@bsd:/opt/repos/PowerShell $ git switch MyLocalPatch
Switched to branch 'MyLocalPatch'
Always check what existing branch you want to base your work on, then make the switch (no pun intended). Now you can easily do your stuff and see if things work. If needed you can simply use switch (or 'checkout') to hop back to the master, and of course you can also easily pull new updates onto your own development branch as well.

But yeah, I highly recommend reading up on Git because with these options you really don't need anything else.
 
So... why not educate yourself on using Git? I'd say that's kind of a requirement if you want to work with Git managed source trees. And well, Git has excellent documentation.
Im actually started to read and dig deeper into the GIT. Im actually ashamed of myself that in so many years i never picked it up
eva-unit0-neon-genesis-evangelion.gif


Anyway, Git... once you have a repository going for yourself you can easily use git-branch(1) to create a new section which you can dedicate to patching that repository. Best part is that you can continue doing other operations (like updating the source tree with git-pull(1)) and apply those operations on the official trees. And of course, eventually when everything is done and ready git-merge(1) can be used to bring things together and/or use git-checkout(1) to switch between branches.
And this is where im kinda loosing control of it ... i might have to read-watch about git for few days and try to understand how should i merge/check/pull all of this.
 
Back
Top