It is not uncommon, especially in troubleshooting scenarios where you might find yourself needing to transfer files to or from an ESXi host using a USB device as it may not be reachable on the network. Another common case for directly attaching a USB device to an ESXi host is to transfer a large amount of Virtual Machines that were exported from another system and rather than streaming the content from your desktop, you may want to connect it directly to ESXi host. In fact, I had this very use case when I was a customer after we had acquired a company and needed to transfer their assets to our infrastructure. The IT admins just copied everything onto a USB device and then shipped us the drive for processing.

Historically, it was understood that ESXi could only access a USB device (requires disabling the USB arbitrator service) if it contains a FAT16 partition which are then automatically mounted under the /vmfs/volumes/ path. The biggest issue with FAT16 is that the size of the partition has to be <=2GB which severely limits its use for larger files. Another alternative that came up in recent years years is that you could run VMFS on a USB device, but that obviously would require you to format the USB device with VMFS and it would only be readable between ESXi hosts. If you were looking for something more generic like FAT32 which supports a larger partition size, it was assumed this was not possible, at least I was under that impression.

It was only recently as part of a project I had been working on where I was re-visiting this topic that I had discovered that other partition types such as FAT32 and even NTFS from a USB device could actually be accessed by ESXi 6.x. The assumption that I and probably others had made was that just because the partitions were not visible or mounted by ESXi, it does not mean the underlying USB device would also not be accessible. To access a FAT32 partition from a USB device in ESXi, you can use the mcopy utility from the ESXi Shell and for accessing an NTFS partition from a USB device in ESXi, you can use ntfscat utility. It actually took me some trial/error to get the correct syntax, but you can see how to use the utilities below.

Note: You still need to disable the USB arbitrator service for ESXi to see the USB device before you can read from it.

FAT32

Copy a file from USB device to ESXi host:

/bin/mcopy -i "/dev/disks/${USB_KEY}:2" ::/MyFile /tmp/MyFile

Copy a file from ESXi host to USB device:

/bin/mcopy -i "/dev/disks/${USB_KEY}:2" /tmp/MyFile ::/MyFile

NTFS

Copy a file from USB device to ESXi host:

/bin/ntfscat -f /dev/disks/${USB_KEY}:2 MyFile > /tmp/MyFile

One limitation that I did come across when using FAT32 on a USB device is that the maximum file size is <=2GB. If you need to transfer larger files from the USB device, you would need to chunk it up and re-construct the file on the ESXi host. One neat trick that I learned from my buddy Timo Sugliani is that you could use the split command which can be found on a Mac OS X or Linux system to break up the original file into smaller chunks. You can then re-construct the original file by simply using the cat command which is available in the ESXi Shell.

Here is the syntax for splitting a file into 1GB chunks:

split -b 1073741824 [FILE-TO-BE-SPLIT]

Here is the syntax for rebuilding the individual chunks into the original file:

cat [SPLITTED-FILES]* > [ORIGINAL-FILE-NAME]

Hopefully these scenarios is not something you would need to frequently do in your environment, but in case you do, there are some additional options beyond FAT16 🙂

3 thoughts on “Copying files from a USB (FAT32 or NTFS) device to ESXi

  1. Thank you so much for this article! But I’ve still got one question: What’s the “:2” at the end of the source path for? Because in my case, I got an error message that the device /dev/disks/mpx.vmhba38:C0:T0:L0:2 does not exist (but with :1 instead of :2 it seems to work). Thanks in advance!

    • The “:2” is the partition number and will depend on how you laid out the partitions on the USB stick. I believe he was experimenting with his kickstart autodeploy process, where he uses 3 partitions on a USB stick.

  2. Hi, thanks for the article, but I can’t seem to make this work. All I get is the following error:

    # ntfscat -v /dev/disks/mpx.vmhba35\:C0\:T0\:L0:1 source > destination

    Failed to determine whether /dev/disks/mpx.vmhba35:C0:T0:L0:1 is mounted: No such file or directory.
    Use the force option to ignore this error.
    ERROR: couldn’t mount volume: No such file or directory.

    Any ideas, please?

    Thank you.

Thanks for the comment!