Factory recovery - Create a Custom Recovery Partition  

Page 1 of 25 12311 ... LastLast
    Factory recovery - Create a Custom Recovery Partition

    Factory recovery - Create a Custom Recovery Partition

    How to create a custom bootable recovery partition to restore Windows
    Published by Category: Installation & Upgrade
    26 Feb 2022
    Designer Media Ltd

    Most computers today with OEM pre-installed Windows come with a so called Factory recovery partition. This partition allows users to restore Windows 10 to it's original state, as it was when shipped from the factory.

    Although a practical feature, restoring Windows to its original state from manufacturer recovery partition means just that, restoring PC to its original state with all OEM bloatware and all possible trial software, Windows being not updated and so on.

    I prefer formatting OEM recovery partition and using that space to create my own instead. I setup a pre-installed Windows or clean install it, update fully, install software as I prefer and create user accounts, and before starting to use Windows I capture the Windows image to a custom install.wim file and use it in setting up my own custom "factory recovery" partition.

    When restoring Windows from this custom recovery partition, Windows is updated (as it was when image was captured), containing all pre-installed software, user accounts and user data, device drivers, custom settings like themes and so on.

    This tutorial will show how to create your own custom recovery partition. The method is easy and relatively fast.






    Contents

     Click links to jump to any part



    Part One: Capture Windows image
    Part Two: Prepare Recovery partition
    Part Three: Add Recovery partition to boot menu




    Part One

     Capture Windows image

    Note   Note
    Please notice: steps 1.1 through 1.3 are not required if your Windows 10 is already fully updated, all software is installed, user accounts created and Windows customized as you want to have it.

    1.1) Update Windows fully

    1.2) Create user accounts and install software you want to be included in Windows recovery image

    1.3) Customize Windows as you'd prefer, changing theme and other settings to your liking

    1.4) When done, boot computer from Windows install media, When the Windows Setup region and keyboard selection screen is shown, press SHIFT + F10 to open Command Prompt:
    Factory recovery - Create a Custom Recovery Partition-command-prompt-boot.jpg

    1.5) Type DISKPART (#1 in next screenshot) and hit Enter to start the disk partitioning utility

    1.6) When booting from Windows install media, drive letters might be different from what they are when booting normally. Enter the command LIST VOL (#2) to check partition letters

    1.7) We need to capture the Windows partition and save that captured install.wim file on another partition (internal or external drive) or on a shared network folder. Check what temporary drive letter your Windows system partition has, in my case now it is D: drive (#3). In case you are saving the captured image to another partition on the same PC, check its drive letter, too. In this example case I could have chosen drive E: (#4) as the location to save the captured Windows image, but instead I will save captured image on a network share

    1.8) Enter command EXIT to quit DISKPART (#5)

    1.9) This step is optional, only required if you want to save captured image on a network share

    In this example now, I want to store the captured image on a shared network folder on another computer. To do that, I need first to initialize networking services with the command wpeinit (#6), then map the shared folder on that PC to a drive letter on the local computer.

    Path to a network share is told as \\server\share where server is the name of the computer where shared drive or folder is located, and share is the name that drive or folder is shared with. In my case I have shared a folder on computer AGM-W10PRO03, named the share as Storage, so the path is \\AGM-W10PRO03\Storage.

    For this example, I’ll map the shared network folder as drive Z: using the following command, entering network credentials (username and password to \\server) when prompted (#7):

    net use Z: \\agm-w10pro03\storage

    1.10) Now I can capture Windows to a custom WIM file with DISM. The switch /imagefile: followed by a path and filename tells the DISM command where to save the captured Windows image, in my case now I want to save image as install.wim on mapped network drive Z:. Switch /capturedir: followed by the drive letter, colon and backslash tells DISM which drive contains the Windows installation I want to capture, drive D: in this example case. Change these according to your needs.

    The command to capture image (#8):

    dism /capture-image /imagefile:Z:\install.wim /capturedir:D:\ /name:"Recovery" /description:"My Custom Recovery Image" /compress:maximum
    Factory recovery - Create a Custom Recovery Partition-capture-image.jpg
    (Click to enlarge.)
    Note   Note
    EDIT:

    Please notice that the DISM command in above screenshot is missing the /description:"My Custom Recovery Image" switch. Without it, the image will be captured OK, but it might not work when trying to use it for system recovery.

    I very strongly recommend adding the /Description switch to your DISM command to avoid any issues when recovery image is needed.

    1.10) When done, close Command Prompt, close Windows Setup region selection window. Windows will restart, let computer boot normally to Windows





    Part Two

     Prepare Recovery partition

    2.1) Create a new partition on any internal HDD or SSD by shrinking an existing one (tutorial) or using unallocated space, name it as Recovery.

    Partition size (my recommendation) should be the size of your custom captured install.wim + 1 GB, rounded up to next full GB. For instance, if your custom install.wim is 6.2 GB, adding 1 GB makes 7.2 GB. Round it up to 8 GB (8,192 MB) for Recovery partition

    2.2) Mount Windows 10 ISO (same version & build as the captured Windows image) as virtual DVD drive (right click ISO image, select Mount). Copy its content to your new Recovery drive

    2.3) On your Recovery drive, browse to Sources folder and delete install.wim, or install.esd file in case your ISO was made using Windows Media Creation Tool. Replace the deleted WIM or ESD file by copying your custom install.wim to same folder





    Part Three

     Add Recovery partition to boot menu

    3.1) Copy following batch code, paste it to a new Notepad text file or any other text editor:

    Code:
    @ECHO OFF
    TITLE Add Recovery to Windows boot menu
    :SETLETTER
    CLS
    ECHO.
    ECHO             ###################################################
    ECHO             #                                                 #
    ECHO             #   This batch file creates recovery environment  #
    ECHO             #        adding it to Windows boot menu.          #
    ECHO             #                                                 #
    ECHO             ###################################################
    ECHO.
    SET /P DRIVELETTER= ^-- Please enter drive letter for your custom recovery partition (without colon): 
    IF NOT EXIST %DRIVELETTER%:\sources\boot.wim ECHO. & ECHO No valid Windows image found on given partition %DRIVELETTER% &ECHO. & PAUSE & GOTO :SETLETTER
    ECHO.
    bcdedit /create {ramdiskoptions} /d "Ramdisk"
    bcdedit /set {ramdiskoptions} ramdisksdidevice partition=%DRIVELETTER%:
    bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
    for /f "tokens=2 delims={}" %%i in ('bcdedit.exe /create /d "Recovery" /application OSLOADER') do (set guid={%%i})
    bcdedit /set %guid% device ramdisk=[%DRIVELETTER%:]\sources\boot.wim,{ramdiskoptions}
    bcdedit /set %guid% path \windows\system32\winload.efi
    bcdedit /set %guid% osdevice ramdisk=[%DRIVELETTER%:]\sources\boot.wim,{ramdiskoptions}
    bcdedit /set %guid% systemroot \windows
    bcdedit /set %guid% winpe yes
    bcdedit /set %guid% detecthal yes
    bcdedit /displayorder %guid% /addlast
    pause

    Alternatively, you can download the above batch file here: Recovery.bat

    Remember to unblock the downloaded batch file before using it (tutorial)!

    3.2) The sample batch file is for UEFI based machines with GPT partitioned HDD / SSD. If your PC is a BIOS based system with MBR formatted disk, change winload.efi in line 21 to winload.exe.

    The line in question for UEFI / GPT systems:

    bcdedit /set %guid% path \windows\system32\winload.efi

    Same line for BIOS / MBR systems:

    bcdedit /set %guid% path \windows\system32\winload.exe

    3.3) Save the file as a batch file with extension .bat, for instance as recovery.bat

    3.4) Open an elevated Command Prompt, run the batch giving full path. For instance, if you saved it as recovery.bat in Scripts folder on drive E:, enter following command:

    E:\Scripts\recovery.bat

    3.5) The batch file will be run, ask you the drive letter to Recovery partition you created, and set up the recovery environment adding it to boot menu
    Factory recovery - Create a Custom Recovery Partition-recovery-environment-created.jpg
    (Click to enlarge.)


    That's it! You have now Recovery option in boot menu. Selecting it, Windows Setup is run and you can clean install Windows 10, your custom image restoring it to the exact state it was when custom image was created. Everything will be there, from your custom desktop theme to user accounts and software already installed.
    Factory recovery - Create a Custom Recovery Partition-boot-menu.jpg

    Tip   Tip
    If your system disk crashes and no boot menu is shown, you can do recovery from your custom recovery partition by booting from Windows install media and running Windows Setup manually from recovery partition.

    For instance, if your recovery partition has drive letter F:, start Command Prompt with SHIFT + F10 when Windows Setup shows the region selection screen, then enter following command:

    F:\Setup.exe

    Windows Setup will be run from your custom recovery partition.

    Happy recovery

    Kari






  1. Posts : 16,325
    W10Prox64
       #1

    Nice!
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #2

    simrick said:
    Nice!
    Thanks!

    This really is something I recommend to every user. Especially if you are running Insider builds, this is a fast and easy method to "save your behind" when something goes wrong and restore Windows to a working state.

    Kari
      My Computer


  3. Posts : 16,325
    W10Prox64
       #3

    Kari said:
    Thanks!

    This really is something I recommend to every user. Especially if you are running Insider builds, this is a fast and easy method to "save your behind" when something goes wrong and restore Windows to a working state.

    Kari
    Agreed!
      My Computer


  4. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #4

    I added this tip to the end of tutorial:

    Tip   Tip
    If your system disk crashes and no boot menu is shown, you can do recovery from your custom recovery partition by booting from Windows install media and running Windows Setup manually from recovery partition.

    For instance, if your recovery partition has drive letter F:, start Command Prompt with SHIFT + F10 when Windows Setup shows the region selection screen, then enter following command:

    F:\Setup.exe

    Windows Setup will be run from your custom recovery partition.

    Kari
      My Computer


  5. Posts : 16,325
    W10Prox64
       #5

    Kari said:
    I added this tip to the end of tutorial:

    Tip   Tip
    If your system disk crashes and no boot menu is shown, you can do recovery from your custom recovery partition by booting from Windows install media and running Windows Setup manually from recovery partition.

    For instance, if your recovery partition has drive letter F:, start Command Prompt with SHIFT + F10 when Windows Setup shows the region selection screen, then enter following command:

    F:\Setup.exe

    Windows Setup will be run from your custom recovery partition.

    Kari
    Oh thanks - that's important. Good to know.
      My Computer


  6. Posts : 4,559
    several
       #6

    I have been doing it for years in Win7.

    Also, if you run setup.exe on your recov partition from within your current windows, you should also be able to do a repair install.
      My Computer


  7. Posts : 16,325
    W10Prox64
       #7

    SIW2 said:
    I have been doing it for years in Win7.

    Also, if you run setup.exe on your recov partition from within your current windows, you should also be able to do a repair install.
    I would have to assign it a letter first right? Because normally the recovery partition is hidden. And the repair install would then include all my installed programs?
      My Computer


  8. Posts : 4,559
    several
       #8

    simrick said:
    I would have to assign it a letter first right? Because normally the recovery partition is hidden. And the repair install would then include all my installed programs?
    Yep. Kari's batch file sets a drive letter.
      My Computer


  9. Posts : 16,325
    W10Prox64
       #9

    Okay, good to know. But then I would have to make sure to keep it updated on a regular basis, (twice a year), because a repair install has to be at least the same version as you're running...or am I getting myself confused?
      My Computer


 

Tutorial Categories

Factory recovery - Create a Custom Recovery Partition Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:13.
Find Us




Windows 10 Forums