Linux kernel deb packages

Building Kernel DEB packages

Recent kernel versions (as of 2013) no longer need tinkering to get usable headers.

Newer versions

# 1 $ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-$KVER.tar.xz # 2 $ cd /usr/src $ tar xvf linux-$KVER.tar.xz # 3: Patches, see below # 4.1 $ cd /usr/src/linux-$KVER $ cp /boot/config-`uname -r` .config $ make oldconfig # OR 4.2 $ cd /usr/src/linux-$KVER $ make xconfig # make config for textual interface, make menuconfig for curses interface # 5: The configuration option CONFIG_LOCALVERSION defines a string attached to the kernel version, e.g. "-1" $ sed 's/CONFIG_LOCALVERSION=.*$/CONFIG_LOCALVERSION="-1"/' .config # 6 $ make deb-pkg
linux-image-$KVER$REV_$KVER$REV$REV_$ARCH.deb # Kernel and modules linux-headers-$KVER$REV_$KVER$REV$REV_$ARCH.deb # Headers necessary to build external modules linux-firmware-image_$KVER$REV$REV_$ARCH.deb # Firmware files from the kernel sources as of version $KVER linux-libc-dev_$KVER$REV$REV_$ARCH.deb # Kernel-related headers

Older versions

NOTE These instructions are copied from the old guide I used to have here.

With semi-modern kernels it’s very simple. Here the version will include the pathlevel (2.6.x.y instead of 2.6.x), and AFAIK you can change the package revision but not install different builds of the same 2.6.x.y version in parallel.

I’m not yet too used to this method so I might be missing something. I don’t yet know if there’s a standard way to create a headers deb.

$ wget http://kernel.org/pub/linux/kernel/v2.6/linux-$KVER.tar.bz2 $ tar jxvf linux-$KVER.tar.bz2 && cd linux-$KVER (patches) (make config) $ fakeroot make KDEB_PKGVERSION=$KVER+$REV deb-pkg (KDEB_PKGVERSION *must* start with a number)

Example:
With KVER=2.6.32.41 and REV=toi-1 this will produce packages linux-image-2.6.32.41_2.6.32.41+toi-1_amd64.deb and linux-firmware-image_2.6.32.41+toi-1_all.deb .
Where kernel package name is linux-image-2.6.32.41 and version 2.6.32.41+toi-1 .

Kernel version ( $ uname -r ) will be 2.6.32.41, modules will go into /lib/modules/2.6.32.41 .

Headers

NOTE This notes have not much hand-holding, don’t mess with this unless you know what you’re doing.

Debian’s linux-headers packages (used to build out-of-tree modules) won’t be created from an older pristine kernel.

To have a viable homebrewed tree to build modules, clean the tree and remove unneeded files:

(Replace $YOURARCH with your architecture, x86_64 users should use x86)

$ cd /usr/src/. /linux-source-$KVER $ make clean prepare # prepare is required for building out-of-tree modules $ mkdir /usr/src/linux-headers-$KVER+$REV $ tar -c --exclude '*.c' --exclude '*.o' --exclude '*.ko' arch/$YOURARCH include scripts Makefile .config Module.symvers | ( cd /usr/src/linux-headers-$KVER+$REV ; tar xv )

Note this self-baked tree contains much more cruft than a proper linux-headers package, but I’m unsure on what to remove.

Читайте также:  Zabbix agent install oracle linux

You’ll have to fix the /lib/modules/$KVER/build link unless you build the package in the correct path (/usr/src/linux-headers-$KVER+$REV).

From Debian-packaged sources

Important The package will contain a couple symlinks to the build location (its real path), so use an appropriate directory name under /usr/src . Using headers will allow a linux-headers package to fill in the links.

# 1 # apt-get install linux-source-$KVER build-essential kernel-package fakeroot # 2 $ cd /usr/src $ mkdir linux-headers-$KVER-$REV $ tar -jxv --strip-components=1 -C linux-headers-$KVER-$REV -f linux-source-$KVER.tar.bz2 # 3: Patches, see below # 4.1 $ cd /usr/src/linux-$KVER $ cp /boot/config-`uname -r` .config $ make oldconfig # OR 4.2 $ cd /usr/src/linux-$KVER $ make xconfig # make config for textual interface, make menuconfig for curses interface # 5 $ make-kpkg --rootcmd fakeroot --revision $EPOCH:$KVER~$X --append-to-version -$X-$ARCH --arch_in_name --initrd -j $NCPUS kernel_image kernel_headers
$ make-kpkg --rootcmd fakeroot --revision 2:2.6.32~3+toi --append-to-version -3-amd64+toi --arch_in_name --initrd -j 2 kernel_image kernel_headers
linux-image-2.6.32-3-amd64+toi_2.6.32~3+toi_amd64.deb # Kernel and modules linux-headers-2.6.32-3-amd64+toi_2.6.32~3+toi_amd64.deb # Kernel headers to build modules

Using an epoch ensures no Debian package will overwrite the customised version.

Package linux-image-* will contain a couple links to the build location, if the corresponding linux-headers-* isn’t installed these links will be removed. You can recreate the links by installing linux-headers-$KVER-$REV and re-installing linux-image-$KVER-$REV .

