What's new

Guide for Creating a Customized 8.1 Recovery Image on Surface Pro/Surface Pro 2

ixtapalapaquetl

New Member
Guide for Creating a Customized Recovery Image on Surface Pro/Surface Pro 2

I am a power user who lives almost exclusively on the desktop, with only occasional forays into Metro-land. For various reasons I do not trust my data to be stored on the cloud, so I do not make extensive use of SkyDrive. For these reasons, when Windows starts getting mucked up and I want to go for a Reinstall through Recovery, backing up all my data and reinstalling my non-Metro apps is a tedious annoyance. What follows is a method to get around these issues.

This guide will bring about the following changes in the behavior of your SP1/SP2:

• Your User Profile directory (so all of your Documents, Photos, Desktop, etc. folders) will be moved from the Windows partition onto a separate partition. This will be done natively by the operating system, and thus you will not need to resort to the use of junctions or registry hacks.

• Using “Remove Everything and Reinstall” (accessed through Recovery in the Charms menu) will not only reinstall Windows 8.1, but will also automatically reinstall all of your other applications and Windows settings. Once you have fixed your computer's state, you can return to that exact state at any time in the future, regardless of what other changes you make to your computer.

• Since your User Profile directory is no longer on the Windows partition, this data will remain completely untouched by the Reinstall process, thus eliminating the need to back up your data prior to reinstallation.

• This process will not be dependent on any third party software, but rather will use native Windows functionality. Documentation for each phase can be found on Microsoft’s TechNet.


I have successfully tested this guide on both an SP1 and an SP2 (though I have very real concerns that there will not be enough room on a 64GB SP1 – 128GB is OK, but tight). When Windows starts acting up on me, I simply initiate a Reinstall through Recovery, and I am back to my initial environment with all my data untouched – the whole process takes maybe 5 minutes for the reinstallation to complete. Painless, and no additional software or external drives are required.


OVERVIEW:

Phase I will tell Windows to look for your recovery directory in a folder you have easy access to rather than a hidden partition.

Phase II will create an initial recovery image (a file named install.wim), and inject any drivers you choose into this image. During this phase you may inject any drivers you wish. You should certainly include the telemetry driver that is missing from the OEM Reinstall image. Injecting the telemetry drivers into the image resolves a familiar issue in Device Manager, and may resolve a battery drain issue when using a keyboard. But you may also easily include the latest Intel video drivers, Wacom drivers for the pen, and any drivers for any peripherals you might wish to use. Once injected, these drivers will be available within Windows for all subsequent reinstallations.

Phase III will involve deleting the old recovery partition, recapturing the newly created extra space, and creating a new partition for use by the User Profile directory.

Phase IV moves the User Profile directory to the partition that was just created.

Phase V allows for creation of a custom installation image that includes all your applications, settings, and tweaks. This image will then replace the default image, allowing Windows to return you to this state at the press of a button, except for your data which will remain untouched.


CAVEATS:


I highly recommend starting this guide from a clean install (detailed in Phase 0). It is possible to adapt this procedure to work from an existing installation, but doing so introduces many unnecessary bugs into Windows. In particular, moving the User Profile directory after already having installed your software leads to some undesirable system behavior, and thus should be avoided. Starting from Phase 0 and following the remaining phases in order ensures that Windows does not get confused regarding the location of critical folders. This guide balances convenience against reliability – the amount of effort required to get a current installation working without error is much greater than the effort required to just install everything from scratch.

Also, this procedure is rather unforgiving of errors. You won’t brick your SP, but you will likely need to start over from a clean install if any mistakes are made. I strongly suggest that you use the same folder/file names as used in the guide to minimize the chance of error. If you do not have a lot of command line experience, it might be a good idea to create a Recovery USB drive for use in the event that you can’t boot up. This is an unlikely, but possible, outcome that can be avoided completely by carefully adhering to this guide.

Finally, it has been suggested elsewhere that upgrades to Windows 9 might be broken by moving the User Profiles to another drive. I obviously can’t test that hypothesis now, but in the worst case scenario, all that would be required would be reverting to an OEM image, upgrading the operating system, and then starting the guide over. No changes are so permanent that they can’t be simply written over.


INSTRUCTIONS:

PHASE 0: Create a pristine environment

In this phase you will be removing all information from your computer. Thus, you will need to back up any data to you have to an external drive, as well as any third party installation software or passwords. When this phase concludes, your computer will be in the same state as when you first got it. Do not begin this process until everything you want to save has been safely moved to another drive.

1) Initiate an OEM Reinstall: Charms > Change PC Settings > Update And Recovery > Recovery > Remove Everything And Reinstall Windows > click Get Started.

2) When this operation is complete and you are ready to enter Windows for the first time, create a temporary user “temp1” (this user will be deleted later) and log in. For simplicity's sake, I suggest that you create a Local Account rather than a Microsoft Account.

