Configuring Disk Mirroring For Windows Server 2012
Configuring Disk Mirroring For Windows Server 2012
Microsoft Corporation
Abstract
One way to avoid the risk of data loss is to set up a RAID configuration. In Windows
Server® 2012, you can set up disk mirroring (RAID1) for the operating system volume using tools
included in Windows Server. Such a disk mirror does not prevent corruption or other errors, so
you should also back up data regularly. This document details the steps to follow to set up the
operating system volume mirror for both BIOS-based and UEFI-based systems.
Copyright information
This document is provided “as-is”. Information and views expressed in this document, including
URL and other Internet Web site references, may change without notice. You bear the risk of
using it.
This document does not provide you with any legal rights to any intellectual property in any
Microsoft product. You may copy and use this document for your internal, reference purposes.
Microsoft, Active Directory, Hyper-V, Windows, Windows Server, and Windows Vista are
trademarks of the Microsoft group of companies.
In Windows Server® 2012, as long as you have one additional hard disk, you can set up mirroring
(RAID1) for the operating system volume using only tools already built into the operating
system. No special software or hardware is required. Once you set up the disk mirror, the
operating system and your data will be present on both boot disks, and the system software will
keep data and changes to the operating system (such as registry updates) in sync on both boot
disks. If the primary boot disk should fail, the computer can switch over and boot from the
secondary boot disk.
Be aware, however, that RAID configurations, including mirrored disks, do not prevent file
corruption or other errors. You should still maintain a plan for backing up data regularly.
This document explains step-by-step how to set up a mirror of the operating system volume
using BCDedit and Diskpart. It also explains how to reset the system to use a single, unmirrored
boot disk, such as during the period until you can replace a failed disk. Separate procedures are
provided for BIOS- and UEFI-based systems. For more information about the differences
between BIOS and UEFI systems, see http://go.microsoft.com/fwlink/?LinkId=184842.
Updates
Windows does not automatically service the contents of the secondary system partition. If you
install any operating system updates or service packs, be sure to manually update the secondary
system partition (the mirror) with the same updates. To do this, be sure to follow Step 3 of the
“Clone the system partition” procedure, where you use the Robocopy.exe command to copy the
contents of the primary system partition to the secondary system partition.
Windows Server Backup automatically selects critical volumes on the primary disk for backup,
but not on the secondary disk. Be sure to configure Windows Server Backup to also select the
relevant volumes on the secondary disk. For more information about critical volumes and
Windows Server Backup in general, see http://go.microsoft.com/fwlink/?LinkID=184843..
If you have used Windows Server Backup to back up either disk in the mirror and if one of those
disks fails, you will not be able to recover either disk from a backup until both disks are present
again. Even though this document provides steps to reconfigure the system to work with one
disk temporarily (see Reconfiguring the mirror after a disk failure), recovery using Windows Server
Backup will not be possible until you have replaced the failed disk.
When the operating system volume is mirrored, Windows Server Backup does not mark the
restored secondary system volume as active by default. In the event that you recover the
secondary disk from a backup, you must manually set the secondary system partition as active.
In UEFI-based systems, the system volume on the secondary disk cannot be backed up with
Windows Server Backup. In the event that you recover the secondary disk from a backup, the
only way to recreate the system volume is to follow the “Clone the system partition from the
primary disk to the secondary disk” procedure in the Creating a mirrored volume section.
Hibernation
The considerations for hibernation of Windows 8 and Windows Server 2012 machines apply to
BIOS, as well as UEFI systems.
Hibernation, after the failure of a mirrored boot volume, may fail and should be disabled. The
setup steps described in this document, as well as the deployment scripts, do not provision for
the use of hibernation of systems on which mirrored boot volumes are deployed.
Hibernation can easily be disabled with the following steps. In an ordinary, elevated command
prompt type:
powercfg.exe /h off
Combination with Storage Spaces
Unused capacity on mirrored dynamic volumes can be used with Storage Spaces if the computer
uses an UEFI instead of a BIOS. The last section of this document describes how to form a
storage pool out of the remaining capacity of the mirrored OS drives and how to reconfigure a
Storage Spaces mirror in the case of disk failure.
Before you create the software mirror, ensure that the boot order in the BIOS is configured to
use the primary disk first and the secondary disk second. Depending on your hardware, you may
need to change the configuration of the disks’ connections. Consult your hardware
documentation for details.
Creating the software mirror (RAID1) of the operating system involves several phases:
3. Clone the system partition from the primary disk to the secondary disk. Computer
firmware requires that each boot disk has a system partition. It is preferable that the first
partition on each disk is the system partition.
4. Mirror the operating system volume from the primary disk to the secondary disk. This is
the key portion of the procedure, which may take the longest to complete, as it scales
directly with the size of the partition.
The following procedures involve creating and using several partitions with unique drive letters.
These procedures are based on a simple retail installation—your installation may have different
drive letters or disk numbers. You can use any drive letters corresponding to the roles in the
table that are appropriate for your system but be careful to alter any commands that refer to
the drive letters or disk numbers accordingly and consistently throughout all of the procedures.
For your reference, the following table clarifies the various volumes and the corresponding
letters as used in the procedures. In the course of the procedures, you will create all of the
partitions in this table except the system partition (S:) on the primary disk and the primary plex
of the operating system volume (C:) on the primary disk.
Similarly, in the following procedures, disk 0 refers to the primary disk and disk 1 refers to the
secondary disk. If the primary and secondary disks are numbered differently on your system,
alter any commands accordingly.
Note
This procedure assumes that the secondary disk contains no data or a partition table. If
you have any important data on the secondary disk, back it up before starting this
procedure.
To disable hibernate
powercfg.exe /h off
To clone the system partition and move the Windows Recovery Environment
First, start Diskpart by typing Diskpart.exe at an elevated command prompt. Then create the
secondary system partition and prepare to copy the contents of the partition using the following
commands at the Diskpart prompt in order:
Select disk 1
active
assign letter=t
select disk 0
select partition 1
assign letter=s
Move Windows RE to the system partition with the following commands at an elevated
command prompt, if it does not reside there yet:
Reagentc.exe /disable
Reagentc.exe /enable
Copy the contents of the primary system partition to the secondary system partition using this
command at an ordinary elevated command prompt (that is, not at a Diskpart prompt):
robocopy.exe s:\ t:\ * /e /copyall /dcopy:t /xf BCD.* /xd "System Volume
Information"
First, start Diskpart by typing Diskpart.exe at an elevated command prompt. If the primary
and secondary disks are not already dynamic disks, convert them to dynamic using the
following commands at the Diskpart prompt in order:
Select disk 1
Convert dynamic
Select disk 0
Convert dynamic
Now that the primary and secondary disks are dynamic disks, mirror the boot volume using
the following commands in order:
select volume=c
Note
This last command commences the mirroring operation immediately.
Depending on the size of the operating system volume, this operation may
proceed quickly or it may take a considerable time—it is best to avoid
restarting the computer until the operation completes.
Entry Description
1. At an elevated command prompt, run Bcdedit.exe /store t:\ boot\BCD /enum all
2. Note the identifier for each of the following entries. You will use these identifiers in
several steps that follow.
Entry Description
3. First, convert the primary plex entries to secondary plex entries in the secondary BCD
store using the following commands at an ordinary elevated command prompt:
4. Remove the remaining primary plex entries from the secondary BCD store by running
the following commands at an elevated command prompt:
2. Note the identifier for each of the following entries. You will use these identifiers in
several steps that follow.
Entry Description
Start Diskpart by typing Diskpart.exe at an elevated command prompt, and then run
the following two commands at the Diskpart prompt:
Select volume=t
remove
Select volume=s
remove
2. Set up and clone the Windows Recovery Environment (Windows RE) on its own partition,
if it is not already configured that way.
3. Clone the system partition from the primary disk to the secondary disk. Computer
firmware requires that each boot disk have a system partition. It is preferable that the first
partition on each disk is the system partition.
4. Mirror the operating system volume from the primary disk to the secondary disk. This is
the key portion of the procedure, which may take the longest to complete.
6. Update the BCD store for the secondary disk: The secondary BCD store should be updated
so that the system can boot from the secondary disk automatically.
7. Update secondary plex entries on the secondary disk.
The following procedures involve creating and using several partitions with unique drive letters.
These procedures are based on a simple retail installation—your installation may have different
drive letters or disk numbers. You can use any drive letters corresponding to the roles in the
table that are appropriate for your system but be careful to alter any commands that refer to
the drive letters or disk numbers accordingly and consistently throughout all of the procedures.
For your reference, the following table clarifies the various volumes and the corresponding
letters as used in the procedures. In the course of the procedures, you will create all of the
partitions in this table except the system partition (S:) on the primary disk and the primary plex
of the operating system volume (C:) on the primary disk.
Note
This procedure assumes that the secondary disk contains no data or a partition table. If
you have any important data on the secondary disk, back it up before starting this
procedure.
Similarly, in the following procedures, disk 0 refers to the primary disk and disk 1 refers to the
secondary disk. If the primary and secondary disks are numbered differently on our system, alter
any commands accordingly.
To disable hibernate
powercfg.exe /h off
To clone the recovery partition
1. First, start Diskpart by typing Diskpart.exe at an elevated command prompt. Then create
the secondary recovery partition using the following commands at the Diskpart prompt in
order:
Select disk 0
Select partition 1
Detail partition
Select disk 1
Convert gpt
Select partition 1
Select partition 1
Select disk 0
Select partition 1
Assign letter=q
Select disk 1
Select partition 1
Assign letter=r
1. Move Windows RE to the primary recovery partition you just created with the following
commands at an elevated command prompt:
Reagentc.exe /disable
Reagentc.exe /enable
2. Copy the contents of the primary recovery partition to the secondary recovery partition
using this command at an ordinary elevated command prompt (that is, not at a Diskpart
prompt):
1. First, start Diskpart by typing Diskpart.exe at an elevated command prompt. Then create
the secondary system partition and prepare to copy the contents of the partition using the
following commands at the Diskpart prompt in order:
Select disk 1
Note: If you are using 4k native HDDs, set the EFI size in the following step to 260
assign letter=t
select disk 0
select partition 2
assign letter=s
2. Copy the contents of the primary system partition to the secondary system partition using
this command at an ordinary elevated command prompt (that is, not at a Diskpart prompt):
robocopy.exe s:\ t:\ * /e /copyall /dcopy:t /xf BCD.* /xd "System Volume
Information"
First, start Diskpart by typing Diskpart.exe at an elevated command prompt. If the primary and
secondary disks are not already dynamic disks, convert them to dynamic using the following
commands at the Diskpart prompt in order:
Select disk 1
Convert dynamic
Select disk 0
Convert dynamic
Now that the primary and secondary disks are dynamic disks, mirror the boot volume using the
following commands in order:
select volume=c
Note
This last command commences the mirroring operation immediately. Depending on
the size of the operating system volume, this operation may proceed quickly or it
may take a considerable time—it is best to avoid restarting the computer until the
operation completes.
1. At an elevated command prompt, run bcdedit.exe /enum all and note the identifier for the
Windows Boot Manager entry which has the description Windows Boot Manager or
Windows Boot Manager – Primary Disk.
2. If the description for this entry is already Windows Boot Manager – Primary Disk, proceed to
the next step. Otherwise, run bcdedit.exe / set {identifier} description “Windows Boot
Manager – Primary Disk”, where {identifier} is the identifier from Step 1.
Note
Be sure to include the curly brackets whenever you enter an {identifier}.
3. Run bcdedit.exe /copy {identifier} /d “Windows Boot Manager – Secondary Disk”, where
{identifier} is the identifier from Step 1. Note the identifier for the entry Windows Boot
Manager – Secondary Disk.
4. Run bcdedit.exe /set {identifier} device partition=t:, where {identifier} is the identifier you
noted for Windows Boot Manager – Secondary Disk in the previous step.
Entry Description
2. Note the identifier for each of the following entries. You will use these identifiers in several
steps that follow.
Entry Description
3. First, convert the primary plex entries to secondary plex entries in the secondary BCD store
using the following commands at an ordinary elevated command prompt:
4. Remove the remaining primary plex entries from the secondary BCD store by running the
following commands at an elevated command prompt:
5. Update the secondary plex entries in the secondary BCD store by running the following
commands at an elevated command prompt:
4. Once the computer has restarted, start Diskpart by typing Diskpart.exe at an elevated
command prompt, and then run the following commands at the Diskpart prompt:
Select disk 0
Select partition 2
Assign letter=s
Select disk 1
Select partition 2
Assign letter=t
8. At the ordinary elevated command prompt, run bcdedit.exe /enum all and note the
identifier for the entry Firmware Application {101fffff} with the description Windows Boot
Manager – Primary Disk.
11. Run bcdedit /enum firmware and note the identifier for the entry Windows Boot Manager
with the description Windows Boot Manger – Secondary Disk.
12. Run bcdedit /delete {identifier} where {identifier} is the identifier you noted in the previous
step.
13. Run bcdedit /set {bootmgr} description “Windows Boot Manager – Secondary Disk”
14. Run bcdedit /enum firmware and note the identifier for the entry Firmware Application
{101fffff} with the description Windows Boot Manager – Primary Disk.
15. Run bcdedit.exe /set {fwbootmgr} displayorder {identifier} /addfirst, where {identifier} is
the identifier you noted in the previous step.
16. Restart the computer through the primary system partition with the command
shutdown.exe /r /t 0
Once you have configured the disk mirror as described in this document, if the primary
operating system disk completely fails, the computer should switch to booting from the
mirrored operating system on the secondary disk. However, at that point the computer once
again has effectively only a single operating system disk, even though the system is still
configured to support the mirrored configuration. Also, the system is vulnerable should the
secondary disk fail, so it is best to replace the failed disk and re-establish the disk mirror as soon
as is practicable.
This topic explains how to reconfigure the system to operate properly with only a single
operating system disk. Once you have replaced the failed disk, you can re-construct the
mirrored configuration by repeating the steps in Creating a mirrored volume.
Reconfiguring after a disk failure in a mirrored operating system volume for BIOS-based computers
Prerequisites: You must have already configured a mirrored operating system volume as
described in Creating a mirrored volume. These procedures assume that the operating system
volume on your system is C:.
Since one disk in the mirror has failed, you must first replace the failed physical disk, and then
reconfigure the remaining functional disk.
2. If the failed disk was the primary disk (that is, the secondary disk is still working
properly), disconnect the secondary disk cable and connect the primary disk cable to it.
3. Install the replacement disk and connect the secondary disk cable to it.
4. Start Diskpart by typing Diskpart.exe at an elevated command prompt. Then remove the
relevant data for the missing system partition, boot volume plex, and recovery partition
with the following commands at the Diskpart prompt:
Select volume=c
Select disk m0
5. If the functional disk (that is, the one you did not have to replace) was the secondary
disk, make it the primary disk with the following commands at a Diskpart prompt:
List volume (Note the numerical identifiers for the system volume, eg. 1 or 2.)
Select volume identifier (where identifier is the numerical identifier for the system
volume)
Assign letter=s
Reagentc.exe /disable
Reagentc.exe /enable
7. Return to the Diskpart prompt and run the following two commands:
Select volume=s
Remove
Reconfiguring after a disk failure in a mirrored operating system volume for UEFI-based computers
Prerequisites: You must have already configured a mirrored operating system volume as
described in Creating a mirrored volume. These procedures assume that primary plex of the
operating system volume on your system is C:.
Since one disk in the mirror has failed, you must first replace the failed physical disk, and then
reconfigure the remaining functional disk.
3. Install the replacement disk and connect the secondary disk cable to it.
4. Start Diskpart by typing Diskpart.exe at an elevated command prompt. Then remove the
relevant data for the missing system partition, boot volume plex, and recovery partition
with the following commands at the Diskpart prompt:
Select volume=c
Select disk m0
5. If the functional disk (that is, the one you did not have to replace) was the secondary
disk, make it the primary disk with the following commands at a Diskpart prompt:
List volume (Note the numerical identifiers for the system volume and recovery
volume, eg. 1 or 2.)
Select volume identifier (where identifier is the numerical identifier for the system
volume)
Assign letter=s
Select volume identifier (where identifier is the numerical identifier for the recovery
volume)
Assign letter=q
Reagentc.exe /disable
Reagentc.exe /enable
Select volume=s
Remove
Select volume=q
Remove
8. Update the primary BCD store by opening an ordinary command prompt and running
Bcdedit.exe /enum all.
9. If the failed disk was the primary disk, note the identifier for the Firmware Application
(101fffff) entry with the description Windows Boot Manager - Primary Disk.
10. If the failed disk was the secondary disk, note the identifier for the Firmware
Application (101fffff) entry with the description Windows Boot Manager - Secondary
Disk.
11. Run Bcdedit.exe /delete {identifier}, where identifier is the appropriate identifier you
noted in the previous steps.
12. If the remaining functional disk is the secondary disk (that is, if the failed disk was the
primary disk), configure the secondary disk to be the primary disk by running
Bcdedit.exe /enum all.
13. Note the identifier for the Windows Boot Manager entry with the description Windows
Boot Manager - Secondary Disk.
14. Run Bcdedit.exe /set {identifier} description “Windows Boot Manager - Primary Disk”
where {identifier} is the identifier you noted in the previous step.
15. Re-construct the mirrored configuration by repeating the steps in Creating a mirrored
volume.
Get-StorageJob
(Alternatively, you can query the name of your space via Get-VirtualDisk and only repair that
individual space by typing Repair-VirtualDisk –FriendlyName identifier1, where identifier1 is the
name of your storage space.)