This site best when viewed with a modern standards-compliant browser. We recommend Firefox Get Firefox!.

Linux-HA project logo
Providing Open Source High-Availability Software for Linux and other OSes since 1999.

USA Flag UK Flag

Japanese Flag


About Us

Contact Us

Legal Info

How To Contribute

Security Issues

This web page is no longer maintained. Information presented here exists only to avoid breaking historical links.
The Project stays maintained, and lives on: see the Linux-HA Reference Documentation.
To get rid of this notice, you may want to browse the old wiki instead.

1 February 2010 Hearbeat 3.0.2 released see the Release Notes

18 January 2009 Pacemaker 1.0.7 released see the Release Notes

16 November 2009 LINBIT new Heartbeat Steward see the Announcement

Last site update:
2014-04-19 10:56:11

Howto Build and Install DRBD

  • Note that for most distributions, official distribution packages of DRBD are available. You only need to read this, if for some reason you want to build your own packages.

These are the steps to build and install DRBD on your system. It should work for SuSE, Debian, RH and other distros with slight modifications.

  • This was written for 0.6.10, and might not work for releases before that, since we changed our Makefile to use the top level kernel source Makefile, so we no longer need to worry about all those funny kernel compile flags... It is still correct for 0.6.13. With some special notes,

    it is still valid for for 0.7.x, too.

I tried to indicate what you should type by the prompt-prefix on the below command lines. all#, when it is the same for all distros, and e.g. suse#, when I think this is specific for suse, in which case I try to point out the alternatives for the different distributions in turn.

For FAQs, publications and other stuff see also the documentation subdirectory in the DRBD tarball, the other DRBD related pages, and of course .

Other helpful links:


  • You need to install the kernel-source package. Or, if you run the default distribution kernel, and there is some "precompiled kernel headers" directory, you can skip this, and compile against that directory of header files. If so, skip the "Prepare" section, and just jump to "Build DRBD".
     rpm.distros# rpm -Uhv kernel-source-2.4.XX-YYY.rpm
          debian# apt-get install kernel-source tar --bzip2 -xvf linux-2.4.XX.tar.bz2

    Note: this is really kernel-source.rpm, NOT kernel.src.rpm. You don't want to use the latter, unless you know exactly why...

    If you want to use a 2.6.x kernel, you need to use DRBD-0.7.; 0.6 just won't compile.

    Obviously you should have a build-system installed, i.e. gcc, make, etc. ;) You should make sure that the gcc you use to compile the module is the same which was used to build the kernel you are running. On recent SuSE this is gcc-3.2, and the default gcc anyways -- just mentioned here in case you installed gcc 2.9x for some other thingy, and then wonder why kernel modules no longer work properly. Note: for a 2.2.x kernel, you need to add a line to kernel/ksyms.c, see debian/kernel-export-wup.patch . But who cares for 2.2, nowadays? So what next?

Prepare the kernel source tree

  •        all# cd /usr/src/linux
       ... or wherever your kernel source happens to be, e.g.
        fedora# cd /usr/src/linux-2.4
           all# make mrproper   # just to be sure;
                                # if you know what it does, you know when you can skip it
    This clones the configuration of the currently running kernel into the kernel source configuration.
       suse# make cloneconfig
    If this did not work, you do not run a shipped version of the SuSE kernel, so you should know how to cope with it... As a hint: copy in the configuration you used to build the

    running kernel into ./.config, then do two times "yes '' | make -s oldconfig" and continue as below. If nothing helps, build a new kernel, or revert to the shipped ones! (If you want to compile your own kernel, you should be using debian or gentoo or rock or something, anyways...) On some distros this step is basically:

       some# zcat /proc/config.gz > .config
           # yes "" | make -s oldconfig ; yes "" | make -s oldconfig
    The redhat way seems to be:
       redhat# cp /boot/kernel-2.4.some-thing.config  .config
            or cp /boot/config-2.4-somthing-whatever  .config
             # make -s oldconfig_nonint ; make -s oldconfig_nonint
       fedora# cp /boot/config-2.4.some-thing  .config
             # export CC=gcc32
             # vi Makefile #mod EXTRAVERSION to match installed kernel
             # yes "" | { make oldconfig ; make oldconfig ; } 
    • Note:
      If you consider to not run some vendor kernel, but compile your own kernel, you need to build in module support, since DRBD is a module. DRBD depends on procfs, but you want to have that anyways. Make sure that you do not compile NBD into the kernel, since DRBD uses the same major device number. Having it as module is ok, but you cannot use both at the same time.

      • Update
        since we now (0.7.1 and later) have an officially assigned device major number (147) and device nodes (/dev/drbd), we no longer hijack NBDs major numbers. You now in fact can use NBD in parallel with DRBD, if it makes any sense in your setup...

    So if necessary, make menuconfig and adapt to your own preferences, but then you need to compile and install this kernel. Modules compiled against this kernel source tree will only work properly with a matching kernel.

    Don't forget

       all# make dep # not neccessary with 2.6 kernels
       all# make include/linux/version.h
         and, starting with 2.6.6
         (for some distros [suse, maybe others] 2.6.5-something)
       all# make modules_prepare

