$ sudo dnf check-update ; sudo dnf update
$ sudo dnf install ncurses-devel bison elfutils-libelf-devel
$ sudo dnf install openssl-devel
``$ sudo dnf groupinstall 'Development Tools'
$ sudo dnf groupinstall 'C Development Tools and Libraries'
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.8.tar.xz
Here are some notes on the basics of compiling a Linux kernel. We're following the text by Soyinka, which means we're downloading the most recent kernel source tree, enabling NTFS support as a module, and then re-compiling. We're recompiling a kernel for a Fedora 23 system that's running in VirtualBox.
Note about code snippets:
We can identify the current kernel by using
$ uname -a 4.7.4-100.fc23.x86_64
This is also the latest kernel at kernel.org, but we'll recompile it to see how the process goes and to enable NTFS support.
First, let's download the source code for the latest release (as of this writing), and unpack it in /usr/src:
$ su root % cd /usr/src % wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.8.tar.xz % tar xvJf linux-4.7.4.tar.xz
Now let's begin to configure the source for our particular virtual machine.
As an aside, sometimes we re-compile kernels to eliminate support for hardware
we don't have, for enabling hardware that we need, or for patching kernels with
security updates. There are more use-cases, but regarding harwdware, we can use
lshw to list PCI devices and other hardware
on the system. This is what my virtual system thinks it has:
% lspci 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service 00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) 00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB 00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08) 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
We need to install
% dnf install lshw % lshw | less
(Output too long to show.)
We're going to run
make menuconfig, but before we do so, we'll
make mrproper to clean up the build environment. First,
install the development tools, then change into the kernel tree directory, and
# need the tools to build the kernel % dnf install @development-tools # alternatively, this is supposed to work: dnf groupinstall "Development Tools" % cd /usr/src/linux-4.7.4 % make mrproper # copy the current kernel's config file to $PWD % cp /boot/config-`uname -r` .config # alternatively: cp /boot/config-$(uname -r) .config # run menuconfig % make menuconfig # received an error about a missing ncurses header file, so: % dnf install ncurses-devel.x86_64 # now re-run menuconfig % make menuconfig
We're following the text by Soyinka, and enabling support for NTFS as a module. I'm skipping her description here, but the changes we've made to .config include:
% grep -i ntfs .config CONFIG_NTFS_FS=m CONFIG_NTFS_DEBUG=y CONFIG_NTFS_RW=y
Next open the Makefile and add -custom to the EXTRAVERSION variable, and then run:
% make kernelversion 4.7.4-custom
After running make, I found I still needed to install some more development files. Here we go:
% dnf -y group install 'C Development Tools and Libraries'
Woops, another error. We also need to install:
% dnf install openssl-devel % make
And it's compiling. Takes about an hour on the virtual system w/ only 1 CPU. If we want it to go faster, next time assign more CPUs, if we can spare them, in our VB settings.
Now we need to install the modules and then run
% make modules_install
More compiling. (Next time run
time command to get a report on how
Next, copy and rename the kernel image to /boot, as well as System.map:
% cp /usr/src/linux-4.7.4/arch/x86_64/boot/bzImage /boot/vmlinux-4.7.4-custom % cp /usr/src/linux-4.7.4/System.map /boot/System.map-4.7.4-custom
Finally, create the RAM file system image, create list of module dependences,
and update the boot loader config. Before rebooting, check
/boot/grub2/grub.cfg to see if the boot config was updated, and
% new-kernel-pkg --mkinitrd --dracut --depmod --install 4.7.4-custom % reboot
After reboot and selecting the new image from grub:
$ uname -r 4.7.4-custom
Soyinka, Wale. (2015). Linux administration: A beginner's guide. New York: MacGraw Hill Education.