Solved Kernel build error

Can you build a GENERIC kernel on your system? Remove src directory, create new one, checkout the 12.1:
svn checkout https://svn.freebsd.org/base/releng/12.1 /usr/src
Replace /etc/make.conf /etc/src.conf with default ones (not modified). Try to build a GENERIC kernel (no modifications). Report back the
Can you build a GENERIC kernel on your system? Remove src directory, create new one, checkout the 12.1:
svn checkout https://svn.freebsd.org/base/releng/12.1 /usr/src
Replace /etc/make.conf /etc/src.conf with default ones (not modified). Try to build a GENERIC kernel (no modifications). Report back the result.

.
How do I remove src directory?
 

SirDice

Administrator
Staff member
Administrator
Moderator
If I try to build kernel now it says that it doesn't know how to buildkernel.
Yes, obviously. You asked how to remove the source directory. If you removed that source directory where is it supposed to build from?
 
Bu
I just meant it looked like different message than before since I haven't deleted the /usr/src due to ("device busy") message.
 

SirDice

Administrator
Staff member
Administrator
Moderator
That only left the /usr/src directory itself, probably because you had a shell open in that directory (hence the "busy" error). Another reason could be the filesystem, if /usr/src/ is a mounted filesystem (ZFS, UFS) then you would get a "busy" too if you try to remove the mountpoint while it's mounted. Everything inside the directory would still get removed though.
 

That only left the /usr/src directory itself, probably because you had a shell open in that directory (hence the "busy" error). Another reason could be ZFS, if /usr/src/ is a mounted ZFS dataset then you would get a "busy" too if you try to remove the mountpoint. Everything else inside the directory would still get removed though.

It executed to the next line now. But when I check out that 12.1 copy it returns with the error message

Svn: E170013: Unable to connect to a repository at URL 'https://svn
That only left the /usr/src directory itself, probably because you had a shell open in that directory (hence the "busy" error). Another reason could be the filesystem, if /usr/src/ is a mounted filesystem (ZFS, UFS) then you would get a "busy" too if you try to remove the mountpoint while it's mounted. Everything inside the directory would still get removed though.
Okay, I still get the same message after deleting the usr/src and doing the check out again. Doesn't know how to build kernel.
 
JUST A TYPO I ISSUED THE CORRECT COMMAND...
Code:
Checked out revision 363360.
root@machine17:~ # cd /usr/src/sys/amd64/conf
root@machine17:/usr/src/sys/amd64/conf # make buildkernel KERNCONF=GENERIC
make: don't know how to make buildkernel. Stop

make: stopped in /usr/src/sys/amd64/conf
 
You can also unpack the src.txz from your installation media instead of using svn.
su -
cd /
tar -xvzf /usr/freebsd-dist/src.txz
EDIT obsolete since you now seem to have the sources.
Instead su - you can use sudo(8) or doas(8), if it's installed ( sudo -i).
Of course then the source tree is updated by freebsd-update(8).
Frankly, you seem to be missing some basic knowledge of UNIX systems in general. Still it's ok to build your own kernel to learn, but you should definitely install the docs pkg install {de,en}-freebsd-doc, replace de with your native tongue & point your favorite browser to /usr/local/share/doc/freebsd. There's a chapter about building your kernel in the handbook.
 

SirDice

Administrator
Staff member
Administrator
Moderator
Code:
Checked out revision 363360.
root@machine17:~ # cd /usr/src/sys/amd64/conf
root@machine17:/usr/src/sys/amd64/conf # make buildkernel KERNCONF=GENERIC
make: don't know how to make buildkernel. Stop

make: stopped in /usr/src/sys/amd64/conf
You're in the wrong directory.
 
sorry guys 4 the typo

Code:
cd /usr/src
make targets
make buildkernel... works 

GENERIC kernel build works now but...
root@machine17:~ # cd /usr/src
root@machine17:/usr/src # make buildkernel KERNCONF=MYKERNEL
make[1]: "/usr/src/Makefile.inc1" line 341: SYSTEM_COMPILER: Determined that CC=cc matches the source tree.  Not bootstrapping a cross-compiler.
make[1]: "/usr/src/Makefile.inc1" line 346: SYSTEM_LINKER: Determined that LD=ld matches the source tree.  Not bootstrapping a cross-linker.
make[1]: "/usr/src/Makefile.inc1" line 1538: Missing KERNCONF /usr/src/sys/amd64/conf/MYKERNEL
*** Error code 1

Stop.
make: stopped in /usr/src
 
On the 1st post, click on "..." -> edit thread -> prefix: solved
EDIT and please install the docs... ;) It's no shame to be unexperienced, but it's also polite to use all the fine sources of information to gain the experience.
 
Okay. I still want to create a custom kernel for learning.

what happened...
Code:
root@machine17:/usr/src # make installkernel KERNCONF=MYKERNEL
--------------------------------------------------------------
>>> Install check kernel
--------------------------------------------------------------
--------------------------------------------------------------
>>> Installing kernel MYKERNEL on Mon Jul 20 18:46:57 MDT 2020
--------------------------------------------------------------
cd /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL;  MACHINE_ARCH=amd64  MACHINE=amd64  CPUTYPE= CC="cc -target x86_64-unknown-freebsd12.1 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" CXX="c++  -target x86_64-unknown-freebsd12.1 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  CPP="cpp -target x86_64-unknown-freebsd12.1 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  AS="as" AR="ar" LD="ld" LLVM_LINK=""  NM=nm OBJCOPY="objcopy"  RANLIB=ranlib STRINGS=  SIZE="size" PATH=/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin  make  KERNEL=kernel install
cd: /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL: No such file or directory
*** Error code 2

Stop.
make[1]: stopped in /usr/src
*** Error code 1

Stop.
make: stopped in /usr/src
 

SirDice

Administrator
Staff member
Administrator
Moderator
Code:
root@machine17:/usr/src # make installkernel KERNCONF=MYKERNEL
....
cd: /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL: No such file or directory
You don't have a kernel config file named MYKERNEL.
 

SirDice

Administrator
Staff member
Administrator
Moderator
So, you did make buildkernel? That actually builds the GENERIC kernel, not your custom kernel. It fails at the installkernel stage because you haven't built MYKERNEL.
 
If you have /usr/obj/usr/src/amd64.amd64/sys/GENERIC but no /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL that means you built a GENERIC kernel.
You can use nohup(1) then you'l have a log written to nohup.out. Like this:
\nohup nice make buildkernel &
less nohup.out
Then press G F to move at the end & follow new lines coming in. CTRL-C will end following. In the log file, you can see where the object files are written to.
 
Top