#-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- #-_ Jeremy's Debian Kernel Compile Guide release 3 _- #-_ http://www.dcos.net/projects/debian-kernel-building.text _- #-_ E-Mail: info@dcos.net 23-Feb-2014 _- #-_ licensed: CC-BY-SA updated11-Oct-2023 _- #-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- #edit debian kernel maintainer information: nano /etc/kernel-pkg.conf Unknown Kernel Package Maintainer #add a non root user to the /usr/src group for write access: adduser a_username_here src #install dependencies: libncurses5-dev build-essential fakeroot kernel-package cramfsprogs initrd-tools aptitude #ubuntu specific dependencies: kernel-wedge #grsec/pax specific dependencies: gcc--plugin-dev #alternative dependencies install method: apt-get build-dep linux #configure the kernel: copy an old .config you have preconfigured from a prior kernel version to the new tree. not doing this is fine also. make olddefconfig #defaults assumed make localmodconfig #only the hardware modules required by system. modifies the .config in the directory. dont do this as a distrobution maintainer. make menuconfig #you will need to verify that localmodconfig did not disable any modules you use. (examples: tun/tap, virtio, loop, vfat) #cleanup: make-kpkg --rootcmd fakeroot clean && make-kpkg --rootcmd fakeroot modules_clean #build kernel packages like this: time fakeroot make -j$(getconf _NPROCESSORS_ONLN) #or like this: export CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) && time fakeroot make-kpkg --revision "1" --initrd buildpackage #or like this: export CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) && time fakeroot make-kpkg --revision "1" --initrd kernel_image kernel_headers kernel_source #utilizing distcc: MAKEFLAGS="HOSTCC=/usr/bin/gcc CCACHE_PREFIX=distcc" a_build_command_here_from_above #install: sudo dpkg -i ../*.deb && reboot #force to keep kernel manually updated: #in aptitude press / for search then find your kernel image and mark it as hold state. may as well remove old kernels while your in there. #building out of kernel release modules: man module-assistant #updating a debian initramfs from running kernel: sudo update-initramfs -uk $(uname -r) #a way to make a semi manual initramfs of running kernel; certainly not customized: cd /boot && sudo mkinitramfs -k -o initrd.img-$(uname -r) $(uname -r) sudo update-grub #note: grsec/pax anonymous mapping mmap might break some qemu emulated archs. gives kernel warnings. #note2: update-grub has major problems running if the current active kernel is grsec/pax enabled #note3: manually updating /boot/grub/grub.cfg is not that hard if note2 is affecting you. note 2023+: s/deb-pkg/bindeb-pkg/ March 16, 2023 linux kernel git commit 05e96e96a315fa49faca4da2aedd1761a218b616 kbuild: use git-archive for source package creation Commit 5c3d1d0 ("kbuild: add a tool to list files ignored by git") added a new tool, scripts/list-gitignored. My intention was to create source packages without cleaning the source tree, without relying on git. Linus strongly objected to it, and suggested using 'git archive' instead. [1] [2] [3] This commit goes in that direction - Remove scripts/list-gitignored.c and rewrites Makefiles and scripts to use 'git archive' for building Debian and RPM source packages. It also makes 'make perf-tar*-src-pkg' use 'git archive' again. Going forward, building source packages is only possible in a git-managed tree. Building binary packages does not require git. So according to the above commit, just use "make bindeb-pkg" or if you want to build src pkg using "make deb-pkg" like before (pre 6.3), then you have to git pull the kernel source tree. #since this is a public document here is some legal areas #sources used/references: as of feb-20-2014 all sourced used where CC-BY-SA or a compatible release licenses. http://debian-handbook.info/browse/stable/sect.kernel-compilation.html http://users.wowway.com/~zlinuxman/Kernel.htm http://newbiedoc.sourceforge.net/system/kernel-pkg.html http://r.outlyer.net/debian:kerneldeb http://www.tecmint.com/kernel-compilation-in-debian-linux/ 2023 refrences: