This guide walks you through the steps to build and install the CBL-Mariner Linux Kernel on AzureLinux.
Run the following command to install all necessary build dependencies:
sudo dnf install -y audit-devel build-essential cpio diffutils dwarves elfutils-libelf-devel flex gettext git glib-devel kbd kmod-devel libcap-devel libdnet-devel libmspack-devel ncurses-devel openssl openssl-devel pam-devel procps-ng-devel python3-devel pciutils-develReplace <kernel-version> with the version of the kernel you want to build. For example: rolling-lts/mariner-3/6.6.44.1.
git clone https://github.com/microsoft/CBL-Mariner-Linux-Kernel.git -b <kernel-version> --depth=1
cd CBL-Mariner-Linux-Kernel/Note: The examples below use the latest AzureLinux 3.0 development configuration for the generic kernel. Ensure you select a configuration file that matches your specific use case and kernel version.
For x86_64 Architecture
wget https://raw.githubusercontent.com/microsoft/azurelinux/3.0-dev/SPECS/kernel/config
cp config .configFor AArch64 (arm64) Architecture
wget https://raw.githubusercontent.com/microsoft/azurelinux/3.0-dev/SPECS/kernel/config_aarch64
cp config_aarch64 .configResolve unexpected configuration differences between your build environment and the default configuration:
make oldconfigFor additional configuration changes, use the menu-based configuration tool:
make menuconfigThis will update the .config file with your changes.
Compile the kernel using all available CPU cores:
make -j$(nproc)Note: While developing, ensure Secure Boot is disabled in your BIOS/UEFI firmware settings, as it may prevent the system from loading unsigned kernels.
For Mariner 2.0
- Install
installkerneland the kernel modules:sudo tdnf install -y installkernel sudo make modules_install sudo make install
- Reboot your system:
Your system should now boot into the new kernel.
sudo reboot
For Azure Linux 3.0
-
Install the kernel modules:
sudo make modules_install
-
Manually copy the kernel image to
/boot:# For x86_64 Architecture: sudo cp arch/x86/boot/bzImage /boot/vmlinuz-<kernel-version> # For AArch64 (arm64) Architecture: sudo cp arch/arm64/boot/Image /boot/vmlinuz-<kernel-version>
-
Rebuild the initramfs and ensure it is placed in
/boot:sudo dracut /boot/initramfs-<kernel-version>.img <kernel-version>
-
Rebuild the GRUB configuration:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
-
Set the desired GRUB entry as default:
sudo vim /boot/grub2/grub.cfg # Copy the name of the menu entry you want as default # Example: "AzureLinux GNU/Linux, with Linux <kernel-version>" sudo vim /etc/default/grub # Add GRUB_DEFAULT="desiredmenuentryname"
Note: Setting the desired GRUB entry as default ensures the system automatically boots into the new kernel during subsequent restarts. This is especially helpful when multiple kernel versions are installed, as it prevents the system from inadvertently booting into an older version.
-
Set a GRUB timeout to enable the menu entry list:
sudo vim /etc/default/grub # Add or modify the following line: GRUB_TIMEOUT=30Note: Setting a longer GRUB timeout allows you to select a previous kernel during boot if something goes wrong with the new kernel. This is helpful for rollback and troubleshooting.
-
Rebuild GRUB after selecting the desired boot entry and setting the timeout:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
-
Reboot your system:
sudo reboot
Your system should now boot into the new kernel.
After rebooting, verify that the new kernel is active:
-
Check Active Kernel Version: Run the following command to confirm the currently running kernel version:
uname -r
Ensure the output matches the
<kernel-version>you built and installed. -
Check Boot Logs: Use the following command to review the system logs for any boot issues:
journalctl -b
Look for any errors or warnings related to the new kernel.
-
Check GRUB Configuration: Confirm that the new kernel is listed in the GRUB menu:
sudo grep menuentry /boot/grub2/grub.cfg
Verify that the
<kernel-version>is present in the output. -
Test Functionality: Perform basic checks to ensure system stability:
- Verify that all hardware (e.g., network adapters, disks) is functioning as expected.
- Confirm that critical services are running:
systemctl status
-
Fallback to Previous Kernel (Optional): If issues arise, reboot the system and select a previous kernel from the GRUB menu during boot.
If you encounter issues, consult the project documentation or raise a query in the repository's issues section.