Thursday, May 24, 2012

Linux: Disable SELINUX


SELINUX may cause some confusion and difficulties when configuring Linux. If any weird problems encounter while configure any of the Linux services (e.g.: Samba, Firewall, ...), we may disable the SELINUX first to check if the problems are related to it.

Fedora 16

In Fedora 16, selinux no longer mount to /selinux.  It has move to /sys/fs/selinux.

  1. Temporary disable SELINUX: echo 0 >/sys/fs/selinux/enforce
  2. Temporary enable SELINUX: echo 1 >/sys/fs/selinux/enforce
  3. Permanently disable SELINUX: edit /etc/selinux/config and change "SELINUX=enforcing" to "SELINUX=disabled"

Fedora 15 or below

  1. Temporary disable SELINUX: echo 0 >/selinux/enforce
  2. Temporary enable SELINUX: echo 1 >/selinux/enforce
  3. Permanently disable SELINUX: edit /etc/selinux/config and change "SELINUX=enforcing" to "SELINUX=disabled"
Reference: How to Disable SELinux

Wednesday, May 02, 2012

Migrate Windows 7 instance to iSCSI target


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.

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:

  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

  4. Open the subkey Linkage and edit FilterList value:

  5. There are usually two lines in FilterList:
  6. Delete the line that refer to LWF driver’s UUID: {B70D6460-3635-4D42-B866-B8AB1A24454C}.  In this case:

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


  1. Diskless Windows 7 iSCSI boot from OpenSolaris 2009.06 ZFS Server. URL:
  2. Transferring the disk image to a SAN target. URL: