How to correctly set the size of the disk, when replacing, if I want to use the original disk size?
The volume of the new disk is 4 Gb, but I want to use only the volume that was used before and is used on the disk of another node (2 Gb).
Resource:
resource res-vdb {
device drbd_res_vdb1 minor 1;
disk /dev/vdb;
meta-disk internal;
protocol C;
on node01 {
address 192.168.0.1:7005;
}
on node02 {
address 192.168.0.2:7005;
}
}
Do I understand correctly that I can take the size from lsblck or from /sys/block/drbd1/size and set in res config before drbdadm create-md and drbdadm attach?
i.e. config:
resource res-vdb {
device drbd_res_vdb1 minor 1;
disk /dev/vdb;
meta-disk internal;
protocol C;
disk {
size 2097052K; <==== 2GB
}
on node01 {
address 192.168.0.1:7005;
}
on node02 {
address 192.168.0.2:7005;
}
}
You're correct in that you can set the size in the DRBD res file before you
create-mdandattachin order to explicitly set the size of the DRBD device.As you've also suggested, you can retrieve the exact size of the DRBD device in various ways, including using
lsblkor inspecting the kernel settings withcat /sys/block/drbd1/size, run from the peer node.However, when you use
lsblk, it's going to do some rounding. DRBD's parser doesn't seem to accept bytes (B) as a valid unit (withdrbd-utilsversion 9.13.1 seems to only likeKB,MB, andGB), so you might be better off setting the size in sectors (s).The size you find in
/sys/block/drbd1/sizeis already in sectors, so an example would be:All that said, because DRBD auto-negotiates the device size among it's peers, you could simply,
drbdadm create-md res-vdb,drbdadm up res-vdb, and it should just work.