====== Input method in FreeBSD virtual terminal (Week1 & 2) ======
Date: 06/07-06/19
During these two weeks, I was preparing my kernel development environment, since this was the first time I tried to modify the freebsd kernel. Also I decided to take notes of the whole process of configuring the environment.
===== Environment Preparation =====
==== Building from Custom Source ====
=== Preparing Source ===
I forked %%FreeBSD%% source code on github: https://github.com/Cycatz/freebsd-src
And clone the project into ''%%/usr/src/%%''.
But ''%%/usr/src%%'' is a zfs dataset, we can not backup the old ''%%/usr/src%%'' by simply renaming it.
So I copied it into other directory and remove all old files in ''%%usr/src%%'' then clone the source code.
cp /usr/src /usr/src.bak
cd /usr/src
rm -rf ./* ./.*
Download the source code:
git remote add origin https://github.com/Cycatz/freebsd-src
git fetch origin
=== Building and Installing Custom Source ===
To build the custom kernel, copy the //GENERIC// kernel config file first:
cp /usr/src/sys/amd64/conf/GENERIC /root/MYKERNEL
cd /usr/src/sys/amd64/conf
ln -s /root/MYKERNEL .
But actually I didn't modify any configurations from GENERIC kernel config except for the //ident// column.
ident MYKERNEL
Now we are ready to build world and kernel:
First we need to install ''%%bear%%'' to index kernel source and generate ''%%compile_commands.json%%'' for LSP
pkg install py37-bear
Now we can build and install them:
cd /usr/src
make -DNO_CLEAN -j 8 buildworld
bear make -DNO_CLEAN -j 8 buildkernel KERNCONF=MYKERNEL
make installworld
make installkernel KERNCONF=MYKERNEL
etcupdate
reboot
After rebooting, use ''%%uname -a%%'' to check if our system version and the kernel profile are correct:
The results:
FreeBSD vt.staque.xyz 14.0-CURRENT FreeBSD 14.0-CURRENT #1 tmp-n248823-ced2dcadccfc-dirty: Fri Aug 20 21:32:02 CST 2021 root@vt.staque.xyz:/usr/obj/usr/src/amd64.amd64/sys/MYKERNEL amd64
=== Reference ===
* Ch 8. Configuring the %%FreeBSD%% Kernel: https://docs.freebsd.org/en/books/handbook/kernelconfig/
* Ch 24. Updating and Upgrading %%FreeBSD%%: https://docs.freebsd.org/en/books/handbook/cutting-edge/#freebsdupdate-portsrebuild
===== Developing on FreeBSD =====
Install clangd:
pkg install llvm12
Make an alias for clangd12:
ln -s clangd12 clangd