3) Go to Windows Update and fully update the new installation. Continue checking manually for updates until you are told there are no available updates remaining. If you are on a SP1 (or possibly an older SP2), you will need to go to the Windows Store to upgrade to Windows 8.1. When that has completed, check again for further updates using Windows Update. It is important to be fully updated on Windows 8.1 before proceeding to the next phase.



PHASE I: Move the Recovery directory

We begin by directing Windows to use C:\Recovery as the recovery folder rather than the hidden partition it natively uses. The customized image that we will create in Phase V will likely be too large for this undesirable recovery partition, necessitating this move. In order to allow this move to take place, we will need to create a temporary dummy file called install.wim (which will be replaced with an actual image in the subsequent phase). Be sure that Windows is set to show file extensions so that you can properly rename the .txt file.

We will need to use an “elevated command prompt” many times throughout this guide when we make use of the command line. One quick way to do this is Charms > Search > type Powershell. Hold the Powershell icon a moment and choose Run as Administrator from the popdown menu. This must be done for all elevated command line entries in this guide. I will bold these commands as a reminder.

1) Create the folders C:\Recovery, C:\drivers, and C:\mount

2) Use Notepad to create a blank text file and save it in C:\Recovery. Rename this file as install.wim (confirm yes to changing the file extension). You must have Windows set to display File Extensions!

3) Open an elevated command prompt and enter

reagentc /setosimage /path C:\Recovery\install.wim /index 1



PHASE II: Creating an initial image and injecting drivers

Windows uses a file called install.wim when it installs itself onto your hard drive. The big idea behind this guide is to replace that file with one of our own making so that next time it installs, it does it with all the things we want already included. Unfortunately, the OEM install.wim is missing some necessary drivers for the SP, so this needs to be addressed before going any further. And since we already have to inject some drivers into the image, we may as well inject any other drivers you will need as well.

1) Download the Surface Driver packages from Microsoft: SP1 from here and SP2 from here. For SP2, you can also grab the Intel Display Driver.

2) Unzip and place the resulting folders in C:\Drivers. Place any additional drivers you want included in your image into C:\Drivers as well. You may wish to include among these the Wacom drivers (and for SP1, the Intel display drivers).
We will now make a preliminary image and inject the drivers from C:\Drivers into it. Each of these steps will take a little while.

3) Go to Charms > Change PC Settings > Update And Recovery > Recovery > Advanced Startup > click Restart Now.

4) Once restarted, Troubleshoot > Advanced Options > Command Prompt. After rebooting, select the user temp1 and enter your password. The command prompt you see is already elevated, so you will not have to do anything special in 5) and 6) below.

5) Create a new image by typing in the command prompt

dism /capture-image /capturedir:C:\ /imagefile:C:\Recovery\install.wim /name:OEMwithdrivers /compress:max

This will take several minutes.

6) To inject the drivers, type

dism /mount-image /mountdir:C:\mount /imagefile:C:\Recovery\install.wim /index:1

When that completes, type

dism /image:C:\mount /add-driver /driver:C:\Drivers /recurse

Then finally

dism /unmount-image /mountdir:C:\mount /commit

When the last command finishes, close the command prompt, exit Windows, and boot up again. We now have an OEM Windows 8.1 install.wim with your drivers added in. You may now delete C:\mount and C:\drivers, but DO NOT delete C:\Recovery.



PHASE III: Managing the hard drive

We will need to use diskpart to do some hard drive management here, as the now defunct hidden recovery partition is protected and thus can only be removed via diskpart. Afterwards, a new data partition will be created within Windows.

1) Open an elevated command prompt and type diskpart.

2) Type

select disk 0

3) Type

list partition

4)
If you only see one partition labeled Recovery, go to the next step. If you have two partitions labeled Recovery, identify the partition number of the larger recovery partition (sized at several GB – not 300MB). Replace the “n” below with the number assigned to the recovery partition. Obviously you need to be careful to not delete the wrong partition, so make sure you use the right number for n.

select partition n
delete partition override


5) Type exit

6) Open Disk Manager (Charms > Search > disk and click Create and Format Hard Drive Partitions)

7) Right click on the bar representing C: and shrink it down to a smaller size. The smaller this partition is, the larger your data partition will be.

8)
Right click on the space next to C: bar and create a new partition. Then right click the new partition bar and assign the partition the letter D.



PHASE IV: Moving the User Profiles directory

The steps below are a simplified version of a guide User Profiles - Relocate to another Partition or Disk . If you are not using the exact commands/folder structure I use below, I strongly recommend that you familiarize yourself with the guide in the link before proceeding, as this phase is very sensitive. Errors here will definitely warrant starting over from Phase 0.

1) From an elevated command prompt type

C:\Windows\System32\Sysprep\Sysprep.exe /audit /reboot

and allow the computer to reboot.

2) Go to the desktop and click Cancel on the System Preparation Tool that is now open.

