Creating A VMFS Datastore On A USB Drive

MOAR Storage!

Totally not supported by VMware but works like a charm. Of course there are a few steps to get your hosts to recognize the device and who doesn’t have a spare USB drive laying around, amirite? what you're telling me is...

 Just don’t be a tard and do something like use this method in a production environment. That would probably be the last task you do at that job.

Disable USB Arbitrator Service

First thing we want to do is disable the USB Arbitrator Service. This service is what allows your ESXi host to pass through USB devices to your VMs. To do so, first connect to your host via SSH and login.

Once you are in, you’re going to want to run the following command and disable this service.

/etc/init.d/usbarbitrator stop

Sweet. Once that is done we can move on.

Find a drive and plug it directly into your ESXi host

Got it? Good! Once you have it plugged in, we are going to want to validate that the host sees this new device. I’m going to use this 64GB SanDisk one.

Go back to your putty session and run the following command:

vdq -q

We can now see the USB drive that was plugged in. You can also login to the host via the GUI and navigate to Storage > Devices and see the drive displayed in the list.

**The vdq command became available in ESXi version 6. According to Will’s blog, vdq stands for VMware Disk Query or VSAN Disk Query. When used with the -q option it will display all the disks found on the host.

Jot down the name of the device on a notepad. We’ll need to use this a few times. In my case, this is my device identifier.


Find the start and end sectors of the drive

Next we need to make sure the drive is formatted correctly. Run the following to make sure we write a GPT (Guid Partition Table) label to the device.

partedUtil mklabel /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142 gpt

Then run the following command to find out the partition info.

partedUtil getptbl /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142

The resulted info displayed is the sector info of the drive. Copy that info to a notepad or something as we’ll need it shortly.

[root@e2esx03:~] partedUtil getptbl /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142
7608 255 63 122224640

Let’s format this bad boy and create a partition. Using the sector info above, we need to determine the start sector and end sector using a little bit of black magic or in human terms…MATH.

The drive start sector is always 2048

We will also need the GUID for VMFS. These are all specifically reserved. You can find this info by typing this command:

partedUtil showGuids

which results in the following output.

[root@e2esx03:~] partedUtil showGuids
 Partition Type       GUID
 vmfs                 AA31E02A400F11DB9590000C2911D1B8
 vmkDiagnostic        9D27538040AD11DBBF97000C2911D1B8
 vsan                 381CFCCC728811E092EE000C2911D0B2
 virsto               77719A0CA4A011E3A47E000C29745A24
 VMware Reserved      9198EFFC31C011DB8F78000C2911D1B8
 Basic Data           EBD0A0A2B9E5443387C068B6B72699C7
 Linux Swap           0657FD6DA4AB43C484E50933C84B4F4F
 Linux Lvm            E6D6D379F50744C2A23C238F2A3DF928
 Linux Raid           A19D880F05FC4D3BA006743F0F84911E
 Efi System           C12A7328F81F11D2BA4B00A0C93EC93B
 Microsoft Reserved   E3C9E3160B5C4DB8817DF92DF00215AE
 Unused Entry         00000000000000000000000000000000

Jot down the vmfs GUID which is: AA31E02A400F11DB9590000C2911D1B8

Remember above when we ran the getptbl command to find our drive sector info? Then I told you to copy the info to a notepad or something. So yeah, we’re going to need that now to find out the end sector.

In my case this is the sequence.

7608 x 255 x 63 – 1 = 122222519

If you are lazy or just scared of calculators, this command can also calculate to find the end sector.

eval expr $(partedUtil getptbl /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142 | tail -1 | awk '{print $1 " \\* " $2 " \\* " $3}') - 1

Create and Format the partition

Now that we have both start and end sectors we can run this command to create the partition. (Make sure you replace your end sector in the command)

partedUtil setptbl /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142 gpt "1 2048 122222519 AA31E02A400F11DB9590000C2911D1B8 0"

Then we’ll format the partition with VMFS6 using this command. Set a label for your datastore as well. I’ll be using this USB drive to hold a few ISOs.

vmkfstools -C vmfs6 -S E2USB-ISO-Datastore /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1

*Initially I forgot to include the :1 at the end of the command the first time I ran through this. That resulted in the drive not being created and throwing the below error. 

[root@e2esx03:~] vmkfstools -C vmfs6 -S E2USB-ISO-Datastore /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142
create fs deviceName:'/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142', fsShortName:'vmfs6', fsName:'E2USB-ISO-Datastore'
deviceFullPath:/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142 deviceFile:t10.SanDisk00Ultra00000000000000000000004C530001240924109142
ATS on device /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142: not supported
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Creating vmfs6 file system on "t10.SanDisk00Ultra00000000000000000000004C530001240924109142" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "E2USB-ISO-Datastore".
Failed to create VMFS on device t10.SanDisk00Ultra00000000000000000000004C530001240924109142
/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142: Permission denied.  (Have you set the partition type to 0xfb?)
Error: Permission denied

If you’ve run it correctly you should see the following command output.

[root@e2esx03:~] vmkfstools -C vmfs6 -S E2USB-ISO-Datastore /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1
create fs deviceName:'/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1', fsShortName:'vmfs6', fsName:'E2USB-ISO-Datastore'
deviceFullPath:/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1 deviceFile:t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1
ATS on device /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1: not supported
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Scanning for VMFS-6 host activity (4096 bytes/HB, 1024 HBs).
Creating vmfs6 file system on "t10.SanDisk00Ultra00000000000000000000004C530001240924109142:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "E2USB-ISO-Datastore".
Successfully created new volume: 591f7eb5-8d919b22-b088-c03fd5682716

Then when you return back to your ESXi host and look under Storage > Datastores you should now see your newly formatted VMFS6 drive for use. You may need to refresh.

Yey! Good job! Thanks to Florian Grehl in helping to get this working.

Some people use a USB datastore for a persistent scratch location, some use it to satisfy a requirement for VSAN. Whatever way you decide to use it, just don’t use it in a production enterprise setting!


Oh and btw USB-C needs to hurry and replace all USB-A connectors.

So yeah, I'm a crazy geek. Gadgets, video games, technology, you name it. I also enjoy being outdoors snowboarding, hiking or biking. Yey! I'm probably the coolest person you'll never meet.

View Comments
  • I’ve Install ESX on a 8GB USB flash drive. It has about 4GB free space for which I would like to use for a datastore.
    But when I try in create the partition I get this error:

    [root@localhost:~] partedUtil setptbl /dev/disks/mpx.vmhba32:C0:T0:L0 gpt “10 7086080 15470594 AA31E02A400F11DB9
    590000C2911D1B8 0”
    0 0 0 0
    10 7086080 15470594 AA31E02A400F11DB9590000C2911D1B8 0
    Error: Read-only file system during write on /dev/disks/mpx.vmhba32:C0:T0:L0
    SetPtableGpt: Unable to commit to disk

    It seem to be read-only 🙁

    Any solution?

  • Hmm…I’ve not tried installing a datastore on the a free partition residing on the same volume as the OS. I don’t think it can be done since you are trying to format a free partition on the same volume that ESXi is running from. That’s likely why the device is locked to read-only.

    Perhaps use a local disk as your datastore or plug in another USB and format that for dedicated storage while keeping ESX on it’s own storage.