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 |
kernel-dev, kernel-headers
, linux-headers
or
similar. In this case, you can skip Section 4.3.2, “Preparing the kernel source tree”
and continue with Section 4.3.3, “Preparing the DRBD build tree”.
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-version
, with the symlink /usr/src/linux
pointing
to that directory.
In this case of building DRBD against kernel sources (not headers), you must continue with Section 4.3.2, “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-version
, or simply a
symbolic link named /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 mrproper
Now it is time to clone your currently running kernel configuration into the kernel source tree. There are a few possible options for doing this:
/proc
filesystem,
enabling you to copy from there:
$ zcat /proc/config.gz > .config
cloneconfig
target, so on those
systems, you can issue:
$ make cloneconfig
/boot
, which
allows you to do this:
$ cp /boot/config-`uname -r` .config
.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 |
---|---|
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 |
---|---|---|---|
| Installation directory prefix |
| This is the default to maintain Filesystem Hierarchy Standard compatibility for locally installed, unpackaged software. In packaging, this is typically overridden with /usr+. |
| Local state directory |
| Even with a default |
| System configuration directory |
| Even with a default |
| Build the DRBD kernel module | no | Enable this option when you are building a DRBD kernel module. |
| 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. |
| Build DRBD Heartbeat integration | yes | You may disable this option unless you are planning to use DRBD’s Heartbeat v1 resource agent or |
| Build DRBD Pacemaker integration | yes | You may disable this option if you are not planning to use the Pacemaker cluster resource manager. |
| 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. Please note that you will need to pass |
| Build DRBD Xen integration | yes (on x86 architectures) | You may disable this option if you are not planning to use the |
| Build programmable bash completion for | 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 |
| 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 Section 4.4, “Building a DRBD RPM package”. |
Most users will want the following configuration options:
$ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-km
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.
Building userspace utilities requires that you
configured DRBD with the --with-utils
option, which is enabled by default.
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.
Building the DRBD kernel module requires that you
configured DRBD with the --with-km
option, which is disabled by default.
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/
symlink.uname -r
/build
If the /lib/modules/
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 uname -r
/build/usr/src/linux-version/include
— the
DRBD build process also looks for the kernel Makefile and
configuration file (.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.38/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