Aligning VMFS and Linux using fdisk

Submitted by jbredehoeft on Tue, 12/06/2011 - 08:14

The alignment procedure for VMFS and Linux is the same as any other Linux file system. Use fdisk’s expert mode to create a new partition with an aligned starting block and then format the file system. You should use this procedure for not only VMFS, but for your Linux virtual machines as well (changing the type in step 7 "fb" to 83.)

  1. If you’re not already on the service console as the root user, begin by becoming root
           $ su - root
           Password:
    
  2. Run fdisk on the device/disk you would like to align. Depending on your configuration, this device will be different. Use the ‘fdisk –l’ to list all available devices; replacing ‘/dev/disks/vmhba32\:0\:0\:0’ in the command below with your lun device. (vmhba32 is the location for your SAN luns).
           $ fdisk /dev/disks/vmhba32\:0\:0\:0
    

    Note that a ‘:’ is a special character in the Linux shell and must be escaped with a ‘\’

  3. Create a new partition
            Command (m for help): n
    
  4. Choose ‘p’ for a new primary partition
           Command action
           e extended
           p primary partition (1-4)
           p
    
  5. When asked for the partition number, enter ‘1’
           Partition number (1-4): 1
    
  6. Use all the defaults by pressing enter at the prompts
           First cylinder (1-1088, default 1):
           Using default value 1
           Last cylinder or +size or +sizeM or +sizeK (1-1088, default 1088):
           Using default value 1088
    
  7. The VMFS file system uses the type fb. Change the type to ‘fb’ on the new partition.
           Command (m for help): t
           Selected partition 1
           Hex code (type L to list codes): fb
           Changed system type of partition 1 to fb (Unknown)
    

    Note: If you were working with a traditional Linux partition, you would use type ‘83’ – the Linux file system.

  8. Enter expert mode
           Command (m for help): x
    
  9. Change the start block to a value that aligns with your stripe element size. I like to use a start block of 2048 (2048 = 1024KB), ESX v3.x and later default to 128 (128 = 64KB) or as we have already said, you could use a value provided by your storage admin.
           Expert command (m for help): b
           Partition number (1-4): 1
           New beginning of data (63-8385929, default 63): 2048
    
  10. Commit the changes to disk
           Expert command (m for help): w
           The partition table has been altered!
    
           Calling ioctl() to re-read partition table.
           Syncing disks.
    
  11. If you are formatting a VMFS for VMware, use vmkfstools to format your file system. If you are formatting a Linux file system, you should use ext2fs or a similar tool to format your file system. Formatting a file system will destroy existing data. Make absolute certain your working with the correct disk!
    • To format a newly created VMFS, use the following syntax replacing ‘/dev/disks/vmhba32\:0\:0\:0\:1’ in the command below with your device and partition number.
              # vmkfstools –C  vmfs3 –b 4m /dev/disks/vmhba32\:0\:0\:0\:1
      
    • The formatting of a Linux file system can be slightly more complex due to the many different file systems and parameters offered like journaling. We cannot cover all the different file systems and their options, but for most, ext3 is an excellent choice (includes journaling.) The following syntax will format a file system as ext3, replace '/dev/sda1' with the device and partition you would like formatted.
              # e2fsck -j /dev/sda1