Computers from most manufactures today will likely come with a hidden recovery partition. In recent versions of Windows, Microsoft included an option to backup this recovery partition to an external drive, allowing a user to perform a factory reset even when the recovery partition has been deleted or corrupted.
On a WD Sentinel DS6100 you may have notice that this option is missing. It's not supported on Windows Server. In this exercise, we are going to look at backing up and restoring the recovery partition on a DS6100 with Windows PE so that you can perform a factory reset. This process also applies to the WD Sentinel DS5100.
Creating a Windows PE bootable USB
In a
previous article we outlined how to create a Windows PE bootable USB and boot it on a WD Sentinel DS6100. Follow the steps in that article and create your own Windows PE bootable USB with a 8 GB or larger USB.
We're using script-based approach to backup and restore the recovery partition of the DS6100. On your Windows PE bootable USB, create a folder named
WDFactoryRestore. We're going to put our recovery image and scripts in that folder.
Backing up the Recovery Partition
Our strategy to backup the recovery partition is to simply use Robocopy to copy the recovery image that is already in the recovery partition of the DS6100. By default, the recovery partition is not assigned a drive letter. You'll need to assign it a drive letter before we can use Robocopy.
Open a command prompt as an administrator and run Diskpart. Use the following commands to assign the recovery partition the drive letter "R".
DISKPART> select disk 0
DISKPART> select partition 5
DISKPART> assign letter="R"
DISKPART> exit
Now copy the recovery image that is in the recovery partition by entering the following command into the command prompt.
Robocopy R:\Recovery D:\WDFactoryRestore\Recovery /mir
(where D: is the drive letter of the USB)
After Robocopy finishes, you should have now backed up the recovery image of your DS6100 to your Windows PE bootable USB. If you would like to remove the drive letter you just assigned to your recovery partition, run the following commands in Diskpart.
DISKPART> select disk 0
DISKPART> select partition 5
DISKPART> remove
DISKPART> exit
Restoring the Recovery Partition
By now you should have a Windows PE bootable USB with the folder
WDFactoryRestore on it. Inside that folder should be another folder called
Recovery containing the actual recovery image of your DS6100.
Create two scripts and place them inside the folder
WDFactoryRestore. Name the scripts
CreatePartitions-UEFI.txt and
FactoryRestore.bat.
CreatePartitions-UEFI.txt
The first script is a Diskpart script that wipes and partitions the boot drive of the DS6100. If this script looks family to you, you may have seen it
here on TechNet. It's exactly the same script.
Copy and paste the following into
CreatePartitions-UEFI.txt to create the script.
rem == CreatePartitions-UEFI.txt ==
rem == These commands are used with DiskPart to
rem create five partitions
rem for a UEFI/GPT-based PC.
rem Adjust the partition sizes to fill the drive
rem as necessary. ==
select disk 0
clean
convert gpt
rem == 1. Windows RE tools partition ===============
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
rem == 2. System partition =========================
create partition efi size=100
rem ** NOTE: For Advanced Format 4Kn drives,
rem change this value to size = 260 **
format quick fs=fat32 label="System"
assign letter="S"
rem == 3. Microsoft Reserved (MSR) partition =======
create partition msr size=128
rem == 4. Windows partition ========================
rem == a. Create the Windows partition ==========
create partition primary
rem == b. Create space for the recovery image ===
shrink minimum=15000
rem ** NOTE: Update this size to match the size
rem of the recovery image **
rem == c. Prepare the Windows partition =========
format quick fs=ntfs label="Windows"
assign letter="W"
rem === 5. Recovery image partition ================
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit
FactoryRestore.bat
The second script is a script we've written. It runs the script above with Diskpart, copies the recovery image back into the recovery partition and applies the recovery image to the system partition. It essentially restore all the partitions and data on the boot drive of the DS6100 back to how it was out of the factory.
To create the script
FactoryRestore.bat, copy and paste the following into
FactoryRestore.bat.
rem == FactoryRestore.bat ==
rem
rem This script performes a factory restore of a
rem WD Sentinel DS5100 / DS6100 from a captured image.
rem
Diskpart /s CreatePartitions-UEFI.txt
Robocopy .\Recovery R:\Recovery /mir
Dism /Apply-Image /ImageFile:".\Recovery\All_os.swm" /SWMFile:".\Recovery\All_os*.swm" /Index:1 /ApplyDir:W:\
bcdboot W:\Windows
To actually perform the factory reset, boot the DS6100 into Windows PE, change the working directory to the
WDFactoryRestore directory on the Windows PE USB and run
FactoryRestore.bat. We recommend testing the restore process on another computer or virtual machine before you decide to wipe your DS6100.
Note: If you are running RAID 1 on your boot drives, after performing the restore process, you may find that you will need to take out one of the boot drives in order to boot your DS6100. You can put the drive back in later, the DS6100 will rebuild it as part of the RAID 1 array again.