On this page
Kernel Operations Manual
Compilation, module management, DKMS, and initramfs operations for custom Gentoo kernels.
Status Checks
# Installed kernels
# Current kernel configuration
|
# If you can't view it: the kernel doesn't have CONFIG_IKCONFIG_PROC enabled. Check /boot/config-$(uname -r)
# Loaded modules
|
# Kernel logs
|
# Kernel parameters (runtime)
Kernel Compilation
# Source location
# Configuration
# Save/restore configuration
# If backup exists: cp /boot/config-6.6.21-gentoo .config && make olddefconfig
# Compilation (Gentoo)
# Or use genkernel (automated)
# Distribution kernel (Gentoo, recommended)
# Alternatively: emerge gentoo-sources + manual compilation (more flexible)
DKMS (Dynamic Kernel Module Support)
# Status
# Example: mt7927/2.12, 6.6.21-gentoo, x86_64: installed
# Install modules
# Uninstall/Remove
# Debugging
# DKMS auto-trigger mechanism after new kernel installation:
# @module-rebuild automatically calls dkms autoinstall during installkernel
# Check: eselect kernel list to confirm new kernel is selected, dkms status to confirm state
Module Management
# Temporary load/unload
# Module parameters
# Persistence: echo "options mt7927 param1=value1" > /etc/modprobe.d/mt7927.conf
# Blacklist (prevent loading)
# echo "blacklist nouveau" > /etc/modprobe.d/blacklist.conf
# echo "blacklist mt7927" > /etc/modprobe.d/blacklist-mt7927.conf
# Auto-load (at boot)
# echo "mt7927" > /etc/modules-load.d/mt7927.conf
# Parameters for all loaded modules
initramfs (dracut)
# Generate initramfs
# View initramfs contents
|
# Debug boot issues
# Add to GRUB command line: rd.debug rd.shell
# Enter emergency shell if issues occur:
# Kernel cmdline (GRUB)
# /etc/default/grub:
# GRUB_CMDLINE_LINUX="quiet splash rd.lvm.vg=vg0 resume=/dev/vg0/swap"
Kernel Parameter Tuning (sysctl)
# Temporary settings
# Persistence
# /etc/sysctl.conf or /etc/sysctl.d/99-custom.conf:
# net.ipv4.ip_forward = 1
# vm.swappiness = 10
# Common tuning items
# net.core.default_qdisc = fq # qdisc for BBR
# net.ipv4.tcp_congestion_control = bbr # TCP congestion control
# vm.swappiness = 1 # Avoid swap as much as possible (1 is lowest besides 0)
# kernel.sysrq = 1 # Enable Magic SysRq
# fs.inotify.max_user_watches = 524288 # inotify watch limit (for IDE/LSP with many files)
Kernel Debugging
# Boot parameters (temporary GRUB cmdline change)
# single # Single-user mode (maintenance)
# init=/bin/bash # Enter shell directly (bypass init)
# ignore_loglevel # Display all kernel logs
# rd.break=pre-mount # dracut: Stop before mounting root filesystem
# Magic SysRq (Kernel emergency)
# Alt+SysRq + b → Immediate reboot
# Alt+SysRq + s → Sync disks
# Alt+SysRq + u → Remount read-only
# Alt+SysRq + e → SIGTERM all processes
# Alt+SysRq + i → SIGKILL all processes
# Safe reboot sequence: R E I S U B (or remember: "BUSIER" backwards)
# Post-crash analysis
# Enable kdump with crash tool to analyze vmcore
# Performance observation
&&