In a recent issue of our popular weekly IT pro newsletter WServerNews we included the following Ask Our Readers request from a reader named Wlad:
“Would it be possible to pose the following question to ask on our readers forum? I have spent last month researching the issue and I’m more confused than ever. I want to create a “rescue disk” for several systems I use, starting with Windows 7 and ending with Windows 10. What I have in mind is a single USB HDD for each system. The drive would be formatted as a “bootable USB” first (whatever that means, I found a dozen different descriptions) and then further partitioned to include a secondary, non-bootable partition. On that second partition I want to create the computer’s HDD clone, but not in the form of the USB HDD being a clone of the computer HDD, but the USB HDD containing a file (or a filesystem) that is an exact clone of the source HDD. Let us call it a “total HDD image.” The goal is to have a single USB HDD that, in case of emergency (WannaCry?) I could connect to the computer in distress, boot from, and then restore the entire HDD from the total HDD image backup. The aim is to restore everything, bit for bit (boot bootstrap, system, Windows files, installed programs, user data, EVERYTHING). Has anybody done this? Could it even be done or am I chasing an impossible dream? Microsoft is not helping with their constant “improvements” of backup and recovery mechanisms and associated mess of confusing terms that have changing meaning over time (like a system backup that may or may not include non-MS applications).”
In the following week’s newsletter several readers of our newsletter offered some suggestions on how Wlad might implement a solution that could meet his needs. One of our readers, though, was helpful enough to provide us with a detailed step-by-step procedure on how one can build a single rescue disk that you can use to boot and restore multiple different versions of Windows. That reader was Mark Van Noy, a Technical Lead/Architect at the University of Colorado Boulder in the Greater Denver Area (and someone we have spoken with before). Mark considers himself an Information Technology generalist who thrives on architecting new tools and services in ways that allow his customers to realize gains in efficiency, productivity, and cost savings while ensuring that IT remains a division that provides a competitive advantage. Let’s now listen as Mark explains how to address the problem Wlad describes.
Steps for creating a USB HDD rescue disk
Good afternoon, Mitch, I think I can help Wlad accomplish exactly what he wants to do. I will break things out in steps to make things easier to follow. I am also trying to be brief since this is a newsletter. The good news is that there is no software to buy! Here is the procedure:
- Download and install Microsoft’s latest Windows 10 Assessment and Deployment Kit (ADK) available for free here.
- Using the ADK, create a Windows 10 1703 WindowsPE ISO. When creating the PE image make sure to include any imaging options or references to DISM.
- Using either Diskpart or the GUI Disk Management tool remove all the partitions from the USB HDD. Then create a primary partition that is around 250-300 MB’s to hold the Windows PE files from step 2. Make sure this partition is set as active so that it is bootable.
- Still using either Diskpart of the GUI Disk Management tool, create a second primary partition that fills the rest of the USB HDD. This is your nonbootable data partition.
- Format both partitions as NTFS
- Connect the USB HDD to the computer you want to back up and boot from the USB HDD to Windows PE which will give you a Windows 10 environment based on the command line. (Some GUI tools such as Notepad run just fine in Windows PE.)
- In Windows PE, use the DISM command to capture an image of each partition you want to back up. For example, to capture the C: drive you might type something along the lines of: DISM /Capture-Image /ImageFile:D:\Marketing-01_backups.wim /CaptureDir:C:\ /Name:"Markerting-01 backup of the C: drive" /CheckIntegrity
- For additional captures of partitions or new backups, use the /Append-Image option instead of /Capture-Image, and DISM will only save the files that have changed, which will save a tremendous amount of space over time compared to creating a new .wim each time. Also, The /Capture-Image option always creates a new file without prompting if you are sure, so using the same file name over again will replace the existing .wim instead of adding to it.
Note that using DISM’s /Apply-Image option to restore a .wim to a hard drive will not re-create the partitions.
Scripting the solution
We normally use Diskpart in PE to partition and format a disk before applying a .wim. The entire process is also very scriptable. Diskpart can take a plain text file of Diskpart commands that will handle the partitioning and formatting of a drive and DISM commands work great from a plain .bat or .cmd batch file.
Below I will show you a sample batch script named Go.cmd that we have used to image various computers. This script uses a text file named Partitioning.txt, which contains the Diskpart commands needed to automate steps 3-5 of the process shown above.
Finally, I will also mention that the .wim format is what Microsoft uses to ship Windows since Windows Vista, making it a reasonably robust technology.
Sample script named go.cmd
REM Script deploys an image from a .wim file
REM !!!!!DESTRUCTIVE PROCESS!!!!!
REM Configure the disk to one Main partition and one scratch, format, set as active
REM !!!!!DESTRUCTIVE PROCESS!!!!!
diskpart /s .\Partitioning.txt
REM Apply the image (Assumes image is in the same directory as this script)
REM Restore the Sysprepped Image to both the C and D drives.
DISM /Apply-Image /ImageFile:Spring2017_Sysprep.wim /Index:1 /ApplyDir:C:\ /CheckIntegrity
DISM /Apply-Image /ImageFile:Spring2017_Sysprep.wim /Index:2 /ApplyDir:E:\ /CheckIntegrity
Sample Diskpart text file named partitioning.txt
sel disk 0
create part pri size=463053
create part pri
sel part 1
format FS=NTFS Label=Windows10 Quick
sel part 2
format FS=NTFS Label=Scratch Quick
Microsoft TechNet has a Command-Line Reference section where you can learn more about the syntax of the Diskpart and DISM commands for Windows 7 and Windows 8.1. For Windows 10 you can refer to the Windows Commands section of the Windows Server 2016 documentation found on the Windows IT Center. See also the article UEFI/GPT-based hard drive partitions on the Microsoft Hardware Dev Center for more information about using Diskpart with Windows 10. And see also the articles DISM Image Management Command-Line Options on MSDN and Create and Manage a Windows Image Using DISM on the Microsoft Hardware Dev Center for more information about using DISM with Windows 10.
Photo credit: Flickr / James Loesch