Wednesday, May 02, 2012

Migrate Windows 7 instance to iSCSI target

Introduction

It is straight forward to install a fresh new Windows 7 instance on iSCSI target. However, there few tricks to migrate a Windows 7 instance to iSCSI target. Migrating an existing Windows 7 instance is a time consuming process especially for large partition size. Doing it right will save lot of time.

Prepare Windows 7 disk volume for migration

If a Windows 7 instance has larger partition size, e.g.: Few hundred Giga bytes or Tera bytes, migrate this instance will spend lot of time transfer Windows 7 instance to iSCSI target. Before start migrate the instance, try shrink or extend the volume size suitable for usage in near future. Use Extend Volume… and Shrink Volume… function in Disk Management to perform the task:

Update Windows 7 network driver

The iSCSI operation rely heavily on the network device. Update the network driver to latest version is not always necessary but it is advisable to do so. Some booting process of iSCSI operation may slow down due to network driver’s problem.

Disable LightWeight Filter (LWF)

Disable LightWeight Filter (LWF) is a crucial step to make sure the migration work. This step must perform or else the SAN boot will fail in later stage.

There is a quick solution to disable LWF by changing some registry setting:

Identify the description of Network Adapter use for iSCSI network operation in later stage:

Start RegEdit in administrator account.

Open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ Class\{4D36E972-E325-11CE-BFC1-08002BE10318}. There are many subkeys underneath, find and open the subkey where the DriverDesc match the NIC’s description. e.g.: 0013

In above example, the windows 7 partition is /dev/sdb1. The sector start from 209920 and end at 309299199. However, sector from 1 to 2099199 is necessary too as it contain the MBR code to make Windows 7 boots properly. The total size to of Windows 7 image should start from sector 1 to 309299199. Each sector has size 512 bytes.

# dd if=/dev/sdb of=win7.img bs=512 count=309299199

The block size of 512 bytes of above example may be slow to image the partition. Try switch the bs and count value may accelerate the imaging process:

# dd if=/dev/sdb of=win7.img bs=309299199 count=512

Transfer win7.img to iSCSI target and perform necessary setup. The Windows 7 instance has successfully migrate to iSCSI target. The iSCSI target is ready to SAN boot now.

Boot iSCSI target

Once the iSCSI target is setup, use iPXE or gPXE to SAN boot the iSCSI target: