GENERAL NOTE
This article is written for 11.2-RELEASE. This is the production release. There are other releases such as -STABLE, -CURRENT. Kindly read through official documentation on the differences between these releases and how,where you can use these releases. This article also assumes that you have perquisite as follows:
- Unix/Linux command-line fundamentals
- Unix/Linux installation procedures such as disk partitioning
Updating @world set provide latest tools to compile the kernel. It is advisable to compile & install @world set before doing anything with kernel.
This article will guide you on updating FreeBSD source files, build & install @world set [optional] and finally the kernel. This article will guide you in compiling the kernel, then the @world set. FreeBSD,unlike GNU/Linux, has monolithic kernel, which forms the operating system. Several assumptions made, such as release type, cpu type etc etc. For more information, Google how FreeBSD differs from Linux.
Source File Update
In order to update source files, you need to determine FreeBSD version you are running. Following command will print out version and patch applied to the system.
#uname -r
e.g:
11.2-RELEASE-p4
where 11.2 is the version, RELEASE is the release type (STABLE,CURRENT etc) and p4 is the patch level applied to the system. If you would like to patch the system to latest patches, following command will do the trick:
- ``#freebsd-update fetch install``
While freebsd-update
known to work for GENERIC kernel configuration, I have made assumption such that user-modified kernel configuration will be named as GENERIC to get patch update.
Following list of commands will help you update source files, located in /usr/src.
-#svn --trust-server-cert --non-interactive checkout https://svn.FreeBSD.org/base/releng/11.2 /usr/src
- This will fetch latest revision of 11.2-RELEASE source files
-svn --trust-server-cert --non-interactive update /usr/src
- This will update /usr/src to latest revision since svn checkout
command
Optional
This is completely optional to update FreeBSD's port tree. FreeBSD ports tree is like a package manager RPM for FreeBSD. Following commands will fetch,install & update Ports Tree.
-#svn --trust-server-cert --non-interactive checkout https://svn.FreeBSD.org/ports/head /usr/ports
-#svn --trust-server-cert --non-interactive update /usr/ports
Build & Install @world [Optional]
Make sure you have updated /usr/src
before proceeding. Following commands will build & install new world into the system.
-#make buildworld installworld
Optional
If you know number of cores your processfor has, you can pass in option -j<NUM_OF_PROCESS>
. For e.g:
-#make -j2 buildworld installworld
Once build process is complete, you can reboot your machine and proceed to compile & install the kernel.
Compile & Install Kernel
To compile i386
system, you need to have have related configuration files in /usr/src/sys/i386/conf
directory, which is the GENERIC file. The file has configuration for kernel & drivers which the system will load up. Below configuration file is for you to try out. I have redacted some configurations because they are not needed. If you would like to know which kernel modules are loaded, you can try following commands:
#pciconf -lv
- This is useful when you want to build driver-specific kernel options#kldstat -v
- This command shows all loaded modules in the kernel- view the boot log
dmesg
file in log folder
[code lang=text] # # GENERIC -- Generic kernel configuration file for FreeBSD/i386 # # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # # http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the # FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the # latest information. # # An exhaustive list of options and more detailed explanations of the # device lines is also present in the ../../conf/NOTES and NOTES files. # If you are in doubt as to the purpose or necessity of a line, check first # in NOTES. # # $FreeBSD: releng/11.2/sys/i386/conf/GENERIC 323770 2017-09-19 16:51:51Z jpaetzel $ machine i386 cpu I486_CPU cpu I586_CPU cpu I686_CPU ident GENERIC
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support
options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 options TCP_OFFLOAD # TCP offload options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists options UFS_DIRHASH # Improve performance on big directories options UFS_GJOURNAL # Enable gjournal-based UFS journaling options QUOTA # Enable disk quotas for UFS options MD_ROOT # MD is a potential root device options NFSCL # Network Filesystem Client options NFSD # Network Filesystem Server options NFSLOCKD # Network Lock Manager options NFS_ROOT # NFS usable as /, requires NFSCL options MSDOSFS # MSDOS Filesystem options CD9660 # ISO 9660 Filesystem options PROCFS # Process filesystem (requires PSEUDOFS) options PSEUDOFS # Pseudo-filesystem framework options GEOM_PART_GPT # GUID Partition Tables. options GEOM_RAID # Soft RAID functionality. options GEOM_LABEL # Provides labelization options COMPAT_FREEBSD4 # Compatible with FreeBSD4 options COMPAT_FREEBSD5 # Compatible with FreeBSD5 options COMPAT_FREEBSD6 # Compatible with FreeBSD6 options COMPAT_FREEBSD7 # Compatible with FreeBSD7 options COMPAT_FREEBSD9 # Compatible with FreeBSD9 options COMPAT_FREEBSD10 # Compatible with FreeBSD10 options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI options KTRACE # ktrace(1) support options STACK # stack(9) support options SYSVSHM # SYSV-style shared memory options SYSVMSG # SYSV-style message queues options SYSVSEM # SYSV-style semaphores options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. options KBD_INSTALL_CDEV # install a CDEV entry in /dev options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) options AUDIT # Security event auditing options CAPABILITY_MODE # Capsicum capability mode options CAPABILITIES # Capsicum capabilities options MAC # TrustedBSD MAC Framework options KDTRACE_HOOKS # Kernel DTrace hooks options DDB_CTF # Kernel ELF linker loads CTF data options INCLUDE_CONFIG_FILE # Include this file in kernel options RACCT # Resource accounting framework options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options RCTL # Resource limits
# Debugging support. Always need this: options KDB # Enable kernel debugger support. options KDB_TRACE # Print a stack trace for a panic.
# To make an SMP kernel, the next two lines are needed options SMP # Symmetric MultiProcessor Kernel device apic # I/O APIC options EARLY_AP_STARTUP
# CPU frequency control device cpufreq
# Bus support. device acpi device pci # ATA controllers device ahci # AHCI-compatible SATA controllers device ata # Legacy ATA/SATA controllers options ATA_STATIC_ID
# ATA/SCSI peripherals device scbus # SCSI bus (required for ATA/SCSI) device ch # SCSI media changers device da # Direct Access (disks) device sa # Sequential Access (tape etc) device cd # CD device pass # Passthrough device (direct ATA/SCSI access)
# atkbdc0 controls both the keyboard and the PS/2 mouse device atkbdc # AT keyboard controller device atkbd # AT keyboard device psm # PS/2 mouse
device kbdmux # keyboard multiplexer
device vga # VGA video card driver options VESA # Add support for VESA BIOS Extensions (VBE)
device splash # Splash screen and screen saver support
# syscons is the default console driver, resembling an SCO console device sc options SC_PIXEL_MODE # add support for the raster text mode
# vt is the new video console driver device vt device vt_vga
device agp # support several AGP chipsets
# Power management support (see NOTES for more options) device apm # Add suspend/resume support for the i8254. device pmtimer
# PCCARD (PCMCIA) support # PCMCIA and cardbus bridge support device cbb # cardbus (yenta) bridge device pccard # PC Card (16-bit) bus device cardbus # CardBus (32-bit) bus
# Serial (COM) ports device uart # Generic UART driver
# Parallel port device ppc device ppbus # Parallel port bus (required) device lpt # Printer device ppi # Parallel port interface device #device vpo # Requires scbus and da
device puc # Multi I/O cards and multi-channel UARTs
# PCI Ethernet NICs. device em # Intel PRO/1000 Gigabit Ethernet Family
# Pseudo Devices device loop # Network loopback device random # Entropy device device padlock_rng # VIA Padlock RNG device rdrand_rng # Intel Bull Mountain RNG device ether # Ethernet support device vlan # 802.1Q VLAN support device tun # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module
# The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter
# USB support options USB_DEBUG # enable debug msgs device uhci # UHCI PCI->USB interface device ohci # OHCI PCI->USB interface device ehci # EHCI PCI->USB interface (USB 2.0) device xhci # XHCI PCI->USB interface (USB 3.0) device usb # USB Bus (required) device ukbd # Keyboard device umass # Disks/Mass storage - Requires scbus and da
# VirtIO support device virtio # Generic VirtIO bus (required) device virtio_pci # VirtIO PCI device device vtnet # VirtIO Ethernet device device virtio_blk # VirtIO Block device device virtio_balloon # VirtIO Memory Balloon device
# The crypto framework is required by IPSEC device crypto # Required by IPSEC device aesni
[/code]
Save above configuration as GENERIC under /usr/src/sys/i386/conf
directory. You can choose to change ident
from GENERIC to name of your choice. Once you're done, type following command from /usr/src
directory to build & install the kernel:
-#make -j2 TARGET_ARCH=i386 buildkernel installkernel KERNCONF=GENERIC
Above command will use make
program to buildkernel
& installkernel
. Option -j<NUM>
set number of parallel builds to set. Option KERNCONF=GENERIC
states the configuration GENERIC to be used. Option TARGET_ARCH=i386
will build & install kernel for target architecture. Suppose you have amd64
machine, you could set TARGET_ARCH=amd64
.
Once above process is complete, reboot your machine and you will boot into newly baked kernel.
uname -a
should show slightly different output when you build & install world and kernel set.
This guide is written for people who are new to FreeBSD. It is a working guide produced using 2 Core, 512MB RAM virtual machine.
Resource: FreeBSD Handbook, nixcraft blog. Google them.