I’ve seen a lot of people posting about this problem but it is very hard to find a good resolution. Here is what the error will typically look like:
filer1:~# drbdadm secondary r0 /dev/drbd0: State change failed: (-12) Device is held open by someone Command 'drbdsetup 1 secondary' terminated with exit code 11
You will typically run into this scenario when attempting to force a DRBD primary node into a secondary status for testing or manual failover purposes. This is a common task. This error could, in some cases, be triggered by a process that is attempting to use the device in question. But I find this to be rather unlikely.
With DRBD, most people are running Linux’ LVM volume manager on top of DRBD. LVM, if still active, will keep DRBD from moving into a secondary mode. If we know this then the problem is easy to solve. The vgchange command will allow us to deactivate the volume group in question so that DRBD can successfully change the state of the system. The “-an” option is used for this.
vgchange -an /dev/drbd0
Most likely this will resolve your error. Obviously use your own volume group name.