Often users want to make existing data highly available with WinDRBD. This article is a short guide that explains how to do that.
This article assumes that you have existing data on an NTFS or ReFS file system on a Windows node. The Windows node may be either Windows Server 2016, 2019, or 2022, or Windows 10, or Windows 11. You also need a second node, that is reachable over a network, to replicate data to. This may be another Windows node or a Linux node. This guide also assumes that you have some kind of service (such as an MS SQL server instance or a Hyper-V hypervisor instance). At a later point in this guide, you will stop that service. Be aware of this so that you can announce a scheduled downtime for the service if you have end users that rely on it.
Step 1: Downloading and Installing WinDRBD
To download and install WinDRBD you can use the installation program packages provided by LINBIT® on their Downloads page, under the DRBD® 9 Windows Driver section. Note that at least WinDRBD 1.1.6 is required for the following steps to work. The installation program is a self-extracting archive so to install WinDRBD simply run the downloaded file on your Windows nodes.
Step 2: Finding a Place for Metadata
When reusing existing partitions you have to use external metadata. To do this, you have to provide storage for approximately 2-10% of the size of the original data partitions. If there are no more places to store the metadata on the node, then you will have to shrink the original file system. You will then have to make the partition that backs the file system smaller. Then you will have to create an extra partition for the DRBD metadata in the new free space on the disk that resulted from the partition shrink operation.
Step 3: Setting Up and Configuring the Backup Node
To replicate your data, you need a separate node. This can be a Windows or Linux node. Create a block device (Linux) or virtual disk (Windows) of exactly the same size as the data partition that you want to replicate (after shrinking it, if you did so). If the remote node is a Windows node, then you also have to open a TCP/IP port for WinDRBD to connect.
Step 4: Creating a DRBD Configuration File
When creating the DRBD configuration file, you have to fill out the disk and meta-disk fields in the volume section of the nodes. Be extra careful not to confuse these parameters or data might get lost! Also, most of the time you will want to use the drive letter of the existing partition for the new replicated partition, if your second node is a Windows node. So it is recommended to use the partition's GUID for addressing the data disk. You can find the GUID with the `mountvol` utility. It will output something like:
In this example, add the following to your DRBD configuration file (inside the volume section):
Also add an entry for the metadata partition that you created in the previous step. For example:
For the device parameter, you only have to assign a unique minor number. For example:
device minor 48;
Note that in a WinDRBD configuration file, everything else (on sections, IP addresses, node id's) works exactly as in the Linux version of DRBD. Also note that in earlier WinDRBD versions the device clause featured an optional drive letter. Starting from WinDRBD 1.1.4 this drive letter is ignored. You have to assign a drive letter later by using a partition manager.
Step 5: Stopping the Service
You are now about to start WinDRBD, so for a short time you need to stop any service that uses the data that you want to replicate. You can do this, for example, with the `sc` command:
sc stop <name-of-service>
Step 6: Bringing the Resource Online
After creating a resource file on both nodes, you can check it with the following command (replacing "myres" with your resource name):
drbdadm dump myres
If the `drbdadm dump` command does not show any errors, you can create the metadata by entering the following command:
drbdadm create-md myres
Then you can bring up the resource:
drbdadm up myres
As part of the attach disk process, WinDRBD will modify the boot sector of the device such that the device is considered a RAW device by the Windows system. This is necessary since otherwise Windows would write to the backing device which would result in data corruption.
Next, on the node where the existing data is located, put the node into a DRBD Primary role for the resource:
drbdadm primary --force myres
The `--force` parameter tells DRBD to consider the existing data partition as UpToDate. If you don't specify `--force` the command will fail.
Step 7: Moving the Drive Letter
Next, delete the drive letter from the old data partition and assign it to the new data partition. When you ran the `drbdadm primary` command, a virtual disk with one partition was created (Note again that you need at least WinDRBD 1.1.4). Assign the desired drive letter to that partition. You might have to bring the disk "online" or make the disk readable/writeable before you can use it. You can do this either by using Partition Manager (start it from Control Panel / System) or on the command line by using the `diskpart` command.
Step 8: Restarting the Service
Finally, you can restart your services (such as MS SQL Server) and the service's data will be replicated in real time now. Note that you don't need to wait until the DRBD resync has finished. This can run in the background and you can use the partition immediately.
Created 2023/02/15 – JT
Reviewed 2023/02/16 – MAT