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:

image

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.

A Microsoft knowledge article KB967042: Windows may fail to boot from an iSCSI drive if networking hardware is changed describe the cause and solution for the problem.

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

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

    image
  2. Start RegEdit in administrator account.
  3. 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

    image
  4. Open the subkey Linkage and edit FilterList value:

    image
  5. There are usually two lines in FilterList:
    {0B47BB2C-86FB-4699-8906-E08465757D92}-{B5F4D659-7DAA-4565-8E41-BE220ED60542}-0000
    {0B47BB2C-86FB-4699-8906-E08465757D92}-{B70D6460-3635-4D42-B866-B8AB1A24454C}-0000
  6. Delete the line that refer to LWF driver’s UUID: {B70D6460-3635-4D42-B866-B8AB1A24454C}.  In this case:
    {0B47BB2C-86FB-4699-8906-E08465757D92}-{B5F4D659-7DAA-4565-8E41-BE220ED60542}-0000
    {0B47BB2C-86FB-4699-8906-E08465757D92}-{B70D6460-3635-4D42-B866-B8AB1A24454C}-0000

Migrate Windows 7 disk image to iSCSI target

Next, the Windows 7 is ready to image and transfer to iSCSI target.  Boot into Linux and use command line utilities like fdisk and dd to image the Windows 7 partition.

First, decide the partition size:

# fdisk -lu /dev/sdb

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdf70df70

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *     2099200   309299199   153600000    7  HPFS/NTFS
/dev/sdb2       718899200  1953521663   617311232    f  W95 Ext'd (LBA)
/dev/sdb5       718901248  1333301247   307200000    7  HPFS/NTFS
/dev/sdb6      1333303296  1435703295    51200000    7  HPFS/NTFS
/dev/sdb7      1435705344  1953521663   258908160    7  HPFS/NTFS

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:

dhcp net0
        sanboot iscsi:nas.example.com::::iqn.example.com:windows-7

Reference

  1. Diskless Windows 7 iSCSI boot from OpenSolaris 2009.06 ZFS Server. URL: http://blog.zorinaq.com/?e=41
  2. Transferring the disk image to a SAN target. URL: http://www.etherboot.org/wiki/sanboot/transfer

4 comments:

Justin H. said...

What is the dd command to transfer the image to the iSCSI target?

Chau Chee Yang said...

Justin H: dd is a command in linux OS.

small said...

why you don't try to direct install windows 7 using original ISO installation CD.

Chau Chee Yang said...

small: I am not install a new windows 7. I am migrating an existing Windows 7 OS.