FreeBSD is a free Unix-like operating system descended from Research Unix via the Berkeley Software Distribution (BSD). Although for legal reasons FreeBSD cannot use the Unix trademark, it is a direct descendant of BSD, which was historically also called “BSD Unix” or “Berkeley Unix”. The first version of FreeBSD was released in 1993, and today FreeBSD is the most widely used open-source BSD distribution, accounting for more than three-quarters of all installed systems running open-source BSD derivatives.
FreeBSD has similarities with Linux, with two major differences in scope and licensing: FreeBSD maintains a complete operating system, i.e. the project delivers kernel, device drivers, userland utilities and documentation, as opposed to Linux delivering a kernel and drivers only and relying on third-parties for system software and FreeBSD source code is generally released under a permissive BSD license as opposed to the copyleft GPL.
It uses the GENERIC kernel by default. FreeBSD’s kernel provides support for some essential tasks such as managing processes, communication, booting and filesystems. In this article, we will show you how you can recompile a FreeBSD kernel with a custom configuration.
Some Features of FreeBSD and kernel
From the different features we can list the following ones:
- FreeBSD 10.0 now supports a truly tickless kernel, enhancing battery performance on laptops and general resource effectiveness in virtual machines.
- AMD GPUs kernel mode setting supports the use of newer xf86-video-ati drivers and AMD GPUs
- FreeBSD 10.0 brings with it support for ZFS TRIM and it also supports LZ4 compression support which compresses much better (up to 50%) than the default LZJB compression
- BSD-kernel are not stand-alone kernels but are developed as being part of a whole. Of course, this is merely a philosophical point of view and not a technical one, but this give system coherence
As prerequisites for this article you need to need just to have a one FreeBSD 10.1 Droplet to be able to use the following commands; we assume that you are a FreeBSD user.
Recompile A FreeBSD Kernel
We will start by getting the operating system source code. As a characteristic of FreeBSD its ability to provide the source code to its operating system to be able to modify and download the source code easily. And to be able to recompile the kernel you have to use the following command in order to pull this source code from FreeBSD’s control system:
sudo pkg install subversion
Then you have to use the following command to rearrange the directory tables since the FreeBSD’s shell utilizes an internel hash table for commands in $PATH:
Then use the following command to check out the latest stable branch to the
sudo svn co https://svn0.us-east.FreeBSD.org/base/stable/10 /usr/src
You will be asked to accept the server certificate type the “p” command to accept it. Now we will create our custom configuration for kernel. We will call our configuration CONF_anis you have the choice to choose another name of course. The kernel configuration files are in the
So move to the configuration directory using the following command:
Then use the following command to create and open the CONF_anis file in order to edit it:
sudo nano CONF_anis
Then copy the following text into your created file:
cpu HAMMER ident CONF_anis options SCHED_ULE options PREEMPTION options INET options INET6 options TCP_OFFLOAD options SCTP options FFS options SOFTUPDATES options UFS_ACL options UFS_DIRHASH options UFS_GJOURNAL options QUOTA options MD_ROOT options NFSCL options NFSD options NFSLOCKD options NFS_ROOT options CD9660 options PROCFS options PSEUDOFS options GEOM_PART_GPT options GEOM_RAID options GEOM_LABEL options SCSI_DELAY=5000 options KTRACE options STACK options SYSVSHM options SYSVMSG options SYSVSEM options _KPOSIX_PRIORITY_SCHEDULING options PRINTF_BUFR_SIZE=128 options KBD_INSTALL_CDEV options HWPMC_HOOKS options AUDIT options CAPABILITY_MODE options CAPABILITIES options PROCDESC options MAC options KDTRACE_FRAME options KDTRACE_HOOKS options DDB_CTF options INCLUDE_CONFIG_FILE options KDB options KDB_TRACE options SMP device cpufreq device acpi options ACPI_DMAR device pci device ata options ATA_STATIC_ID device scbus device da device cd device pass device atkbdc device atkbd device vga device splash device sc options SC_PIXEL_MODE device uart device loop device random device padlock_rng device rdrand_rng device ether device vlan device tun device md device gif device faith device firmware device bpf options USB_DEBUG device uhci device usb device virtio device virtio_pci device vtnet device virtio_blk device virtio_scsi device virtio_balloon device pf device pflog options ALTQ options ALTQ_CBQ options ALTQ_RED options ALTQ_RIO options ALTQ_HFSC options ALTQ_PRIQ device crypto device aesni options GEOM_ELI options IPSEC options IPSEC_DEBUG
Then save and close your file.
/usr/srcdirectory and use the following commands to use our new configuration file:
cd /usr/src sudo make buildkernel KERNCONF=CONF_anis
It will require some time to finish that. As example of average equation for a 0.5 GB Droplet you need 45 minutes. After finishing your kernel recompilation, use the following command to start the installation:
sudo make installkernel KERNCONF=CONF_anis
After making the installation of your new system to reboot it, use the following command:
sudo shutdown -r now
And to check the functionality of your new kernel configuration use the following command:
sysctl kern.conftxt | grep ident
To be sure that everything works good you have to receive something like this:
In this article we explained for you how you can get a compiled and configured kernel. Now you get it and everything works good if you received the final message while checking the functionality of your system