After installing the customised linux-image package you might need to manually create an initrd if it wasn’t done automatically.

# update-initramfs -k $VER-$REV -c # update-grub # Run ALWAYS after calling update-initramfs

Notes

Huge package/modules

Beware when importing configuration from a Debian kernel, if debugging symbols are enabled ( CONFIG_DEBUG_KERNEL option), the resulting package will be huge.

Quick way to re-configure it:

$ sed -i '/CONFIG_DEBUG_KERNEL/d' .config

Patches

TuxOnIce

Download TOI patch for the appropriate kernel version from http://www.tuxonice.net/. If not available, a close enough version MIGHT work.

# 1 $ cd /usr/src && wget http://www.tuxonice.net/downloads/all/tuxonice-$TUXONICEVER-for-$KVER.patch.bz2 # 2 $ cd linux-$KVER $ bzcat ../tuxonice-$TUXONICEVER-for-$KVER.patch.bz2 | patch -p1

Installing tuxonice-userui package is a good idea.

Debian-packaged

Some patches are available as debian packages, e.g. linux-patch-debianlogo .

The patch files can be found at /usr/src/kernel-patches/diffs/$PATCHNAME/$PATCH-$CLOSESTVERSION.gz .

Читайте также:  Подключение к linux telnet

1) Where $KVER is the kernel version, $ARCH is the host architecture codename and $REV is the revision

Источник

Linux kernel deb packages

This is an obsolete now guide on how to build the Linux Kernel into a .deb package. Don’t use this, or take with a grain of salt. Instead, see https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official

Install the Required Packages

  • build-essential — Essential packages required for compiling.
  • linux-source — The Linux Kernel Source
  • libncurses5-dev — Development files for ncurses5. Optional for using curses based menu driven configuration.
  • sudo apt-get install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison

Extracting the Kernel Source

Under /usr/src you will find a file looking like linux-source-x.x.tar.xz. Please note that x.x will match the current Linux Kernel source for your release of Debian. In this example we will be using the 4.15 Kernel under Sid.

Configuring the Kernel

Using your current Debian kernel configuration as a starting point

Alternatively, you can use the configuration from a Debian-built kernel that you already have installed by copying the /boot/config-* file to .config and then running make oldconfig to only answer new questions.

If you do this, ensure that you modify the configuration to set:

CONFIG_SYSTEM_TRUSTED_KEYS = ""

otherwise the build may fail:

make[4]: *** No rule to make target 'debian/certs/test-signing-certs.pem', needed by 'certs/x509_certificate_list'. Stop. make[4]: *** Waiting for unfinished jobs.

Building the Debian Package

This will take quite some time and it’s worth noting that it doesn’t necessarily have to be done on the target machine (or even the target architecture, search in your engine of choice for kernel cross-compiling if you want to set it up). Choosing your most powerful machine may reduce the time of this operation from many hours to under 1.

It’s also worth noting that if you’re using not much of a deviation from the default configuration that ships with debian, you’ll need upwards of about 7GB or so of space to do this operation.

The first one will replace your current default menulist item in grub upon installation. This means that if you install it then next time you reboot, you’ll boot into that kernel.

Читайте также:  Intel cpu monitor linux

The second are debug symbols for the first. This is useful if say, you want to do kernel debugging. It’s worth noting that when extracted the debug symbols are about 5GB.

See also

The «Compiling a Kernel» section in the Debian Administrator’s Guide (WARNING: outdated)

Источник

How to build the mainline kernel source package?

Ubuntu kernel PPA only provides linux-headers*.deb and linux-image*.deb packages. How can I build the corresponding linux-source*.deb package ? Context: I’m currently running Ubuntu 11.10 with the mainline kernel (3.2 rc6 now) to get a better support for my sandybridge IGP (Dell E6420 laptop with intel i5-2520M CPU). Appears, i’d like to install this touchpad driver, ALPS touchpads being badly supported (see previous link bug report), while waiting for upstream support in kernel version 3.3. Problem is, DKMS keeps complaining about not finding the full kernel source:

Module build for the currently running kernel was skipped since the kernel source for this kernel does not seem to be installed. 
  1. Uncompressing the kernel.org source archive in /usr/src/ . DKMS still complaining.
  2. Manually updating the kernel source package with uupdate and the mainline source package like explained here. Did not succeed.
  3. Manually building the linux-source package following @roadmr and @elmicha instructions. I eventually succeeded to build it but DKMS still complained about the missing source.
  4. At last I noticed an error I did not catch in the first place while reinstalling the kernel headers. Appears the .deb I got may have been corrupted, downloading it again did the trick 🙂 Alas, while DKMS agreed to compile the module i ran into the following error which appears to have already been reported. This issue isn’t yet solved but I won’t try to because of the following: in the end I decided to test the precise kernel version 3.2-rc6 through the xorg-edgers ppa which appears to be correctly patched: it works.

Nevertheless, it might still be of some interest to know how to build the mainline linux-source package as the Ubuntu Kernel Team doesn’t provide it. Not to mention that I learned a lot in the process ^^

Источник

Оцените статью
Adblock
detector