Comparing with ‘normal’ Linux kernel build, the ‘official’ Linux kernel build for each distribution is confusing and awkward. Debian 7.1 Wheezy may be friendly but still needs cautions. The good thing is you do not need to patch the original kernel with the Debian patches yourself. Have fun!
1. Get the official Debian kernel source pkg
apt-get source linux
This cmd will download the corresponding Debian kernel source pkg based on your current `uname -r`. After download the pkg, Debian pkg management will install the pkg into /usr/src. Moreover, the Debian patches would be patched automatically, which may be the best thing for official kernel build!
debian:/usr/src# apt-get source linux
Reading package lists… Done
Building dependency tree
Reading state information… Done
NOTICE: ‘linux’ packaging is maintained in the ‘Svn’ version control system at:
svn://svn.debian.org/svn/kernel/dists/trunk/linux/
Need to get 69.2 MB of source archives.
Get:1 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (dsc) [103 kB]
Get:2 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (tar) [65.9 MB]
Get:3 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (diff) [3,225 kB]
Fetched 69.2 MB in 6min 36s (175 kB/s)
gpgv: keyblock resource `/root/.gnupg/trustedkeys.gpg’: file open error
gpgv: Signature made Sat 08 Jun 2013 05:56:06 PM PDT using RSA key ID 95861109
gpgv: Can’t check signature: public key not found
dpkg-source: warning: failed to verify signature on ./linux_3.2.46-1.dsc
dpkg-source: info: extracting linux in linux-3.2.46
dpkg-source: info: unpacking linux_3.2.46.orig.tar.xz
dpkg-source: info: unpacking linux_3.2.46-1.debian.tar.xz
dpkg-source: info: applying debian/version.patch
dpkg-source: info: applying debian/kernelvariables.patch
dpkg-source: info: applying bugfix/all/kbuild-Fix-missing-n-for-NEW-symbols-in-yes-make-old.patch
dpkg-source: info: applying bugfix/x86/viafb-autoload-on-olpc-xo1.5-only.patch
dpkg-source: info: applying bugfix/all/cifs-fix-potential-buffer-overrun-when-composing-a-new-options.patch
debian:/usr/src#
debian:/usr/src# ll
total 67588
drwxr-xr-x 24 root root 4096 Jul 28 11:28 linux-3.2.46
-rw-r–r– 1 root root 3224676 Jun 8 18:56 linux_3.2.46-1.debian.tar.xz
-rw-r–r– 1 root root 103051 Jun 8 18:56 linux_3.2.46-1.dsc
-rw-r–r– 1 root root 65871748 Jun 8 18:56 linux_3.2.46.orig.tar.xz
debian:/usr/src#
2. Before you start the build, make sure you have some tools installed besides the ones needed by the ‘normal’ Linux kernel build…
apt-get install debhelper
apt-get install gcc-4.6
apt-get install xmlto
apt-get install filterdiff
3. Choose the arch for your machine and trigger the build only for that arch – to save time and storage!
fakeroot make -f debian/rules.gen setup_i386_none_686-pae
cd /usr/src/linux-3.2.46/debian/build/build_i386_none_686-pae
make menuconfig
cd ../../..
fakeroot make -f debian/rules.gen binary-arch_i386_none_686-pae binary-indep
DEBIAN_KERNEL_JOBS=${NR_CPUS}
debian:/usr/src# ll
total 349864
drwxr-xr-x 24 root root 4096 Jul 28 20:36 linux-3.2.46
-rw-r–r– 1 root root 3224676 Jun 8 18:56 linux_3.2.46-1.debian.tar.xz
-rw-r–r– 1 root root 103051 Jun 8 18:56 linux_3.2.46-1.dsc
-rw-r–r– 1 root root 65871748 Jun 8 18:56 linux_3.2.46.orig.tar.xz
-rw-r–r– 1 root root 6383274 Jul 29 11:50 linux-doc-3.2_3.2.46-1_all.deb
-rw-r–r– 1 root root 597596 Jul 29 11:00 linux-headers-3.2.0-4-686-pae_3.2.46-1_i386.deb
-rw-r–r– 1 root root 22920680 Jul 29 10:44 linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb
-rw-r–r– 1 root root 255994142 Jul 29 11:00 linux-image-3.2.0-4-686-pae-dbg_3.2.46-1_i386.deb
-rw-r–r– 1 root root 2942958 Jul 29 11:51 linux-manual-3.2_3.2.46-1_all.deb
-rw-r–r– 1 root root 200430 Jul 29 11:00 xen-linux-system-3.2.0-4-686-pae_3.2.46-1_i386.deb
debian:/usr/src#
4. Install the new kernel image and reboot the machine
dpkg -i linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb
debian:/usr/src# dpkg -i linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb
(Reading database … 184013 files and directories currently installed.)
Preparing to replace linux-image-3.2.0-4-686-pae 3.2.46-1 (using linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb) …
Unpacking replacement linux-image-3.2.0-4-686-pae …
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Setting up linux-image-3.2.0-4-686-pae (3.2.46-1) …
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
update-initramfs: Generating /boot/initrd.img-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Generating grub.cfg …
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.2.0-4-686-pae
Found initrd image: /boot/initrd.img-3.2.0-4-686-pae
done
debian:/usr/src#
5. Trigger new build with certain code changes by deleting the build timestamp
rm debian/stamps/build_i386_none_686-pae_plain
6. Reference
https://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage
apt-get install filterdiff should be:
apt-get install patchutils