Before being able to build DRBD from source, your build host must fulfill the following prerequisites:
make, gcc, the glibc
development libraries, and the flex scanner
generator must be installed.
![]() | Note |
|---|---|
You should make sure that the |
For building directly from a git checkout, GNU Autoconf is also required. This requirement does not apply when building from a tarball.
If you are running a stock kernel supplied by your
distribution, you should install a matching precompiled
kernel headers package. These are typically named
kernel-dev, kernel-headers,
linux-headers or similar. In this case, you
can skip the section called “Preparing the kernel source tree” and
continue with the section called “Preparing the DRBD build tree”.
If you are not running a distribution stock kernel
(i.e. your system runs on a kernel built from source with
a custom configuration), your kernel source files must be
installed. Your distribution may provide for this via its
package installation mechanism; distribution packages for
kernel sources are typically named
kernel-source or similar.
![]() | Note |
|---|---|
On RPM-based systems, these packages will be named
similar to
|
"Vanilla" kernel tarballs from the kernel.org archive
are simply named linux-version-tar.bz2 and should be
unpacked in
/usr/src/linux-, with
the symlink version/usr/src/linux pointing
to that directory.
In this case of building DRBD against kernel sources (not headers), you must continue with the section called “Preparing the kernel source tree”.
To prepare your source tree for building DRBD, you must
first enter the directory where your unpacked kernel sources
are located. Typically this is
/usr/src/linux-,
or simply a symbolic link named
version/usr/src/linux:
cd /usr/src/linux
The next step is recommended, though not strictly
necessary. Be sure to copy your existing
.config file to a safe location before
performing it. This step essentially reverts your kernel
source tree to its original state, removing any leftovers from
an earlier build or configure run:
make mrproperNow it is time to clone your currently running kernel configuration into the kernel source tree. There are a few possible options for doing this:
Many reasonably recent kernel builds export the
currently-running configuration, in compressed form, via
the /proc filesystem, enabling you
to copy from there:
zcat /proc/config.gz > .config
SUSE kernel Makefiles include a
cloneconfig target, so on those systems,
you can issue:
make cloneconfig
Some installs put a copy of the kernel config into
/boot, which allows you to do
this:
cp /boot/config-`uname -r` .config
Finally, you may simply use a backup copy of a
.config file which you know to have
been used for building the currently-running
kernel.
Any DRBD compilation requires that you first
configure your DRBD source tree with the included
configure script.
![]() | Note |
|---|---|
The information in this section applies to DRBD 8.3.6
and above. Up until release 8.3.5, DRBD had no
When building from a git checkout, the
|
Invoking the configure script with the
--help option returns a full list of supported
options. The table below summarizes the most important ones:
Table 4.1. Options supported by DRBD's configure script
| Option | Description | Default | Remarks |
|---|---|---|---|
--prefix | Installation directory prefix | /usr/local | This is the default to maintain Filesystem
Hierarchy Standard compatibility for locally
installed, unpackaged software. In packaging, this is
typically overridden with
/usr. |
--localstatedir | Locate state directory | /usr/local/var | Even with a default prefix, most
users will want to override this with
/var. |
--sysconfdir | System configuration directory | /usr/local/etc | Even with a default prefix, most
users will want to override this with
/etc. |
--with-km | Build the DRBD kernel module | no | Enable this option when you are building a DRBD kernel module. |
--with-utils | Build the DRBD userland utilities | yes | Disable this option when you are building a DRBD kernel module against a new kernel version, and not upgrading DRBD at the same time. |
--with-heartbeat | Build DRBD Heartbeat integration | yes | You may disable this option unless you are planning to use DRBD's Heartbeat v1 resource agent or dopd. |
--with-pacemaker | Build DRBD Pacemaker integration | yes | You may disable this option if you are not planning to use the Pacemaker cluster resource manager. |
--with-rgmanager | Build DRBD Red Hat Cluster Suite integration | no | You should enable this option if you are planning to use DRBD with rgmanager, the Red Hat Cluster Suite cluster resource manager. |
--with-xen | Build DRBD Xen integration | yes (on x86 architectures) | You may disable this option if you are not
planning to use the block-drbd
helper script for Xen integration. |
--with-bashcompletion | Build programmable bash completion for drbdadm | yes | You may disable this option if you are using a shell other than bash, or if you do not want to utilize programmable completion for the drbdadm command. |
--enable-spec | Create a distribution specific RPM spec file | no | For package builders only: you may use this option if you want to create an RPM spec file adapted to your distribution. See also the section called “Building a DRBD RPM package”. |
The configure script will adapt your DRBD build to distribution specific needs. It does so by auto-detecting which distribution it is being invoked on, and setting defaults accordingly. When overriding defaults, do so with caution.
The configure script creates a log file,
config.log, in the directory where it was
invoked. When reporting build issues on the mailing list, it is
usually wise to either attach a copy of that file to your email,
or point others to a location from where it may be viewed or
downloaded.
![]() | Important |
|---|---|
Building userspace utilities requires that you configured DRBD with
the |
To build DRBD's userspace utilities, invoke the following commands from the top of your DRBD checkout or expanded tarball:
$make$sudo make install
This will build the management utilities
(drbdadm, drbdsetup, and
drbdmeta), and install them in the
appropriate locations. Based on the other
--with options selected during the configure stage, it
will also install scripts to integrate DRBD with other
applications.
![]() | Important |
|---|---|
Building the DRBD kernel module requires that you configured DRBD with
the |
After changing into your unpacked DRBD sources
directory, you should now change into the kernel module
subdirectory, simply named drbd, and
build the module there:
cd drbd make clean all
This will build the DRBD kernel module to match your
currently-running kernel, whose kernel source is expected to
be accessible via the /lib/modules/`uname -r`/build
symlink.
If the /lib/modules/`uname -r`/build
symlink does not exist, and you are
building against a running stock kernel (one that was
shipped pre-compiled with your distribution), you may also
set the KDIR variable to point to the
matching kernel headers (as opposed to
kernel sources) directory. Note that besides the actual
kernel headers — commonly found in
/usr/src/linux-
— the DRBD build process also looks for the
kernel Makefile and configuration file
(version/include.config), which pre-built kernel
headers packages commonly include. To build against
precompiled kernel headers, issue, for example:
$cd drbd$make clean$make KDIR=/lib/modules/2.6.31/build
If you are building DRBD against a kernel
other than your currently running one,
and you do not have precompiled kernel sources for your
target kernel available, you need to build DRBD against a
complete target kernel source tree. To do so, set the
KDIR variable to point to the kernel
sources directory:
$cd drbd$make clean$make KDIR=/path/to/kernel/source
You also have the option of setting the compiler
explicitly via the CC variable. This is
known to be necessary on some Fedora versions, for example:
cd drbd make clean make CC=gcc32