Clean kernel ompilation ============================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Version Info ` * :ref:`Steps to do clean kernel compilation ` * :ref:`STEP 1: Boot the system ` * :ref:`STEP 2: Redirect to root access ` * :ref:`STEP 3: Change directory to kernel source code location ` * :ref:`STEP 3.1: Download source code ` * :ref:`STEP 3.2: Copy all directories and files from freebsd-src to src directory ` * :ref:`STEP 4: Change directory to sys directory ` * :ref:`STEP 5: Change directory to platform directory ` * :ref:`STEP 6: Change directory to conf directory ` * :ref:`STEP 7: Create custom Configurtaion file ` * :ref:`STEP 8: Modify configuration file ` * :ref:`STEP 9: Change to src directory ` * :ref:`STEP 10: Build the kernel source code ` * :ref:`STEP 11: Install the kernel module on system ` * :ref:`STEP 12: Reboot the system ` * :ref:`STEP 13: Check for kernel changes ` * :ref:`STEP 14: Check the loaded modules ` * :ref:`STEP 15: Check the threads running ` * :ref:`STEP 16: Check wireless interface name ` * :ref:`STEP 17: Check ethernet interface name ` .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step1: .. tab-set:: .. tab-item:: Clean kernel compilation * In this section, you are going to learn .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to do clean kernel compilation .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step2: .. tab-set:: .. tab-item:: Version Info =============================== ======================================= # Version =============================== ======================================= Freebsd 14.1.0 =============================== ======================================= .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step3: .. tab-set:: .. tab-item:: Steps to do clean kernel compilation .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step4: .. tab-set:: .. tab-item:: STEP 1: Boot the system * To compile the kernel source code user should change the user access to root previlege mode .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step5: .. tab-set:: .. tab-item:: STEP 2: Redirect to root access * Execute below command to redirect to root access .. code-block:: c test:~$ su .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step6: .. tab-set:: .. tab-item:: STEP 3: Change directory to kernel source code location * Run the below command to change the directory to kernel source code location .. code-block:: c test:~$ cd /usr/src/ .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step6_1: .. tab-set:: .. tab-item:: STEP 3.1: Download source code * Note: By Default "/usr/src directory contain the exist version kernel source code. if you want to compile from externally, follow steps 3.1 and 3.2 .. code-block:: shell test:~$ rm -rf /usr/src/* & rm -rf /usr/src/.* test:~$ cd /usr * NOTE: git branch name "release/14.1.0" is for user validate. Based on user requirement clone the respective branch and compile it. .. code-block:: shell test:~$ git clone -b release/14.1.0 https://github.com/freebsd/freebsd-src.git .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step6_2: .. tab-set:: .. tab-item:: STEP 3.2: Copy all directories and files from freebsd-src to src directory * Copy all the directories and files from freebsd-src to src directory .. code-block:: shell test:~$ cp -rf freebsd-src/* src/ & cp -rf freebsd-src/.* src/ .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step7: .. tab-set:: .. tab-item:: STEP 4: Change directory to sys directory * Run the below command to move to the sys directory .. code-block:: c test:~$ cd /sys .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step8: .. tab-set:: .. tab-item:: STEP 5: Change directory to platform directory * Run the below command to move to the platform directory * Many platform source code available in the "/usr/src/sys" directory, based on requirement select platform directory and compile it. .. code-block:: c test:~$ cd amd64 .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step9: .. tab-set:: .. tab-item:: STEP 6: Change directory to conf directory * Run the below command to move to the conf directory .. code-block:: c test:~$ cd conf .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step10: .. tab-set:: .. tab-item:: STEP 7: Create custom Configurtaion file * TESTCONF is custom configuration file name, you can mention any name .. code-block:: c test:~$ cp GENERIC TESTCONF .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step11: .. tab-set:: .. tab-item:: STEP 8: Modify configuration file * Modify the configuration file which is required for the systems * Open TESTCONF file and add copy below lines to TESTCONF file .. code-block:: c test:~$ vi TESTCONF ident GENERIC ident TESTCONF .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step12: .. tab-set:: .. tab-item:: STEP 9: Change to src directory .. code-block:: c test:~$ cd /usr/src/ .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step13: .. tab-set:: .. tab-item:: STEP 10: Build the kernel source code * Run below command to build the kernel source code .. code-block:: c test:~$ make -j8 buildkernel KERNCONF=TESTCONF .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step14: .. tab-set:: .. tab-item:: STEP 11: Install the kernel module on system * Before running make command take backup of the all prebuild modules and binaries .. code-block:: c test:~$ cp -rf /boot/kerenel /boot/kernel_14_1_0 test:~$ make -j8 installkernel KERNCONF=TESTCONF .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step15: .. tab-set:: .. tab-item:: STEP 12: Reboot the system * Reboot the system .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step16: .. tab-set:: .. tab-item:: STEP 13: Check for kernel changes * Once kernel loaded run the below command and confirm, system loaded with proper kernel changes * Observe the Configuration file name will appear on this line .. code-block:: c test:~$ uname -a FreeBSD sysadmin 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 TESTCONF amd64 .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step17: .. tab-set:: .. tab-item:: STEP 14: Check the loaded modules * Run kldstat command to check the loaded module on systems .. code-block:: c test:~$ kldstat .. literalinclude:: kldstat_output.txt .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step18: .. tab-set:: .. tab-item:: STEP 15: Check the threads running .. code-block:: c test:~$ ps PID TT STAT TIME COMMAND 89708 v0 Is+ 0:00.00 /usr/libexec/getty Pc ttyv0 89952 v1 Is+ 0:00.00 /usr/libexec/getty Pc ttyv1 90039 v2 Is+ 0:00.00 /usr/libexec/getty Pc ttyv2 90117 v3 Is+ 0:00.00 /usr/libexec/getty Pc ttyv3 90205 v4 Is+ 0:00.00 /usr/libexec/getty Pc ttyv4 90556 v5 Is+ 0:00.00 /usr/libexec/getty Pc ttyv5 90630 v6 Is+ 0:00.00 /usr/libexec/getty Pc ttyv6 91095 v7 Is+ 0:00.00 /usr/libexec/getty Pc ttyv7 14538 0 I 0:00.01 su 14664 0 I+ 0:00.05 su (sh) 12462 1 S 0:00.01 su 12586 1 S 0:00.01 su (sh) 12895 1 R+ 0:00.00 ps .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step19: .. tab-set:: .. tab-item:: STEP 16: Check wireless interface name .. code-block:: c test:~$ ifconfig wlan0: flags=8843 metric 0 mtu 1500 options=0 ether 0c:9a:3c:9f:17:71 inet 192.168.3.20 netmask 0xffffff00 broadcast 192.168.3.255 groups: wlan ssid TP_link_11ax_5G channel 36 (5180 MHz 11a) bssid 50:d4:f7:00:51:de regdomain FCC country US authmode WPA2/802.11i privacy ON deftxkey UNDEF AES-CCM 2:128-bit txpower 17 bmiss 7 mcastrate 6 mgmtrate 6 scanvalid 60 wme roaming MANUAL parent interface: iwlwifi0 media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11a status: associated nd6 options=29 .. _FreebsdDeviceDriver_kernel_compilation_clean_kernel_compilation_step20: .. tab-set:: .. tab-item:: STEP 17: Check ethernet interface name .. code-block:: c test:~$ ifconfig em0: flags=1008843 metric 0 mtu 1500 options=60251b ether 7c:8a:e1:98:43:82 inet 10.91.229.72 netmask 0xffffff00 broadcast 10.91.229.255 inet6 fe80::7e8a:e1ff:fe98:4382%re0 prefixlen 64 scopeid 0x1 media: Ethernet autoselect (100baseTX ) status: active nd6 options=23