Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / Accessing USB Flash Drive from VMWare ESXi

September 15, 2022 VirtualizationVMWare

Accessing USB Flash Drive from VMWare ESXi

Sometimes you may need to directly connect an external USB flash drive (stick) to your VMWare ESXi host. For example, you may need it to copy a virtual machine image to send it to a remote office (if the WAN channel between offices is slow or highly loaded), to backup VM files to an external USB media, to copy an ISO file or VM image to the ESXi host (when it is better not to overload your LAN). In this article we’ll show how to connect a USB flash drive/stick to an ESXi host as a VMFS datastore or to copy files from a FAT32/NTFS partition directly.

Contents:
  • How to Connect an External USB Drive as a VMFS Datastore in VMWare ESXi?
  • How to Copy Files from USB Drive (NTFS/FAT32) to ESXi Directly?

How to Connect an External USB Drive as a VMFS Datastore in VMWare ESXi?

Suppose you want to connect a USB drive to an ESXi host and create a VMFS datastore on it to copy/move files and images of virtual machines conveniently.

Officially, VMWare doesn’t support external USB drives as VMFS datastore. However, it works and you can use it. Also, ESXi doesn’t support USB devices larger than 2 TB.

In VMWare ESXi 6.5 and higher, the method of connecting a USB device to a host was changed. Earlier several drivers (xhci, ehci-hcd, usb-uhci, usb-storage) were used. Then a single USB driver (vmkusb) replaced all of them.

  1. Connect to the ESXi host console over SSH;
  2. Stop the USB arbitrator. The service is used to passthrough a USB device from an ESXi host to a virtual machine (USB Passthrough): # /etc/init.d/usbarbitrator stop
    If you don’t want the USB arbitrator to start after the host restart, run the command: # chkconfig usbarbitrator off
  3. Connect an empty USB drive to your ESXi host;
  4. You can identify the name of the USB drive in the log: /var/log/vmkernel.log or using /dev/disks: # ls /dev/disks/
    The USB disk is usually named mpx.vmhbaX or naa.X.
    stop usbarbitrator to directly connect USB device to vmware esxi host
  5. Create a GPT (GUID) partition table on your USB drive: # partedUtil mklabel /dev/disks/naa.5000000000000001 gpt
  6. Then create a partition on your drive manually. To do it, specify the first and the last sector on the drive. List the information about the disk sectors: # partedUtil getptbl /dev/disks/naa.5000000000000001 vmware esxi shecll - create vmfs partition on the usb drive using partedUtil
  7. The first sector is always 2048. The size of the last sector is calculated based on the getptbl output. In my example, it is calculated as follows: 121597 * 255 * 63 -1 = 1953455804
    If there is a partition on the drive, you can remove it: # partedUtil delete /dev/disks/naa.5000000000000001 1
  8. Create an VMFS partition (the GUID of such a partition is always AA31E02A400F11DB9590000C2911D1B8): # partedUtil setptbl /dev/disks/naa.5000000000000001 gpt "1 2048 1953455804 AA31E02A400F11DB9590000C2911D1B8 0"
  9. Then you can format the partition with the VMFS6: # vmkfstools -C vmfs6 -S USB-HDD-DSDatastore /dev/disks/naa.5000000000000001:1
  10. Open the graphic VMWare vSphere Client and go to Storages. Your USB drive will appear in the list of available datastores.

usb stick as a vmfs datastore on vmware esxi

How to Copy Files from USB Drive (NTFS/FAT32) to ESXi Directly?

If you don’t want to change a file system on your USB drive to VMFS (there is a little trick to access VMFS from Windows), you can access files on NTFS or FAT32 formatted partitions from the ESXi console and copy the files you want.

Disable the USB arbitrator service before connecting a USB drive to the ESXi host.

To access FAT32 formatted partitions from ESXi, you can use the mcopy tool. In order to access an NTFS partition on a USB drive, use ntfscat. Ext3 file system is also originally supported. The basic restrictions are:

  • FAT32 and Ext3 partitions are available to read and write;
  • NTFS drives are read-only (it means that you can copy data from an NTFS USB drive to an ESXi host, but not vice versa).

To copy a file from a FAT32 USB device to ESXi, use this command:

# /bin/mcopy -i "/dev/disks/naa.5000000000000001:2" ::/some.iso /vmfs/volumes/12345678-ddd654321-4321-aaaabbbb2222/iso/some.iso

where /some.iso is a path to a file on your USB drive. The second path shows where to copy the file on the ESXi host (for example, to VMFS datastore directly).

To copy a file back from ESXi to USB, just swap the paths in the command.

The main FAT32 problem is that it doesn’t support files over 4 GB. So it is quite hard to copy VMDK files of virtual machines. As a rule, you can split a source file into some parts before copying (of 3 GB, for example):

# split -b 3221225472 /vmfs/volumes/xx/vm1/vm1.vmdk

Then you can copy all parts to a USB drive and join them on a target ESXi host:

# cat vm1* > vm1.vmdk

To copy a file from an NTFS formatted USB drive to an ESXi host, the following command is used:

# /bin/ntfscat -f /dev/disks/naa.5000000000000001:2" some.iso > /vmfs/volumes/12345678-ddd654321-4321-aaaabbbb2222/iso/some.iso

You can only copy files to ESXi, not back. NTFS cannot be written with ntfscat.

5 comments
9
Facebook Twitter Google + Pinterest
previous post
How to Sign a PowerShell Script (PS1) with a Code Signing Certificate?
next post
How to Troubleshoot, Repair and Rebuild the WMI Repository?

Related Reading

Reset Root Password in VMware ESXi

October 12, 2023

How to Fix ‘An Operating System Wasn’t Found’...

July 14, 2023

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Increase Virtual Machine Disk Size in...

April 6, 2023

How to Install Free VMware Hypervisor (ESXi)

January 24, 2023

5 comments

krish April 9, 2021 - 2:15 pm

Hi,
Thank you so much for this blog. I tried lots of blog and none of them worked but this one for copying file from USB to ESXi while the host was down. The mcopy tool worked flawlessly.
Thank you

Reply
Updating the Firmware ROM on the HP ProLiant through VMWare ESXi. - September 25, 2021 - 9:25 pm

[…] stick as a datastore to store your .zip file while you install it, you’ll just need to follow this guide to enable […]

Reply
Lee December 16, 2021 - 1:43 pm

Thanks for this post, this is the most comprehensive and simple to follow. Resolved my issue in under 15 mins

Reply
Asad January 1, 2023 - 7:58 am

NTFSCAT command not found error … ESXi 7

Reply
admin January 9, 2023 - 4:25 am

Looks like ntfscat was only available in esxi 5.x and 6.x

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Adding Drivers into VMWare ESXi Installation Image
  • Shrinking VMDK Virtual Disk Size on VMWare ESXi
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Hyper-V Virtual Machine Stuck in Stopping/Starting State
  • Match Windows Disks to VMWare VMDK Files
  • Recovering a Deleted VMFS Datastore on VMware ESXi/vSphere
  • Using iPerf to Test Network Speed and Bandwidth
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top