Build DRBD kernel module (outside of the kernel source)

  • unpack the DRBD tgz, I suggest to unpack it into /usr/src/drbd-<version>

       all# cd /usr/src
       all# tar -xvzf where/you/downloaded/it/drbd-0.6.12.tar.gz
    Now build the module.

    Note: On some distros (redhat/fedora typically), you first need to have a look into ./drbd_config.h (which should be a symlink to drbd/linux/drbd_config.h, and (un)comment some of the settings appropriately. Since 0.7.3, we have script/, which helps you with this, and gets called during the normal build process, so you "should" no longer need to adjust it by hand.

           all# cd drbd-0.6.12/drbd  # kernel module sub directory
           all# make clean all
        fedora# make clean all CC=gcc32
    BTW, this expects the kernel source to be in

    /lib/modules/`uname -r`/build If you want to compile against some other kernel source tree, which might be differently configured, or even configured for a different architecture, instead try:

       all# make clean ; make KDIR=/path/to/kernel/source
    On some systems you may need to explicitly set the compiler to use

    with e.g. make ... CC=gcc32. Note that it should build against preconfigured kernel-headers, too,

    like in make KDIR=/usr/src/linux-include/athlon. But then you should be very sure that your running kernel matches the configuration of that header tree exactly. Or for Debian:

       /usr/src/modules/drdb # dpkg-buildpackage -us -uc -b

Patching DRBD into the kernel

  • This is an alternative to the make all in the previous section, and the only way to compile DRBD as part of the kernel itself (not as module). Since 0.7, you can ask for a kernel patch. You then can verify this patch, and apply it to the kernel source tree.

       make KDIR=/usr/src/linux-2.6.x kernel-patch
       cd /usr/src/linux-2.6.x
       patch -p1 < $OLDPWD/patch-linux-2.6.x-drbd-0.7_whatever

    Now, with make menuconfig or make xconfig, you should find DRBD in the block-devices menu, select it as module, or as part of the kernel.

    Rebuild the kernel modules (make modules; make modules_install), or rebuild and install the new kernel (make bzImage or make linux ARCH=um or ...)

Build DRBD user space tools only

  • If you took the "patch kernel" approach, you still need to build the user space tools.
        all# cd /usr/src/drbd-0.6.12/user
        all# make
        or with drbd-0.7 simply
        all# make tools

Install it

  • If the above steps went ok, you just need to install it.
        all# cd /usr/src/drbd-0.6.12
        all# make install
       If you patched the kernel, you obviously only want to
        all# make install-tools

Configure it

  • If you have not used DRBD before, have browse on You should find some interesting stuff on the "Documentation" and "Publications" sub pages. In any case, have a look at the example configuration file in

    ./scripts/drbd.conf, which is well commented. Maybe we added a new config option, or deprecated an other ;)

Why ... ?

  • Why did I not just make ; make install in the toplevel directory of the drbd source? Because I seem to be too stupid to get my docbook environment right, and I don't want to screw up the precompiled documentation and man-pages that come with the .tar.gz ...

    Note: since 0.7, to rebuild the documentation, you need to explicitly ask for it: make doc


  • Added on your feedback and request, if necessary... ;-)

    Also, have a look at the DRBD/FAQ, and the other links mentioned at the top of this page.

Building a .rpm of it

  • This should be fairly easy, there is an example spec

    file, and you can even make rpm. If this is a CVS/SVN version, you might need to say make rpm FORCE=1.

    There are caveats, please have a look at ./README, too, you might want/need to edit the ./drbd.spec{.in} file. Note that it should build against preconfigured kernel-headers, too,

    like in make rpm KDIR=/usr/src/linux-include/athlon, make rpm KDIR=/usr/src/linux-include/smp, ...

    You then should find packages in dist/{S,}RPMS/*/*.rpm:


Building a .deb of it

  • Have a look into the ./debian/* example files in place.

    also, see DRBD/HowTo/PackageForDebian, originally posted as

       From: Jens Benecke
       Subject: [DRBD-dev] Re: RFC: new ./INSTALL hints
       Date: Wed, 24 Dec 2003 13:14:23 +0100

Hope this helped, cheers and have fun ...

-- LarsEllenberg