7

I am building custom linux kernel packages in a Ubuntu 13.10 amd64 environment using
apt-get source linux-image-$(uname -r)
the debian way make-kpkg clean;fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers.

Linux headers is larger than image

The result are two .deb files where the file linux-headers- is 8.2M in size and the resulting linux-image- is only 6.1M. After having a look in what files the linux-image- contains, I see that there are loads of headers for items which are disabled in the .config file.

Linux-headers-... content

  • unused file systems, like /fs/reiserfs/,
  • unused security modules, like /security/selinux/,
  • unused includes, like /include/pcmcia/ or /include/sound/,
  • unused architectures, like /arch/powerpc/, /arch/s390/, /arch/parisc/, /arch/blackfin/, /arch/cris/, /arch/xtensa/, /arch/alpha/, /arch/ia64/, /arch/h8300/, /arch/arm/, etcetera,
  • unused drivers, like /drivers/leds/, /drivers/eisa/, /drivers/isdn/, /drivers/net/ppp/, /drivers/net/wireless/, etcetera,
  • unused networking like /net/bluetooth/, /net/wimax/, /net/decnet/, etcetera

What (and how) are the options for stripping the unused items out of the linux-headers- package and/or otherwise reduce the file size?

7
  • Why do you want to reduce linux-headers package size? Mar 14, 2014 at 9:40
  • 1
    May be I don't need the linux-headers- package to create and use a working custom linux kernel at all, and just strip the kernel_headers from fakeroot make-kpkg.
    – Pro Backup
    Mar 14, 2014 at 10:29
  • You can find details about the Debian way of debian compilation here - unix.stackexchange.com/a/115921/4671 . This answer needs to be cleaned up, but I haven't got around to it. Feel free to add questions/comments. Mar 15, 2014 at 12:29
  • 1
    The linux-headers package is only needed when you want to compile sources, kernels or build other packages. They are also not a part of a system runtime. So precisely spoken there is no use-case for stripping unused header files.
    – user55518
    Mar 22, 2014 at 1:33
  • @bersch Without a better answer, I am willing to award your comment the bounty.
    – Pro Backup
    Mar 23, 2014 at 10:55

1 Answer 1

5
+50

The linux-headers package is only needed when you want to compile sources, kernels or build other packages.

Package description from debian:

This package provides the architecture-specific kernel header files for Linux kernel 2.6.32-5-686, generally used for building out-of-tree kernel modules. These files are going to be installed into /usr/src/linux-headers-2.6.32-5-686, and can be used for building modules that load into the kernel provided by the linux-image-2.6.32-5-686 package.

kernel-headers are also not a part of a system runtime. So precisely spoken there is no use-case for stripping unused header files from the package. However the original description restricts this by saying generally and limits it's usage to build kernel modules. If you are running a custom kernel which was built with kpkg, then you may also relink your /usr/include/{linux,asm,asm-generic} headers to be able to properly compile other sources.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .