Introduction to Linux Kernel Development
About Course
This course provides a comprehensive introduction to Linux kernel design and architecture, aimed at equipping you with both theoretical knowledge and practical skills. I will begin by covering essential operating system concepts and terminologies, ensuring that you have a strong foundation. From there, you’ll dive into the intricate workings of the Linux kernel, learning how to build it from source code and create a fully functional, custom bootable Linux system. This includes setting up a BusyBox user-space environment to complete the operating system, giving you a hands-on understanding of the system’s internals.
In addition to kernel building, this course will teach you how to develop your own Linux kernel modules, with a deep dive into loadable kernel modules (LKMs). You’ll explore how to extend the kernel’s functionality dynamically, enabling you to create, load, and debug modules efficiently. The course also delves into key features like kthreads, interfacing with the procfs (/proc) filesystem, allowing you to expose any module / kernel related statisitics to user-space, and also interfacing with debugfs (/sys/kernel/debug), allowing you to expose variables from within kernel-space to user-space for diagnostics and debugging.
Furthermore, you’ll gain experience in contributing to the Linux kernel by learning how to create patches and apply them following the official Linux kernel development workflow. Upon completing this course, you will be proficient in exploring, managing, and modifying the Linux kernel source code, ready to embark on a path toward becoming a skilled Linux kernel developer.
What Will You Learn?
- Learn how Linux kernel works with a high-level understanding of various kernel subsystems
- Setup your own development environment for exploring Linux kernel development on a VirtualBox VM
- Learn about important concepts related to modern operating systems
- Learn how to custom compile and boot a binary image from official Linux kernel sources
- Learn how to create a Linux bootable image with custom built Linux kernel and busybox as userspace
- Learn how to create custom initramfs image with busybox as user-land
- Learn how to navigate the kernel sources, learn new features and APIs
- Learn how to create Linux kernel modules and understand development process of loadable kernel modules
- Learn how to interface procfs and debugfs via Loadable Kernel Modules
- Learn the tips, techniques and best practices to become a proficient Linux kernel developer
- Learn how to create patches that can be submitted to the official Linux kernel community
Course Content
Introduction to Linux
In this section, you will learn about the introductory concepts of the Linux ecosystem. You will learn about the history of Linux, Key features of Linux kernel and the Linux kernel development process.
-
An overview of the Linux ecosystem and OS stack
24:27:00 -
Brief History of Linux
55:57 -
Key Features of the Linux Kernel
16:36 -
The Linux Kernel Development Process
57:04
Setting up your Linux kernel development environment
In this section, I will guide you through the setup of your Linux kernel development environment. You will learn how to create a VirtualBox VM with ArchLinux configured as a guest OS that we will use for learning Linux kernel internals and development for the rest of the course.
If you are already well versed with Linux setup and configuration, you can safely skip this section and use your own setup instead.
-
Setting ArchLinux on VirtualBox VM (Windows / Linux / MacOS x86)
26:38
A Primer on OS Concepts
In this section, I will explain in detail - the core concepts of Operating Systems that you will need to understand to become a kernel developer.
-
Fundamental concepts related of Operating Systems design and architecture
01:35:01 -
High level architecture of an operating system kernel
01:13:09 -
IRQ subsystems and other core kernel features
37:39 -
Monolithic vs Microkernel architecture
41:51 -
Cooperative vs Preemptive multitasking
30:56 -
Virtual memory and Demand Paging
56:31
Building a custom Linux kernel and boot image
In this section, I will teach you by demonstrating the steps involved in building Linux kernel from the sources for your target hardware configuration. We will create a Linux boot image from our custom compiled Linux kernel.
-
Building a custom kernel image from the sources and booting the new kernel
01:59:17 -
Booting custom Linux image with busybox as user-space
58:30 -
Creating a custom Linux bootable image using initramfs with busybox
50:41
High level architecture of the Linux kernel
In this section, I will teach how you the various subsystems and components of the Linux kernel using a high-level architectural diagram and navigating the kernel sources.
-
Understanding “Everything is a File” paradigm on Linux
00:00 -
Linux Kernel subsystems and core architectural layers
34:06
Navigating the Linux kernel sources
In this section, I will teach you how to navigate the Linux kernel source code - identifying the code-base for various kernel susbsystems and drivers. You will also learn about the Linux kernel boot process.
-
Linux kernel source tree layout: a high-level overview
01:13:18 -
Navigating the Kernel sources using cscope and LXR
22:27 -
Linux Kernel Boot Process: High-level code walkthrough of core kernel boot
34:38 -
Linux Kernel Boot Process: Subsystem initialization to user-space init
38:09
Loadable Kernel Modules
In this section, I will teach you how to add features into the Linux kernel by creating a Loadable Kernel Module. You will also learn how to modify the Linux kernel, create a patch and the process involved to submit a patch to the Linux kernel community.
-
An overview on Loadable Kernel Modules
53:19 -
Writing your first loading kernel module
01:11:15 -
Loadable kernel module: features and diagnostics
01:17:33 -
An overview on kthreads and module parameters
01:06:43 -
Validating module parameters
41:09 -
Creating Loadable Kernel Modules based on multiple source files
01:14:58 -
Passing module parameters and managing modules via module aliases
-
Develop a loadable kernel module to add entries into /proc (procfs) filesystem
01:02:23 -
Exposing variables as files in debug filesystem (/sys/kernel/debug)
34:18 -
Creating and submitting patches to the Linux kernel community
47:34
Conclusion
In this section, I will guide you through the future directions that you might want to explore on Linux kernel learning and development
-
Ending notes and future directions
10:05