Creating a filesystem on a DRBD device prepares the replicated block device for a normal Linux mount point. The format belongs on the Primary DRBD volume, so the filesystem metadata is written through DRBD and replicated to the peer nodes instead of being created on one backing disk only.
DRBD exposes each volume as a block device, commonly through /dev/drbd/by-res/<resource>/<volume>. In single-primary mode, a conventional filesystem such as ext4 or XFS can sit on that DRBD device because only one node writes to it at a time.
Formatting destroys any existing data on the selected volume. Confirm the resource is UpToDate, confirm the intended node is Primary, and avoid manual formatting when Pacemaker, DRBD Reactor, LINSTOR, or another manager already owns filesystem creation and mounting for the resource.
Related: How to create DRBD metadata
Related: How to promote a DRBD resource to primary
Related: How to check DRBD resource status
$ sudo drbdadm status wwwdata
wwwdata role:Primary
volume:0 disk:UpToDate
node-b role:Secondary
volume:0 peer-disk:UpToDate
Stop when the local role is not Primary, the local disk is not UpToDate, or another connected node is also Primary for a normal single-primary filesystem.
$ ls -l /dev/drbd/by-res/wwwdata/0 lrwxrwxrwx 1 root root 16 Jun 19 10:15 /dev/drbd/by-res/wwwdata/0 -> ../../../drbd1000
Use the /dev/drbd/by-res path when it exists. It ties the command to the resource name and volume number instead of a remembered DRBD minor number.
$ sudo wipefs --no-act /dev/drbd/by-res/wwwdata/0
No output means wipefs found no filesystem or partition signature. If output appears, stop and confirm that the existing data can be replaced.
$ sudo mkfs.ext4 -L wwwdata /dev/drbd/by-res/wwwdata/0 mke2fs 1.47.2 (1-Jan-2025) Creating filesystem with 2621440 4k blocks and 655360 inodes Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
This command overwrites the selected DRBD volume. Run it once on the intended Primary node, not separately on each peer.
$ sudo blkid /dev/drbd/by-res/wwwdata/0 /dev/drbd/by-res/wwwdata/0: LABEL="wwwdata" UUID="d007763d-183d-4b46-b851-b950bd7b7544" BLOCK_SIZE="4096" TYPE="ext4"
The UUID belongs to the filesystem on the DRBD device. Use this value only after confirming the device path points to the intended resource.
$ sudo mkdir --parents /srv/wwwdata
$ sudo mount -t ext4 /dev/drbd/by-res/wwwdata/0 /srv/wwwdata
$ findmnt /srv/wwwdata --output TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /srv/wwwdata /dev/drbd1000 ext4 rw,relatime
$ sudo touch /srv/wwwdata/drbd-write-test
$ ls -l /srv/wwwdata/drbd-write-test -rw-r--r-- 1 root root 0 Jun 19 10:18 /srv/wwwdata/drbd-write-test
A successful file create on the mounted path proves the filesystem accepts writes through the Primary DRBD volume.
$ sudo rm /srv/wwwdata/drbd-write-test
$ sudo umount /srv/wwwdata
Keep the filesystem mounted only when this node should continue owning the application path manually. Cluster-managed resources should normally be mounted by the manager's filesystem resource.