This guide describes DRBD version 8.4 and above. For 8.3 please look here.


10.6. Nested LVM configuration with DRBD

It is possible, if slightly advanced, to both use Logical Volumes as backing devices for DRBD and at the same time use a DRBD device itself as a Physical Volume. To provide an example, consider the following configuration:

In order to enable this configuration, follow these steps:

filter = ["a|sd.*|", "a|drbd.*|", "r|.*|"]

This filter expression accepts PV signatures found on any SCSI and DRBD devices, while rejecting (ignoring) all others.

After modifying the lvm.conf file, you must run the vgscan command so LVM discards its configuration cache and re-scans devices for PV signatures.

write_cache_state = 0

After disabling the LVM cache, make sure you remove any stale cache entries by deleting /etc/lvm/cache/.cache.

pvcreate /dev/sda1
Physical volume "/dev/sda1" successfully created
pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
vgcreate local /dev/sda1 /dev/sda2
Volume group "local" successfully created
lvcreate --name r0 --size 10G local
Logical volume "r0" created
resource r0 {
  device /dev/drbd0;
  disk /dev/local/r0;
  meta-disk internal;
  on <host> { address <address>:<port>; }
  on <host> { address <address>:<port>; }
}

After you have created your new resource configuration, be sure to copy your drbd.conf contents to the peer node.

drbdadm primary r0
pvcreate /dev/drbd0
Physical volume "/dev/drbd0" successfully created
vgcreate replicated /dev/drbd0
Volume group "replicated" successfully created
lvcreate --name foo --size 4G replicated
Logical volume "foo" created
lvcreate --name bar --size 6G replicated
Logical volume "bar" created

The Logical Volumes foo and bar will now be available as /dev/replicated/foo and /dev/replicated/bar on the local node.

To make them available on the peer node, first issue the following sequence of commands on the local node:

vgchange -a n replicated
0 logical volume(s) in volume group "replicated" now active
drbdadm secondary r0

Then, issue these commands on the peer node:

drbdadm primary r0
vgchange -a y replicated
2 logical volume(s) in volume group "replicated" now active

After this, the block devices /dev/replicated/foo and /dev/replicated/bar will be available on the peer node.


This guide describes DRBD version 8.4 and above. For 8.3 please look here.