Skip to content

ESX CLI create VMFS and datastore on backend storage

February 17, 2012


  • IBM DS3500 storage box
  • IBM x3550 with 2 SAS HBA’s for the ESX host
  • Redundant SAS connection between storage & ESX host
  • Multipath with active/passive config


  • Back-end storage with a volume mapped to your ESX host
    • LUN id of the mapped volume
  • Identifier of your FC or SAS HBA’s
    • In this case vmhba3 (active) & vmhba4 (standby)
  • SSH Client (openssh, putty, …)
  • vSphere Client (if you want visualization afterwards)

SSH to your ESX host (on windows open putty):

ssh -l root esxhost

Find your device identifier by its LUN id. If you work with multipathing and have an active/passive configuration make sure the State is acitve, since you will find your mapped device on multiple HBA’s and only one of them will be the active path. The LUN id is 0 in this case (L0). Note the Device entry, you will need it further on. Identify the right entry by Adapter & LUN:

~ # esxcli storage core path list

UID: sas.500605b004542970-sas.50080e5239d32000-naa.60080e5000239d32000001ef4f3eb6da
Runtime Name: vmhba3:C0:T0:L0
Device: naa.60080e5000239d32000001ef4f3eb6da
Device Display Name: IBM Serial Attached SCSI Disk (naa.60080e5000239d32000001ef4f3eb6da)
Adapter: vmhba3
Channel: 0
Target: 0
LUN: 0
Plugin: NMP
State: active
Transport: sas
Adapter Identifier: sas.500605b004542970
Target Identifier: sas.50080e5239d32000
Adapter Transport Details: 500605b004542970
Target Transport Details: 50080e5239d32000

Now that you know the device identifier (naa.60080e5000239d32000001ef4f3eb6da) you can find the device (local path) of the mapped volume:

~ # ls /vmfs/devices/disks/

naa.600605b0041c3d90ff0000bb0b54c69d                          vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552
naa.600605b0041c3d90ff0000bb0b54c69d:1                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:1
naa.600605b0041c3d90ff0000bb0b54c69d:2                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:2
naa.600605b0041c3d90ff0000bb0b54c69d:3                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:3
naa.600605b0041c3d90ff0000bb0b54c69d:5                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:5
naa.600605b0041c3d90ff0000bb0b54c69d:6                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:6
naa.600605b0041c3d90ff0000bb0b54c69d:7                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:7
naa.600605b0041c3d90ff0000bb0b54c69d:8                        vml.0200000000600605b0041c3d90ff0000bb0b54c69d536572766552:8
naa.60080e5000239d32000001ef4f3eb6da                          vml.020000000060080e5000239d32000001ef4f3eb6da313734362020
naa.60080e5000239d380000016f4f3e7b86                          vml.020000000060080e5000239d32000001ef4f3eb6da313734362020:1
~ #

Create a partition on this device and set partition type to VMFS (0xfb):

~ # fdisk /vmfs/devices/disks/naa.60080e5000239d32000001ef4f3eb6da

m: menu
p: print current partition table
-> It should be empty
n: new partition
-> follow wizzard
t: set partition type to VMFS
-> fb
w: write partition table & exit

Create VMFS filesystem (datastore) (fs: VFMS5, name: datastore2). Keep in mind to create the filesystem on the created partition and not the raw device.

~ # vmkfstools -C vmfs5 -S datastore2 /vmfs/devices/disks/naa.60080e5000239d32000001ef4f3eb6da\:1

Change your current directory to the freshly created datastore datastore2, you will notice it’s just a link to a unique identifier

~ # cd /vmfs/volumes/datastore2/
/vmfs/volumes/4f3e647f-10d6cc03-4bb3-5cf3fce8561e # ls
/vmfs/volumes/4f3e647f-10d6cc03-4bb3-5cf3fce8561e # touch test.txt
/vmfs/volumes/4f3e647f-10d6cc03-4bb3-5cf3fce8561e # ls
/vmfs/volumes/4f3e647f-10d6cc03-4bb3-5cf3fce8561e #

You have a working datastore now, you can login to your ESX host with the vSphere client and browse the datastore.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: