Monday, 27 November 2017

Can I create a custom recovery image for Windows 10 like recimg did in Windows 8.1?


One of my pet peeves with refreshing Windows 10 is that I always have to spend several hours reinstalling the software I need by default: Steam, Origin, Chrome, Uplay, 1Password, Skype, Office,... It's quite a list.


In researching, I read several articles that explain that I can create a custom recovery image. However, the method that's usually recommended, recimg, appears to have been removed in Windows 10 release version.


I found this article that explains how to do it using reagentc. Is this the current method of creating a custom recovery image that has preinstalled software?



Answer



Overview


For the sake of completeness here are the tools & relevant keywords one has to use to get custom recovery for Windows 10. Thanks to search engines and drastic changes on MS side, internet is flooded with badly outdated howtos.


These days, the feature you are looking for is called Push-Button reset abbreviated as PBR. Essentially all necessary information can be found there. But basically, you are relying on built-in mechanism that uses Windows Component Store (C:\Windows\WinSxS) augmented with custom provisioning packages (ppkg).


You'll need Windows Assessment and Deployment Kit (ADK) and USMT from there with ScanState tool. ScanTool in Windows 10 ADK was augmented with /apps to capture installed Windows desktop applications into ppkg, and, starting from Anniversary build 14393, with /diff. You can install ADK on another PC and prepare necessary files by Starting Deployment and Imaging Tools Environment and running CopyDandI.cmd amd64 d:\SppTools to get a copy of x64 version into d:\SppTools .


Optionally one may turn installed classic apps into shortcuts (file pointers) for deferred deployment. See step 10-6. (It was always a puzzle for me when I saw a link to install Excel and alike on a brand new PC). Single instancing can be used to run application directly from provisioning packages sitting in your c:\recovery\customizations.


You can also capture application one by one into isolated (siloed) provisioning packages essentially by diffing system state. Note that it won't work in Windows 10 editions before Anniversary (build 14393).


Although not explicitly stated, it looks like one may still capture everything into install.wim. Although it undermines the whole idea of rebuilding OS from up-to-date components. See the first diagram named "Capturing Base App SPP" and step 4 that mentions install.wim can be a "customized push-button reset recovery image". This didn't work for me


Windows 10 treats specially folders like C:\Recovery\Customizations (with ppkgs) and C:\Recovery\OEM (with other scripts you might create) - it copies them into recovery media you'll create using standard features.


And here is the link for hands-on labs for training.


Personally, after reading how many steps one should take, I settled on Sysprep built into Windows 10 and Clonezilla.


Steps that worked for me in Anniversary edition


Note that the following is for an "average advanced user" and is simplified as possible and isn't meant as the ultimate guide.



  1. Install ADK with USMT on a spare PC and copy tools to SppTools on a flash drive as written above, i.e. CopyDandI.cmd amd64 d:\SppTools.

  2. Then boot clean reference PC and press Ctrl+Shift+F3 from Welcome Screen to reboot into Audit mode. If you were already under normal user, use sysprep\sysprep (I had on my PC at least) from elevated console and choose reboot to Audit. Remember to delete your user once in Audit mode.

  3. Install all the stuff you want and insert that flash drive, and open command prompt followed by changing directory to SppTools.

  4. Optionally, from Admin prompt compact /compactos:always. This saved me ~2.2GB. So up to you if worth a shot.

  5. Use Disk Cleanup and delete all junk like RetailDemo Offline Content.

  6. Then scanstate /apps /ppkg C:\Recovery\Customizations\base.ppkg /tel:off This will take time. Optionally, I'd suggest to save such lines into some cmd in d:\SppTools\ for ease of use next time, if ever, so it can be used with type, more and alike for copy-pasting.

  7. Now, if you forgot another app, install it, and do scanstate /apps /diff:C:\Recovery\Customizations\base.spp /ppkg C:\Recovery\Customizations\more.spp /tel:off Don't bother with it. This captures the difference, but for whatever reasons SPP unlike PPKG isn't automatically provisioned. Also see notes.

  8. Now you can reboot to OOBE using sysprep dialog (you were in Audit mode, right?). Tick Generalize if you plan on deploying to other devices, otherwise I'm not sure it is necessary. (It caused me a message saying that Windows 10 can't be installed on my hardware, but worked fine other time.)

  9. Finally, you can create a Recovery Drive using standard tool as usually:-)


If you want to keep raw image before rebooting and save some extra space you can do the following as well just before 8).



  1. Reboot into WinPE 10 on some USB flash drive instead of Out-Of-Box-Experience, I hope you have some lying around.

  2. Make it Single Instance with dism /Apply-CustomDataImage /customdataimage:c:\recovery\customizations\base.spp /imagepath:C:\ /SingleInstance. Think twice, though! Once you install updates, you'll loose twice as much space.

  3. Cleanup with md c:\temp, dism /Cleanup-Image /Image=c:\ /startComponentCleanup /ResetBase /ScratchDir:C:\Temp, rmdir c:\temp. (I have no idea how to insert code block into a list)

  4. Capture image dism /Capture-Image /ImageFile:d:\some-image-to-apply-on-another-pc-later-manually.wim /CaptureDir:C:\ /Name:Drive-C


Misc




  1. Note that testing PBR out will leave traces in C:\Windows\Logs\PBR as well as C:\$SysReset.




  2. I played with various options likes /config:Config_AppsAndSettings.xml, /genconfig, /i, /ue:*, /tel and they made no difference in combination with /apps options. Just in case, I keep /tel:off.




  3. I get defaultuser0 after reset. I wonder if someone can comment on how to avoid that.




  4. /apps will not work with /offlinewindir for dism.




  5. I have no idea yet how single instancing works with upgrades and uninstalls. Works well. But space is wasted.




  6. I stumbled on Visual Studio 2015 Community "prerelease license expired" issue. I'm not sure what caused that. Single Instanceing or something wasn't captured.




  7. On siloed packages, they aren't restored and dism says it doesn't know what is /Apply-SiloedPackage.




Here are some reference numbers for free space reported by dir.



  1. Before applying custom image: 196,703,948,800 bytes free

  2. After applying: 219,435,716,608 bytes free

  3. after deleting pagefile and alike (not necessary for dism though): 226,386,108,416 bytes free

  4. After rebooting and OOBE (9.) I got somehow 223,074,557,952 bytes free.


To see that you are truly using single instancing use fsutil wim


fsutil wim enumwims c:
0 {C55440AD-B696-49DE-A63F-3A60BE169FD5} 00000000 C:\Recovery\Customizations\base.spp:1

1 {8E902FE3-90AC-44C2-BFC6-E14B703B8526} 00000000 C:\Recovery\Customizations\sdr.spp:1

Objects enumerated: 2

And to check a particular file


fsutil wim queryfile c:\ProgramData\chocolatey\bin\choco.exe
Wim DataSource: 0
Wim Hash: 75a43e820eb05beb43f9f22b568838f609d1d92b
Wim State: Operational

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...