Somos campeones del mundo!!
We are the champions!!
In this post I’m going to continue creating the scripts (and manual steps) to restore the windows image file and show alternatives to the creation of the DVDs. To fully understand the process I recommend reading the part 1 of this series.
By now you should have your set of restoring DVDs and the bootable DVD that includes the tools required to continue the process.
I’m going to start explaining the manual steps to restore the image, so you can understand what’s going on, and then I’ll give you the code for the restore.cmd script that can be used to restore the system automatically.
Go and get yourself a coffee while you back-up your data, as the restoring process described here cleans the hard drive.
The first thing the we need to do is to clean the disk and create the partitions. To do that we will use diskpart.
The process involves creating 2 partitions. The first one is for Windows. Here I’ve used a 40GB but you can choose what you want. and the second needs to be al least 15GB to copy all the image parts, as the tool imagex doesn’t prompt for multi-disk image and we need to do this manually. I wouldn’t be too worried by now about the size of the partitions. I my case, once I had the system restored and Windows finished installing, I went to the Windows Disk Management tools and I resized the Windows partition and created some Striped partitions (RAID 0) to improve performance.
In case you need to use Windows HD encryption, you will need to create 3 partitions. 1st for the partition called “system” (this one will be the active one, and it doesn’t need a letter assigned as it’s hidden)
After booting from the boot DVD you will have a command prompt.
Type: diskpart
SELECT DISK 0
CLEAN
CREATE PARTITION PRIMARY SIZE=40000 (create a 40GB partition for Windows)
SELECT PARTITION 1
FORMAT QUICK FS=NTFS LABEL="Windows"
ASSIGN LETTER="C"
ACTIVE
CREATE PARTITION PRIMARY (create a second partition in the disk for the remaining)
SELECT PARTITION 2
FORMAT QUICK FS=NTFS LABEL="EXT"
ASSIGN LETTER="e"
EXIT
Now that we have the partitions we need to copy the image parts and the tool to restore the image to e:
In case you had the image parts in an external HD or USB Key or the second HD, you don’t need to copy the files locally. Instead you could connect your USB external HD and go to the next step (restore the image) because the system can detect the external HD when you plug it in and read the image directly from there (you only need to type the right source location)
copy d:\imagex.exe e:\
copy d:\sources\asus.swm e:\
(change to DVD 2 )
copy d:\sources\asus2.swm e:\
(change to DVD 3 )
copy d:\sources\asus3.swm e:\
Once we have the files in the HD e:, we need to go to e: (where we have the imagex.exe file) and apply the image to the HD c: with the next command
e:
imagex /ref e:\asus*.swm /apply e:\asus.swm 1 c:
The command:
This process can take a while, just wait until it’s finished.
Now that the Windows image has been restored we need to make that image bootable. To do that we need to go the the restored Windows system files and run the bcdboot command.
CD c:\Windows\System32
BCDBOOT C:\Windows
At this stage your system has already been restored and you need to reboot. Remove all your DVDs and restart the machine.
You can type wpeutil reboot to do so.
If everything went Ok, your system must be restarting and finishing the installation in the same way it did the first day that you used your computer. So finish the install, fix your partitions and uninstall all the rubbish that thy have installed by default. I also recommend to create a backup of your system once you have it the way you like it, and next time you can restore it to that state directly without having to do all these steps.
To finish creating the fully automated restore you can use the following scripts (to continue the process in the part 1).
There are 2 txt files with the commands for diskpart to clean the HD and create partitions. The reason why is that depending on the HD partitions before restoring the system, when the restoring starts, the partitions are mounted in different drive letters. If this happens, the scripts don’t know which drive contains the tools and where to copy the image files. To solve that, what I have implemented is a 2 steps recovery. First, I check if the tools are in the expected location (it happens when the HD is clean). If the script can’t find the tools in the HD d:, then cleans the HD and restarts automatically. Next time the system boots, we know where we are and we can automate the process. There are better ways to do this, but this one works and I didn’t want to spend too long for a process that shouldn’t happen more than once or twice a year.
|
SELECT DISK 0 EXIT |
|
SELECT DISK 0 CREATE PARTITION PRIMARY SIZE=40000 CREATE PARTITION PRIMARY EXIT |
In this script I have added a bit of error checking, some CLS (clear screen) and messages to make it look a bit better and easier to use once it’s been deployed.
You can modify the script to adapt it you your convenience in case you have a different number of DVDs or you are creating images for other machines.
|
@echo off IF NOT EXIST d:\create_partitions.txt ( wpeutil Reboot @echo. Initialising the HD if errorlevel 1 goto :errorPartitions copy d:\imagex.exe e:\ CLS :retryFile1 CLS CLS CLS e: if errorlevel 1 goto :errorRestore CLS CD c:\Windows\System32 if errorlevel 1 goto :errorBoot CLS wpeutil reboot :errorPartitions :errorRestore :errorBoot :end |
At this stage you are smarter than the guys that developed the restoring system for ASUS because:
If ASUS was smarter, they would give you the original install install disk (I would have paid a bit extra to avoid all the crap that they have put in my computer and that I have uninstalled anyways). They may probably get some extra cash from the companies of the preinstalled rubbishware they put in your machine, but in a long term, they end up paying back all that money because of they need a larger number of people in support to attend complains and answering users and they have to spend extra resources as electricity to keep your computer plugged-in while restoring.
Enjoy your coffee!!
Update: I have added a new post in where I explain how to fully customise the WIM image, update it with service packs and updates and remove bundled crap to create an updated and clean image that can be safely used to bring your computer to a clean state without the pain of running all the Windows updates again. Please check my post.
This post follows the previous post in were I explained how I bought a new ASUS laptop with preinstalled Windows 7 PRO x64 OEM and they didn’t give me the restore DVDs. Instead they had a retarded restoring system that relied on a 20GB partition in the HD that got useless when I changed my Partitions to use the Striped and Mirror features that come with the OS.
In this post I’ll explain how to manually create a set of DVDs from the original ASUS system image files named asus.swm, asus2.swm and asus3.swm. This method can be used for other brands that have the same type of lame restoring system or if you want to split an image bigger than the size of a DVD (usually the split is named install.swm install2.swm install3.swm).
After you finish reading your post you’ll be able to create a set of DVDs/CDs of the size you want and have a bootable DVD/CD that will automate the restoring and prompting to introduce the next disk. I’m going to add as many details and explanations as I can to allow non developers to be able to understand the process and create their set of DVDs. So if you find it too easy, skim through. If you find it still complicated, add a comment and I’ll try to give more samples (you can read the MS documentation as well).
To create the recovery DVDs we are going to need “Windows Automated Installation Kit for Windows 7” (Windows 7 AIK) installed (you can download it and install it for free). This is the set of tools that the laptop manufacturers use create the images that are installed in your system. This post can also be used as a tutorial to understand the process of deployment using Windows 7 AIK (the steps used here are taken out from Microsoft documentation and they are using the tools that MS has made freely available to users to deploy Windows in an alternative way to standard setup). I take no responsibility of any errors in the scripts that I’ll be providing in the next post and I take no responsibility of the information that could be lost by using these steps. Please take your time to read the official Microsoft documentation about the tools and the risks of using them (http://technet.microsoft.com/en-us/library/dd744356%28WS.10%29.aspx) and remember that restoring the image will wipe out all the data in your HD so you need to run a backup of your data before you restore your system. And remember that these instructions should never be used to install Windows in a computer other to the one that you have paid the license for (no license no install). Please read read your Windows license agreement before following the steps to install your Windows image.
Before we start with the process ne need to have the full image file (install.wim or asus.wim or image.wim) or the image already split in parts (asus.swm, asus2.swm and asus3.swm or install.swm install2.swm install3.swm). If you want to change the size to use double layer DVDs or CDs or a Blu-Ray or any other thing, you can join your image and then split it back in the size that you want. To do that you can use imagex command to:
Now that we have our images with the size that we want, we are going to start.
To restore the system we need to create a bootable DVD with all the tools required to boot, configuration files to create partitions and scripts to restore the image.
In this process I will assume that we have installed Win AIK in the standard path (c:) and that we want to do the work in the d: drive.
copy restore.cmd d:\winpe_x86\mount\Windows\System32\
copy clear_partitions.txt d:\winpe_x86\mount\Windows\System32\
copy create_partitions.txt d:\winpe_x86\mount\Windows\System32\
In the next post I’ll explain how to fully automate the process creating the scripts from the step 4.
Update: I have added a new post in where I explain how to fully customise the WIM image, update it with service packs and updates and remove bundled crap to create an updated and clean image that can be safely used to bring your computer to a clean state without the pain of running all the Windows updates again. Please check my post.