4.5. Building a DRBD Debian package

The DRBD build system contains a facility to build Debian packages directly out of the DRBD source tree. For building Debian packages, Section 4.3.1, “Checking build prerequisites” applies essentially in the same way as for building and installing with make, except that you of course also need the dpkg-dev package containing the Debian packaging tools, and fakeroot if you want to build DRBD as a non-root user (highly recommended).

Also, see Section 4.3.2, “Preparing the kernel source tree” if you are not building against a running kernel with precompiled headers available.

The DRBD source tree includes a debian subdirectory containing the required files for Debian packaging. That subdirectory, however, is not included in the DRBD source tarballs — instead, you will need to create a Git checkout of a tag associated with a specific DRBD release.

Once you have created your checkout in this fashion, you can issue the following commands to build DRBD Debian packages:

$ dpkg-buildpackage -rfakeroot -b -uc
[Note]Note

This (example) drbd-buildpackage invocation enables a binary-only build (-b) by a non-root user (-rfakeroot), disabling cryptographic signature for the changes file (-uc). Of course, you may prefer other build options, see the dpkg-buildpackage man page for details.

This build process will create two Debian packages:

After you have created these packages, you can install, upgrade, and uninstall them as you would any other Debian package in your system.

Building and installing the actual kernel module from the installed module source package is easily accomplished via Debian’s module-assistant facility:

# module-assistant auto-install drbd8

You may also use the shorthand form of the above command:

# m-a a-i drbd8

Note that any kernel upgrade will require you to rebuild the kernel module (with module-assistant, as just described) to match the new kernel. The drbd8-utils and drbd8-module-source packages, in contrast, only need to be recreated when upgrading to a new DRBD version. If at any time you upgrade to a new kernel and new DRBD version, you will need to upgrade both packages.