Resizing resources

Growing on-line

If the backing block devices can be grown while in operation (online), it is also possible to increase the size of a DRBD device based on these devices during operation. To do so, two criteria must be fulfilled:

  1. The affected resource's backing device must be one managed by a logical volume management subsystem, such as LVM or EVMS.

  2. The resource must currently be in the Connected connection state.

Having grown the backing block devices on both nodes, ensure that only one node is in primary state. Then enter on one node:

drbdadm resize resource

This triggers a synchronization of the new section. The synchronization is done from the primary node to the secondary node.

Growing off-line

When the backing block devices on both nodes are grown while DRBD is inactive, and the DRBD resource is using external meta data, then the new size is recognized automatically. No administrative intervention is necessary. The DRBD device will have the new size after the next activation of DRBD on both nodes and a successful establishment of a network connection.

If however the DRBD resource is configured to use internal meta data, then this meta data must be moved to the end of the grown device before the new size becomes available. To do so, complete the following steps:

[Warning]Warning

This is an advanced procedure. Use at your own discretion.

  1. Unconfigure your DRBD resource:

    drbdadm down resource
  2. Save the meta data in a text file prior to shrinking:

    drbdadm dump-md resource > /tmp/metadata

    You must do this on both nodes, using a separate dump file for every node. Do not dump the meta data on one node, and simply copy the dump file to the peer. This will not work.

  3. Grow the backing block device on both nodes.

  4. Adjust the size information (la-size-sect) in the file /tmp/metadata accordingly, on both nodes. Remember that la-size-sect must be specified in sectors.

  5. Re-initialize the metadata area:

    drbdadm create-md resource
  6. Re-import the corrected meta data, on both nodes:

    drbdmeta_cmd=$(drbdadm -d	dump-md test-disk)
    ${drbdmeta_cmd/dump-md/restore-md} /tmp/metadata
     Valid meta-data in place, overwrite? [need to type 'yes' to confirm] yes
     Successfully restored meta data

    [Note]Note

    This example uses bash parameter substitution. It may or may not work in other shells. Check your SHELL environment variable if you are unsure which shell you are currently using.

  7. Re-enable your DRBD resource:

    drbdadm up resource
  8. On one node, promote the DRBD resource:

    drbdadm primary resource
  9. Finally, grow the file system so it fills the extended size of the DRBD device.

Shrinking on-line

[Warning]Warning

Online shrinking is only supported with external metadata.

Before shrinking a DRBD device, you must shrink that the layers above DRBD, i.e. usually the file system. Since DRBD cannot ask the file system how much space it actually uses, you have to be careful in order not to cause data loss.

[Note]Note

Whether or not the filesystem can be shrunk on-line depends on the filesystem being used. Most filesystems do not support on-line shrinking. XFS does not support shrinking at all.

To shrink DRBD on-line, issue the following command after you have shrunk the file system residing on top of it:

drbdadm -- --size=new-size resize resource

You may use the usual multiplier suffixes for new-size (K, M, G etc.). After you have shrunk DRBD, you may also shrink the containing block device (if it supports shrinking).

Shrinking off-line

If you were to shrink a backing block device while DRBD is inactive, DRBD would refuse to attach to this block device during the next attach attempt, since it is now too small (in case external meta data is used), or it would be unable to find its meta data (in case internal meta data are used). To work around these issues, use this procedure (if you cannot use on-line shrinking):

[Warning]Warning

This is an advanced procedure. Use at your own discretion.

  1. Shrink the file system from one node, while DRBD is still configured.

  2. Unconfigure your DRBD resource:

    drbdadm down resource
  3. Save the meta data in a text file prior to shrinking:

    drbdadm dump-md resource > /tmp/metadata

    You must do this on both nodes, using a separate dump file for every node. Do not dump the meta data on one node, and simply copy the dump file to the peer. This will not work.

  4. Shrink the backing block device on both nodes.

  5. Adjust the size information (la-size-sect) in the file /tmp/metadata accordingly, on both nodes. Remember that la-size-sect must be specified in sectors.

  6. Only if you are using internal metadata (which at this time have probably been lost due to the shrinking process), re-initialize the metadata area:

    drbdadm create-md resource
  7. Re-import the corrected meta data, on both nodes:

    drbdmeta_cmd=$(drbdadm -d	dump-md test-disk)
    ${drbdmeta_cmd/dump-md/restore-md} /tmp/metadata
       Valid meta-data in place, overwrite? [need to type 'yes' to confirm] yes
       Successfully restored meta data

    [Note]Note

    This example uses bash parameter substitution. It may or may not work in other shells. Check your SHELL environment variable if you are unsure which shell you are currently using.

  8. Re-enable your DRBD resource:

    drbdadm up resource