The following two steps are critical.


3) Move the file C:\Recovery\install.wim to D:\install.wim and rename it as OEMdrivers.wim. You must have Windows set to display File Extensions!

4) Open Notepad, paste the following text, and save the file as D:\relocate.xml. The formatting is not important (line breaks, tabs, etc.). You must have Windows set to display File Extensions!

THE NAMES AND LOCATIONS IN 3) AND 4) MUST BE EXACTLY AS STATED ABOVE OR YOU MUST ADJUST THE XML FILE BELOW ACCORDINGLY. Failure to do so will mess things up and you’ll have to start from Phase 0!

<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FolderLocations>
<ProfilesDirectory>D:\Users</ProfilesDirectory>
</FolderLocations>
</component>
</settings>
<cpi:eek:fflineImage cpi:source="wim:D:/OEMdrivers.wim#Windows 8.1" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>


5) From an elevated command prompt, type

net stop WMPNetworkSvc

If it says the service isn’t running, wait a few minutes and try again. If it still says it isn’t running,
go on to the next step.

6) Now type

cd c:\Windows\System32\Sysprep

followed by

.\sysprep /audit /reboot /unattend:D:\relocate.xml

7) After the reboot happens, go back to the desktop. Make sure the System Preparation Tool is set to Enter System out of Box Experience (OOBE) and Reboot, then click OK.

8) After the reboot, create a new user profile “temp2” and log in to Windows. Again, for simplicity's sake I suggest using a Local Account.

9) Finally, create what will become your actual final user account through Charms > Change PC Settings > Accounts > Other Accounts (be sure to set your actual user account as an Administrator!). Reboot, log in as this user, navigate once again to Charms > Change PC Settings > Accounts > Other Accounts, and delete the accounts for temp1 and temp2. Then navigate to D:\Users and manually delete the temp1 and temp2 folders if you see them there. You may need to change ownership and permissions of these folders to do so, try rebooting first though.

10) You may now delete D:\relocate.xml to tidy things up. Do not delete OEMdrivers.wim however; instead move that file a secure location. This image will serve as a failsafe if you ever need to go back to a vanilla installation with User Profiles on C: (though it will retain the drivers you have injected).



PHASE V: Preparing your custom image

At this point, all that remains is installing your apps, reimporting your data, and personalizing your Windows settings according to your preferences. Once you have everything set up just right, you are ready to make your final custom recovery image. Whatever state your computer is in before initiating these commands will be the state you return to through Reinstall. You will be able to return your computer to this current state at any time in the future.

1) Charms > Change PC Settings > Update And Recovery > Recovery > Advanced Startup > click Restart Now

2) Once restarted, Troubleshoot > Advanced Options > Command Prompt. After rebooting, select your username and enter your password.

3) Create your custom image by typing from the command prompt

dism /capture-image /capturedir:C:\ /imagefile:C:\Recovery\install.wim /name:customimage

4) That’s it! All done! Reboot and you are good to go.



VERIFICATION/USAGE:

And now for the moment of truth… at any point in time, you can return your computer's state to the custom state you created in Phase V by following the steps below. (If you want to test out your computer’s new functionality, put something on your desktop (anything will do) and uninstall a program (again, it doesn’t matter which one) before so you have changed the environment.)

1) Go to Charms > Change PC Settings > Update And Recovery > Recovery > Remove Everything And Reinstall Windows > click Get Started.

2)
Be sure to choose Only the Drive Where Windows is Installed or your data will be removed too!

Behind the scenes, Windows wipes C: clean except for your image in C:\Recovery. It will then take that image and write it to C: (including boot partitions). Once it is finished, your computer will be exactly as it was the moment before you began step 1) of Phase V with one notable difference – all of your User Folders will be untouched. You can see the program you uninstalled moments ago will be back and ready for use. You will also see that the file you placed on your desktop a moment ago is still there despite this Reinstall. This is because your desktop is now located on D:, and is thus untouched by the Reinstall process!


FINAL NOTES:

As time goes on, there may be further critical software/firmware updates etc. that you want incorporated into your custom image. My suggestion would be to do a Reinstall as detailed in the paragraph above, install whatever new software/updates you want, then repeat the steps in Phase V. This will overwrite the old install.wim image with your updated image, and you are then good to go.

If for any reason you want to go back to a vanilla Windows installation with the User Profiles on C:, simply copy the OEMdrivers.wim file you saved earlier to C:\Recovery, rename it install.wim, and go through the reinstall process. This will take you back to a point before you moved the User Profile and you can proceed from there (obviously your programs will not be installed). This may become important when it comes time to upgrade to Windows 9.

The big take away here is whatever image is in C:\Recovery is what you will get when you reinstall. This is so powerful. And no other software to worry about! I hope you find this guide to be useful. I will be checking in from time to time to answer questions that come up. Good luck and enjoy.
 
Last edited:
Back
Top