Restore physical Windows 2008 r2 server to Hyper-V VM for test environment usage

In this article I will explain all steps included for restoring physical machine to 2012 R2 Hyper-V host. Reason for doing this is testing software upgrade on test virtual machine instead on production server, or any other when you are dealing with testing anything. This is long process and you need to be patient.
 

Part 1. Creating boot media

For starters  we need to have full Windows server backup of physical machine. Because it is usually big, we will do restore over network. To do that we need network connectivity from virtual machine we boot from 2008 R2 CD. To get drivers for Hyper-V we need to extract it from Windows integration disc. Mount it on virtual machine or if you don’t have one, mount it from this location (%windir%\system32\vmguest.iso) . Let say that mounted ISO get drive letter D:, and we will create folder to extract drivers named c:\AIPx64.

We need to extract drivers (only x64 because 2008 r2 is 64bit OS) and we do it with next command.

msiexec /a d:\support\amd64\Windows5.x-HyperVIntegrationServices-x64.msi TARGETDIR=C:\AIPx64\.

imageWe will get folders like on picture on the right. To integrate drivers to instalation ISO of W2008R2 SP1 we need ADK (Automated Deployment Kit). you can use any version compatible but let say that we will use the latest one you can found in this link: http://www.microsoft.com/en-us/download/details.aspx?id=39982

After installation of ADK create next folders on the same root preferably. Root can be new folder you can name newISO or what ever you like. Folders are:

  • WindowsISO-  where you will unpack windows installation CD
  • drivers – copy all drivers folders you extracted from Integration CD
  • wim – temporary folder for wim file
  • WindowsISOdrivers – folder for creation of new iso installation disc with integrated drivers.

Start ADK from command prompt

image

Mount install.wim from c:\newiso\windowsISO to c:\newiso\wim folder

imagex /mountrw C:\newiso\WindowsISO\SOURCES\install.wim  1 C:\newiso\wim

After that add rivers to mounted install.wim

cd c:\newiso\drivers
dism /image:C:\newiso\wim /add-driver /driver:. /recurse

You get something like this

image

Commit and unmount changes to install.wim

imagex /unmount /commit C:\newiso\wim

Result is looking like this

image

After that we create new ISO with integrated drivers

oscdimg -n -m -bc:\newiso\WindowsISO\boot\etfsboot.com C:\newiso\WindowsISO C:\newiso\WindowsISOdrivers\windows.iso

image

Part 2. Booting and restoring

After creating boot media with hyper-v drivers, mount it to newly created virtual machine. Configure VM in such way it virtual hard disk can accommodate all data from physical machine.

On first screen chose your settings and click Next

image

Chose “Repair you computer”

image

Chose Use Recovery tools …… Click Next

image

Go to command prompt

image

If you type ipconfig on command prompt you will get nothing. That is because PE enviroment is not started, and without it we can not get our backup from network. Start WinPE with this command

Start /w wpeinit

Try ipconfig after that and you will see that you now have ip address. On picture below you will see that we have APIPA address. My server LAN doesn’t have DHCP so we will need to enter IP address manually .

image

Use this command to enter ip address manually (Enter your values. You can see my example on picture):

“netsh interface ipv4 set address name = "<idx>" source=static address=<staticIP> mask=<SubnetMask> gateway=<DefaultGateway>”

After you successfully get ip address you can ping you environment

image

Lets now connect to network share and see what backup we have. Type next command to check backup we have:

wbadmin get versions -backuptarget:\\server\share

You should get output similar to this

image

After that we should start restore. you will start it with next command:

wbadmin start sysrecovery -backuptarget:\\server\share -version:01/08/2009-19:20 -recreatedisks -restoreallvolumes 

It will ask you for password to connect to share and then one more confirmation. After that wait for restore to finish

image

It will take some time. If it happens that you think something is wrong during restore( percentage of restore status stopped) , open another command prompt and type:

wbadmin get status

You will get updated status of restore operation. Shutdown VM and don’t forget to connect it to internal virtual switch. We don’t want to have 2 same machines on network. 🙂

Part 3. Post restore “problems”

After restore you will probably get next error. It is normal because physical server has enabled SCSI or some other drivers for booting from disks. Now we have to enable proper drivers.

image

First boot again from installation media and choose all options like in part 2. to enter command prompt. In command prompt type “regedit” to enter Registry editor.

image

Select “HKEY_LOCAL_MACHINE“. On the menu, click “File > Load Hive“. Navigate to “C:\Windows\System32\Config\SYSTEM“. Restored Windows directory can be on another drive letter.  Click “Open“. Under “Key Name“, type “Recovery“. You can use any other name for loaded hive but we use here Recovery.

image

Click “OK“. Navigate to “HKEY_LOCAL_MACHINE\Recovery\ControlSet001\services\intelide“. Double-click “Start“. Change the “Value data” to “0“.

image

Depending on drivers needed you will maybe need to enable some other drivers. Usual setting for booting on VMWare VM are:

aliide 3
amdide 3
atapi 0
cmdide 3
iastorv 3
intelide 0
msahci 3
pciide 3
viaide 3
LSI_SAS 0

Navigate to “HKEY_LOCAL_MACHINE\Recovery“. On the menu, click “File > Unload Hive“. Close “Registry Editor“. On “System Recovery Options“, click “Restart“. After that your machine should be booted and you can log in.

I hope I helped you in the process that is little bit troublesome but is needed from time to time. If you have any question please comment and also correct me if I told something wrong. I know there is other easier options to do this, but I wanted to show core edition of this process.

Advertisements