Resizing DRBD without LVM

Given:

Wanted:

The official documentation of DRBD describes online and offline growth (http://www.drbd.org/users-guide-emb/s-resizing.html). Both didn't work in my case. So I came up with these steps:

  1. Backup your data!
  2. Disable DRBD on the secondary node, e.g. chkconfig drbd off, or crm node standby if you're using Pacemaker
  3. Power off the secondary node
  4. Resize the disk of the secondary node
  5. Power on the secondary node
  6. Resize /dev/sdb1 on the secondary node by calling sfdisk -uS /dev/sdb. It'll show the current partitions, e.g.:
    [root@drbd2 ~]# sfdisk -uS /dev/sdb
    Checking that no-one is using this disk right now ...
    OK
    
    Disk /dev/sdb: 208050 cylinders, 16 heads, 63 sectors/track
    Old situation:
    Units = sectors of 512 bytes, counting from 0
    
       Device Boot    Start       End   #sectors  Id  System
    /dev/sdb1          2048 125829119  125827072  83  Linux
    /dev/sdb2             0         -          0   0  Empty
    /dev/sdb3             0         -          0   0  Empty
    /dev/sdb4             0         -          0   0  Empty
    Input in the following format; absent fields get a default value.
    <start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>
    Usually you only need to specify <start> and <size> (and perhaps <type>).
    
    sfdisk now asks for a new partition scheme. For sdb1 adapt the current start value (2048) only. For sdb2 to sdb4 enter 0 as start value and as size:
    /dev/sdb1 :2048
    /dev/sdb1          2048 209715199  209713152  83  Linux
    /dev/sdb2 :0 0
    /dev/sdb2             0         -          0   0  Empty
    /dev/sdb3 :0 0
    /dev/sdb3             0         -          0   0  Empty
    /dev/sdb4 :0 0
    /dev/sdb4             0         -          0   0  Empty
    New situation:
    Units = sectors of 512 bytes, counting from 0
    
       Device Boot    Start       End   #sectors  Id  System
    /dev/sdb1          2048 209715199  209713152  83  Linux
    /dev/sdb2             0         -          0   0  Empty
    /dev/sdb3             0         -          0   0  Empty
    /dev/sdb4             0         -          0   0  Empty
    Warning: partition 1 does not start at a cylinder boundary
    I don't like this - probably you should answer No
    Do you want to write this to disk? [ynq] 
    
    Then enter y, press Enter, and sfdisk will hopefully say something like:
    Successfully wrote the new partition table
    
    Re-reading the partition table ...
    
  7. Manually start DRBD once (service drbd start) to move its meta data the end of the partition:
    [root@drbd2 ~]# service drbd start
    Starting DRBD resources: [
         create res: drbd0
       prepare disk: drbd0
        adjust disk: drbd0Internal drbd meta data successfully moved.
    
         adjust net: drbd0
    ]
    .
    
  8. If you're using Pacemaker, shutdown DRBD (service drbd stop) and take the secondary node online (crm node online). Otherwise, enable DRBD at system boot again (chkconfig drbd on)
  9. Disable DRBD on the primary node (see step 2)
  10. Power off the primary node
  11. Resize the disk of the primary node
  12. Power on the primary node
  13. Resize /dev/sdb1 on the primary node (see step 6)
  14. On the secondary node, read /proc/drbd and note the value of oss:
    [root@drbd2 ~]# cat /proc/drbd 
    version: 8.4.1 (api:1/proto:86-100)
    GIT-hash: 91b4c048c1a0e06777b5f65d312b38d47abaea80 build by
    root@drbd.intra.ogris.net, 2012-11-23 17:30:18
     0: cs:WFConnection ro:Secondary/Unknown ds:UpToDate/DUnknown C r-----
        ns:0 nr:4 dw:4 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:62911580
    
  15. Manually start DRBD once (service drbd start) on the primary node (see step 7)
  16. On the secondary node, read /proc/drbd again and compare the value of oss:
    [root@drbd2 ~]# cat /proc/drbd 
    version: 8.4.1 (api:1/proto:86-100)
    GIT-hash: 91b4c048c1a0e06777b5f65d312b38d47abaea80 build by
    root@drbd.intra.ogris.net, 2012-11-23 17:30:18
     0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
        ns:0 nr:4 dw:8 dr:1029 al:1 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:104853340
    
    (Yes, this was a resize from 60 to 100 GB)
  17. On both nodes, check /var/log/messages or the output of dmesg. You'll find something like:
    kernel: block drbd0: drbd_bm_resize called with capacity == ......
    
  18. Repeat step 8 on the primary node
  19. On the secondary node, finally resize the filesystem, e.g.: resize2fs /dev/drbd0