2

To write Ansible script to setup DRBD device and file systems, I face the following issue:

# blockdev --report /dev/drbd0
RO    RA   SSZ   BSZ   StartSec            Size   Device
blockdev: cannot open /dev/drbd0: Wrong medium type

I would have expected DRBD device to implement block device operations like any md device.

I run a Debian Linux Jessie/stable with package

drbd-utils 8.9.2~rc1-2+deb8 amd64 RAID 1 over TCP/IP for Linux (user utilities)

Is there any way to get usable device size ?

Yves Martin
  • 879
  • 3
  • 7
  • 21

2 Answers2

2

Depending on your version of the drbd utils, you could use:

drbdsetup status /dev/drbd0 --verbose --statistics

which will give you something along the lines of:

home node-id:1 role:Secondary suspended:no
    write-ordering:none
  volume:0 minor:0 disk:UpToDate
      size:1048412 read:0 written:1048412 al-writes:0 bm-writes:48 upper-pending:0 lower-pending:0 al-suspended:no blocked:no
  nina local:ipv4:10.9.9.111:7001 peer:ipv4:10.9.9.103:7010 node-id:0 connection:Connected role:Secondary
      congested:no
    volume:0 replication:Connected disk:UpToDate resync-suspended:no
        received:1048412 sent:0 out-of-sync:0 pending:0 unacked:0
  nino local:ipv4:10.9.9.111:7021 peer:ipv4:10.9.9.129:7012 node-id:2 connection:Connected role:Secondary
      congested:no
    volume:0 replication:Connected disk:UpToDate resync-suspended:no
        received:0 sent:0 out-of-sync:0 pending:0 unacked:0
  nono local:ipv4:10.9.9.111:7013 peer:ipv4:10.9.9.138:7031 node-id:3 connection:WFConnection
gxx
  • 5,483
  • 2
  • 21
  • 42
  • thanks for the idea but it is difficult to extract only information I requested, aka size in blocks, to be used in an Ansible playbook or a shell script – Yves Martin Sep 20 '16 at 08:52
  • @YvesMartin Isn't the fourth line reading `size: ...` something you could work with? – gxx Sep 20 '16 at 09:47
  • As your command replies "received netlink error reply: Operation not supported", I guess my device /dev/drbd0 is really usable yet... – Yves Martin Sep 20 '16 at 12:13
  • I created another question about my "real" issue http://serverfault.com/questions/804217/drbd-on-raw-disk-block-device – Yves Martin Sep 20 '16 at 12:55
2

My trouble was to try to use /dev/drbd0 before device is really usable, aka when drbdadm cstate data confirms it is in Connected or SyncSource state.

By the way, when ready, blockdev operations are available for /dev/drbd0, or size can be queried directly from /sys/block/drbd0/size

Yves Martin
  • 879
  • 3
  • 7
  • 21