Custom Kernel Configuration

Overview

Compile and configure custom kernels for specific hardware support, performance tuning, or security requirements.

Build Custom Kernel

Install Build Dependencies

# Install build tools
apt install build-essential git
 
# Install kernel build deps
apt build-dep linux

Clone Kernel Source

# Clone Proxmox kernel
git clone https://github.com/proxmox/linux-proxmox.git
 
# Or use vanilla kernel
git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Configure Kernel

# Change to source directory
cd linux-proxmox
 
# Use Proxmox config
cp /boot/config-$(uname -r) .config
 
# Or use menuconfig
make menuconfig

Build Kernel

# Build
make -j$(nproc) deb-pkg
 
# Install
dpkg -i ../linux-*.deb

Kernel Parameters

GRUB Configuration

# Edit GRUB
nano /etc/default/grub
 
# Add parameters
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
 
# Update GRUB
update-grub

Common Parameters

ParameterDescription
intel_iommu=onEnable IOMMU
amd_iommu=onEnable AMD IOMMU
iommu=ptIOMMU passthrough
hugepages=1024Huge pages
default_hugepagesz=2M2MB pages
transparent_hugepage=neverDisable THP
nosmtDisable SMT

Kernel Modules

Load at Boot

# Create config
nano /etc/modules
 
# Add modules
vfio
vfio_iommu_type1
vfio_pci
nvidia
nvidia_uvm

Blacklist Modules

# Blacklist
nano /etc/modprobe.d/blacklist.conf
 
blacklist nouveau
blacklist nvidia

Performance Tuning

CPU Governors

# Set governor
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 
# Make persistent
apt install cpufrequtils
nano /etc/default/cpufrequtils

Kernel Tuning

# Network buffer
net.core.rmem_max=16777216
net.core.wmem_max=16777216
 
# File system
fs.file-max=65536

Security Hardening

Kernel Settings

# Disable unused features
echo 1 > /proc/sys/kernel/dmesg_restrict
 
# Disable core dumps
hard core 0
 
# Restrict sysrq
echo 1 > /proc/sys/kernel/sysrq

Keywords

kernel compilation tuning performance security kernel-parameters


Back to Proxmox VE