5

We have DRBD volumes shared between 2 servers. There is typically a filesystem directly on each volume rather than stacked LVM etc. On a server with a DRBD volume as primary, how do I tell if it is in use or not? I can tell if it is mounted directly using e.g. /proc/mounts, but there may also be e.g. a XEN VM using the volume.

I can run drbdadm secondary and see if it errors with "Device is held open by someone". Is there any way to tell without actually making the device secondary?

A bonus would be to tell how many processes have the device open (OK, there should only ever be 1, but...), and to identify what holds it open.

3 Answers3

3

Disclaimer: It's been a while since I last used DRBD, so there might be a better way to do what you want.

You try to "demote" your Primary to Secondary and "promote" the Secondary to Primary back. If the operation succeeds, it means no one was using your distributed volume. If the operation fails, it means someone is holding a volume lock. Refer to the official documentation for more details.

https://linbit.com/drbd-user-guide/users-guide-drbd-8-4/#s-resource-roles

RiGiD5
  • 1,859
3

DRBD works, but it's prone to split-brain issues if not carefully managed, leading to potential data loss or corruption. It’s also less suited for modern, scalable workloads.

https://www.ipserverone.info/knowledge-base/how-to-fix-drbd-recovery-from-split-brain/

For a more scalable solution, Ceph is a better option. It avoids the pitfalls of DRBD, offers block, object, and file storage, and handles failures more gracefully with auto-healing and replication.

https://docs.ceph.com/en/reef/architecture/

NISMO1968
  • 1,583
fopsik
  • 685
-4

lsof and fuser are typically what I'll use.

lsof is a utility that lists open files, directories, block files, etc. in Linux. For example, I'm running a dd on a DRBD device in the background, and can see that process in the lsof output:

# lsof /dev/drbd1000 
COMMAND     PID USER   FD   TYPE   DEVICE   SIZE/OFF NODE NAME
dd      2537055 root    1w   BLK 147,1000 0xb34ed000 1877 /dev/drbd1000

fuser displays the PIDs of processes using the specified files or file systems. Fuser will also show kernel processes, like a mounted device. For example, I've formatted and mounted the DRBD device on /mnt:

# fuser -vm /dev/drbd1000 
                     USER        PID ACCESS COMMAND
/dev/drbd1000:       root     kernel mount /mnt