Automatically Mount DRBD device at boot

They may be occasions where it is required to mount the DRBD device at boot outside of pacemaker. While not common, we can accomplish this via a systemd unit file.

Usually, this isn't regarded as a best practice, but there may be some occasions where this is applicable and desired.

In this example we'll mount /dev/drbd0 on /drbd/r0 upon boot. Create a systemd unit file named /etc/systemd/system/drbd-r0.mount (you must name it with the mount path as the name, substituting dashes for slashes). The contents of this unit file should look like the example below:

[Unit]

Description=Mount DRBD device

After=network.target

After=drbd.service


[Mount]

What=/dev/drbd0

Where=/drbd/r0

Type=xfs

Options=defaults


[Install]

WantedBy=multi-user.target

Lastly, make sure you've enabled DRBD® and this custom systemd unit at boot.

 # systemctl daemon-reload

# systemctl enable drbd.service drbd-r0.mount

 

Reviewed 2020/11/30 – DGT