In order to prepare a DRBD resource for use as a Physical Volume, it is necessary to create a PV signature on the DRBD device. In order to do so, issue one of the following commands on the node where the resource is currently in the primary role:
# pvcreate /dev/drbdX
or
# pvcreate /dev/drbd/by-res/<resource>/0
![]() | Note |
---|---|
This example assumes a single-volume resource. |
Now, it is necessary to include this device in the list of devices LVM
scans for PV signatures. In order to do this, you must edit the LVM
configuration file, normally named
/etc/lvm/lvm.conf
. Find the line in the
devices
section that contains the filter
keyword and edit it
accordingly. If all your PVs are to be stored on DRBD devices, the
following is an appropriate filter
option:
filter = [ "a|drbd.*|", "r|.*|" ]
This filter expression accepts PV signatures found on any DRBD devices, while rejecting (ignoring) all others.
![]() | Note |
---|---|
By default, LVM scans all block devices found in |
If you want to use stacked resources as LVM PVs, then you will need a more explicit filter configuration. You need to make sure that LVM detects PV signatures on stacked resources, while ignoring them on the corresponding lower-level resources and backing devices. This example assumes that your lower-level DRBD resources use device minors 0 through 9, whereas your stacked resources are using device minors from 10 upwards:
filter = [ "a|drbd1[0-9]|", "r|.*|" ]
This filter expression accepts PV signatures found only on the DRBD
devices /dev/drbd10
through /dev/drbd19
, 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.
You may of course use a different filter
configuration to match your
particular system configuration. What is important to remember,
however, is that you need to
In addition, you should disable the LVM cache by setting:
write_cache_state = 0
After disabling the LVM cache, make sure you remove any stale cache
entries by deleting /etc/lvm/cache/.cache
.
You must repeat the above steps on the peer node.
![]() | Important |
---|---|
If your system has its root filesystem on LVM, Volume
Groups will be activated from your initial ramdisk (initrd) during
boot. In doing so, the LVM tools will evaluate an |
When you have configured your new PV, you may proceed to add it to a Volume Group, or create a new Volume Group from it. The DRBD resource must, of course, be in the primary role while doing so.
# vgcreate <name> /dev/drbdX
![]() | Note |
---|---|
While it is possible to mix DRBD and non-DRBD Physical Volumes within the same Volume Group, doing so is not recommended and unlikely to be of any practical value. |
When you have created your VG, you may start carving Logical Volumes
out of it, using the lvcreate
command (as with a non-DRBD-backed Volume Group).