How to align VMWARE Virtual Disk

Aligning the file system of a VM increase the I/O efficiency from the NTFS file system to the underlying storage, creating a VM within VCenter automatically aligns the VMFS but the guest file system must also be aligned.

Windows XP/2003 does not provide a method for creating aligned file system during installation. to work around this, the VM file system can be accessed using fdisk from the ESXi console, this goal is to set the beginning offset for the file system to sector 128, this has (128 sectors x 512 bytes/sector=64k), please follow the below steps to achieve this.

  1. Log in to the console using SSH of the ESXi Server hosting the Template virtual machine
  2. Go to the datastore where virtual machine resides
  3. Here in this example, in our case VM machine name is “Win_XP_32_temp_01” and he resides on SAN 3TB datastore, in your case it will be different and you will choose accordingly.

# Cd /vmfs/volumes/SAN-3TB/
# Cd Win_XP_32_temp_01 (go to the VM directory, in our example it is “Win_XP_32_temp_01”)

1) View the VMDK file parameters by typing cat
#cat Win_XP_32_temp_01.vmdk |grep -i ddb.geometry.cylinders

Note the ddb.geometry.cylinders value. In this example it is 1044

2) Edit the “–flat” virtual disk file of the VM using fdisk .
#fdisk ./ Win_XP_32_temp_01-flat.vmdk

Enter in expert mode by typing “x” and then “c” to enter the number of cylinders equal to the value of “ddb.geometry.cylinders”, which was “1044” in this example.

 

Command (m for help): x

 

Expert command (m for help): c

Number of cylinders (1-1048576, default 1044): 1044

The number of cylinders for this disk is set to 1044.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

 

1)      Type “r” to return to normal mode

2)      Type “n” for new partition, select “p” and then type “1” to select the first partition and “1” to set the first cylinder and press enter

The default value for the last cylinder, which should be equal to the “ddb.geometry.cylinders”, appears

 

Expert command (m for help): r

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1044, default 1): Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): Using default value 1044

 

1)      While still in the expert mode , type “b” to specify the beginning offset for the disk and the type “1” to specify the first partition and set the new beginning of data to 128

Type “p” to view the partition table and ensure the “start” has the correct value 128 

 

Command (m for help): x

 

Expert command (m for help): b

Partition number (1-4): 1

New beginning of data (0-16771859, default 63): 128

Recalculate C/H/S values? (Y/N): Y

 

Expert command (m for help): p

 

Disk ./WinTest-flat.vmdk: 255 heads, 63 sectors, 1044 cylinders

 

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl      Start       Size ID

 1 00   2   3    0 254  63 1023        128   16771732 83

 2 00   0   0    0   0   0    0          0          0 00

 3 00   0   0    0   0   0    0          0          0 00

 4 00   0   0    0   0   0    0          0          0 00

 

1)      Type “r” to return to the normal mode

2)      Type “t” to specify the partition type.

3)      Type “7” to set the partition type to NTFS and then type “w” to write the partition table to disk

 

Expert command (m for help): r

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 7

Changed system type of partition 1 to 7 (HPFS/NTFS)

 

Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table

fdisk: WARNING: rereading partition table failed, kernel still uses old table: Inappropriate ioctl for device

 

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s