mkfs.ext3: Wrong medium type while trying to determine filesystem size


While going through a DRBD howto a coworker made, I came across the following problem. On a freshly created DRBD block device, mkfs bails out with the following message:

mkfs.ext3 /dev/drbd0 mke2fs 1.39 (29-May-2006) mkfs.ext3: Wrong medium type while trying to determine filesystem size


The DRBD block device you’re trying to access is configured to act as a Secondary device, which means it cannot be accessed to be read ot to be written to.
The state of your device is kept in /proc/drbd:

cat /proc/drbd
version: 8.3.2 (api:88/proto:86-90) GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
0: cs:SyncSource ro:Secondary/Secondary ds:UpToDate/Inconsistent B r---- ns:10159548 nr:0 dw:0 dr:10167296 al:0 bm:620 lo:11 pe:5 ua:253 ap:0 ep:1 wo:b oos:202535316
[>....................] sync'ed:  4.8% (197788/207708)M finish: 0:57:20 speed: 58,832 (54,620) K/sec

The part ro:Secondary/Secondary tells you what both nodes are set to.

Another way to check the state of the block device is with the drbdadm command:

drbdadm state drbd0 Secondary/Secondary


Switch the DRBD block device to Primary using drbdadm:

drbdadm primary drbd0

This shouldn’t generate any output if it doesn’t encounter any errors.
If you get an error message about multiple primaries:

Multiple primaries not allowed by config

Then you already have a running master in your setup, you only need to switch machines, since you are currently working on the wrong one.