VMware: How To Mount a USB Thumb Drive as a Data Store

Although USB is not a recommended data store type, it is still possible to mount this type of storage in VMWare. It should also be noted that VMWare will not provide support for this work around. Caveat emptor to those who choose to follow my mickey mouse methods. Also, one must be advised that a change in “USB Arbitrator” setting will affect all guests on such particular host.

Some benefits of using USB media are for storing: ISOs, infrequently used bulk files, and backup repositories. This is to save precious SAN volumes for other redundancy required production workloads.

# Get a list of existing disks

[rambo@testbox:~] ls /dev/disks/
mpx.vmhba33:C0:T0:L0
mpx.vmhba33:C0:T0:L0:1
mpx.vmhba33:C0:T0:L0:5
mpx.vmhba33:C0:T0:L0:6
mpx.vmhba33:C0:T0:L0:7
mpx.vmhba33:C0:T0:L0:8
mpx.vmhba33:C0:T0:L0:9
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1
vml.0000000000766d68626133333a303a30
vml.0000000000766d68626133333a303a30:1
vml.0000000000766d68626133333a303a30:5
vml.0000000000766d68626133333a303a30:6
vml.0000000000766d68626133333a303a30:7
vml.0000000000766d68626133333a303a30:8
vml.0000000000766d68626133333a303a30:9
vml.0100000000533235304e5830483833353139324a202020202053616d73756e
vml.0100000000533235304e5830483833353139324a202020202053616d73756e:1

# Stop USB Arbitrator (pass-through) service
/etc/init.d/usbarbitrator stop

# Disable USB Arbitrator
chkconfig usbarbitrator off
# Plugin USB thumb drive and run this command to discover the new USB disk

[rambo@esx20:~] esxcli storage core device list
--- Truncated for brevity ---
t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNJ0NC00894D_____
Display Name: Local ATA Disk (t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNJ0NC00894D_____)
Has Settable Display Name: true
Size: 953869
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNJ0NC00894D_____
Vendor: ATA
Model: Samsung SSD 870
Revision: 1B6Q
SCSI Level: 5
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: false
Is SSD: true
Is VVOL PE: false
Is Offline: false
Is Perennially Reserved: false
Queue Full Sample Size: 0
Queue Full Threshold: 0
Thin Provisioning Status: yes
Attached Filters:
VAAI Status: unknown
Other UIDs: vml.0100000000533556534e4a304e43303038393444202020202053616d73756e
Is Shared Clusterwide: false
Is SAS: false
Is USB: false
Is Boot Device: false
Device Max Queue Depth: 31
No of outstanding IOs with competing worlds: 31
Drive Type: unknown
RAID Level: unknown
Number of Physical Drives: unknown
Protection Enabled: false
PI Activated: false
PI Type: 0
PI Protection Mask: NO PROTECTION
Supported Guard Types: NO GUARD SUPPORT
DIX Enabled: false
DIX Guard Type: NO GUARD SUPPORT
Emulated DIX/DIF Enabled: false

mpx.vmhba32:C0:T0:L0
Display Name: Local USB Direct-Access (mpx.vmhba32:C0:T0:L0)
Has Settable Display Name: false
Size: 16000
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/mpx.vmhba32:C0:T0:L0
Vendor: General
Model: UDisk
Revision: 0100
SCSI Level: 2
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: true
Is SSD: false
Is VVOL PE: false
Is Offline: false
Is Perennially Reserved: false
Queue Full Sample Size: 0
Queue Full Threshold: 0
Thin Provisioning Status: unknown
Attached Filters:
VAAI Status: unsupported
Other UIDs: vml.0000000000766d68626133323a303a30
Is Shared Clusterwide: false
Is SAS: false
Is USB: true
Is Boot Device: true
Device Max Queue Depth: 1
No of outstanding IOs with competing worlds: 1
Drive Type: unknown
RAID Level: unknown
Number of Physical Drives: unknown
Protection Enabled: false
PI Activated: false
PI Type: 0
PI Protection Mask: NO PROTECTION
Supported Guard Types: NO GUARD SUPPORT
DIX Enabled: false
DIX Guard Type: NO GUARD SUPPORT
Emulated DIX/DIF Enabled: false

mpx.vmhba35:C0:T0:L0
Display Name: Local USB Direct-Access (mpx.vmhba35:C0:T0:L0)
Has Settable Display Name: false
Size: 2000000
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/mpx.vmhba35:C0:T0:L0
Vendor: USB
Model: Disk 3.0
Revision: 0200
SCSI Level: 2
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: true
Is SSD: false
Is VVOL PE: false
Is Offline: false
Is Perennially Reserved: false
Queue Full Sample Size: 0
Queue Full Threshold: 0
Thin Provisioning Status: unknown
Attached Filters:
VAAI Status: unsupported
Other UIDs: vml.0000000000766d68626133353a303a30
Is Shared Clusterwide: false
Is SAS: false
Is USB: true
Is Boot Device: false
Device Max Queue Depth: 1
No of outstanding IOs with competing worlds: 1
Drive Type: unknown
RAID Level: unknown
Number of Physical Drives: unknown
Protection Enabled: false
PI Activated: false
PI Type: 0
PI Protection Mask: NO PROTECTION
Supported Guard Types: NO GUARD SUPPORT
DIX Enabled: false
DIX Guard Type: NO GUARD SUPPORT
Emulated DIX/DIF Enabled: false

--- Truncated for brevity ---
# Run list disks command again to locate the newly detected item
# This is an example from a different ESXi host
[rambo@ESXTEST:~] ls /dev/disks/
mpx.vmhba32:C0:T0:L0
mpx.vmhba32:C0:T0:L0:1
mpx.vmhba33:C0:T0:L0
mpx.vmhba33:C0:T0:L0:1
mpx.vmhba33:C0:T0:L0:5
mpx.vmhba33:C0:T0:L0:6
mpx.vmhba33:C0:T0:L0:7
mpx.vmhba33:C0:T0:L0:8
mpx.vmhba33:C0:T0:L0:9
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1
vml.0000000000766d68626133323a303a30
vml.0000000000766d68626133323a303a30:1
vml.0000000000766d68626133333a303a30
vml.0000000000766d68626133333a303a30:1
vml.0000000000766d68626133333a303a30:5
vml.0000000000766d68626133333a303a30:6
vml.0000000000766d68626133333a303a30:7
vml.0000000000766d68626133333a303a30:8
vml.0000000000766d68626133333a303a30:9
vml.0100000000533235304e5830483833353139324a202020202053616d73756e
vml.0100000000533235304e5830483833353139324a202020202053616d73756e:1
# Make partition table for new disk
partedUtil mklabel /dev/disks/vml.0000000000766d68626133323a303a30 gpt

# Find end sector
partedUtil getptbl /dev/disks/vml.0000000000766d68626133323a303a30

[rambo@ESXTEST:~] partedUtil getptbl /dev/disks/vml.0000000000766d68626133323a303a30
Error: The primary GPT table on '/dev/disks/mpx.vmhba32:C0:T0:L0' is OK, but secondary is corrupt. Fix secondary table? This will move secondary at the end in case it is not at the end already. It will also set LastUsableLBA to use all the space at the end. diskSize (1048576000) AlternateLBA (1048575999) LastUsableLBA (1048575966)
gpt
65270 255 63 1048576000

# Calculate
# 65270 * 255 * 63 - 1 = 1048562549

# Create VMFS partition
# The start sector is always 2048
# The GUID for VMFS is AA31E02A400F11DB9590000C2911D1B8
partedUtil setptbl /dev/disks/vml.0000000000766d68626133323a303a30 gpt "1 2048 1048562549 AA31E02A400F11DB9590000C2911D1B8 0"

# An example of command being successful
[rambo@ESXTEST:~] partedUtil setptbl /dev/disks/vml.01000000003443353330303030323430
343230313035353335556c74726120 gpt "1 2048 240252074 AA31E02A400F11DB9590000C291
1D1B8 0"
gpt
0 0 0 0
1 2048 240252074 AA31E02A400F11DB9590000C2911D1B8 0

# Run this command if the existing gpt disk has errors
[rambo@ESXTEST:~] partedUtil fixGpt /dev/disks/vml.0000000000766d68626133323a303a30
FixGpt tries to fix any problems detected in GPT table.
Please ensure that you don't run this on any RDM (Raw Device Mapping) disk.
Are you sure you want to continue (Y/N): Y
Error: The primary GPT table on '/dev/disks/mpx.vmhba32:C0:T0:L0' is OK, but secondary is corrupt. Fix secondary table? This will move secondary at the end in case it is not at the end already. It will also set LastUsableLBA to use all the space at the end. diskSize (1048576000) AlternateLBA (1048575999) LastUsableLBA (1048575966)
Fix/Ignore/Cancel? Fix
gpt
65270 255 63 1048576000
1 2048 1048562549 AA31E02A400F11DB9590000C2911D1B8 vmfs 0

# Format partition with vmfs6
vmkfstools -C vmfs6 -S USB-Datastore1 /dev/disks/vml.0000000000766d68626133323a303a30:1

# Example of successful command
[rambo@ESXTEST:~] vmkfstools -C vmfs6 -S USB-Datastore /dev/disks/vml.01000000003443:1 # that last number '1' indicates the primary partition
353330303030323430343230313035353335556c74726120:1
create fs deviceName:'/dev/disks/vml.01000000003443353330303030323430343230313035353335556c74726120:1', fsShortName:'vmfs6', fsName:'USB-Datastore'
deviceFullPath:/dev/disks/t10.SanDisk00Ultra00000000000000000000004C530000240420105535:1 deviceFile:t10.SanDisk00Ultra00000000000000000000004C530000240420105535:1
ATS on device /dev/disks/t10.SanDisk00Ultra00000000000000000000004C530000240420105535:1: 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.SanDisk00Ultra00000000000000000000004C530000240420105535:1" with blockSize 1048576, unmapGranularity 1048576, unmapPriority default and volume label "USB-Datastore".
Successfully created new volume: 5d5ab29d-2aa0b031-7cbf-94c691abb6e2

# Check mounts
esxcfg-scsidevs -m

[rambo@ESXTEST:~] esxcfg-scsidevs -m
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 /vmfs/devices/disks/t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 5c8206f0-49fe1606-76b6-94c691abb6e2 0 SamsungSSD
mpx.vmhba32:C0:T0:L0:1 /vmfs/devices/disks/mpx.vmhba32:C0:T0:L0:1 5d59f580-2570f44c-5b05-94c691abb6e2 0 USB-Datastore1

[root@ESXTEST:~] esxcfg-scsidevs -m
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 /vmfs/devices/disks/t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 5c8206f0-49fe1606-76b6-94c691abb6e2 0 SamsungSSD
t10.SanDisk00Ultra00000000000000000000004C530000240420105535:1 /vmfs/devices/disks/t10.SanDisk00Ultra00000000000000000000004C530000240420105535:1 5d5ab29d-2aa0b031-7cbf-94c691abb6e2 0 USB-Datastore

Raw output of a related activity: turning usbarbitrator back ON

[root@esxtest:~] ls /dev/disks/
mpx.vmhba32:C0:T0:L0                                                        t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1  vml.0000000000766d68626133323a303a30:9
mpx.vmhba32:C0:T0:L0:1                                                      t10.ATA_____Samsung_SSD_860_EVO_1TB_________________S3Z8NB0KB46308J_____    vml.0000000000766d68626133353a303a30
mpx.vmhba32:C0:T0:L0:5                                                      t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNG0NA05357H_____    vml.0000000000766d68626133353a303a30:1
mpx.vmhba32:C0:T0:L0:6                                                      t10.ATA_____Samsung_SSD_870_QVO_1TB_________________S5VSNJ0NC00894D_____    vml.0100000000533235304e5830483833353139324a202020202053616d73756e
mpx.vmhba32:C0:T0:L0:7                                                      vml.0000000000766d68626133323a303a30                                        vml.0100000000533235304e5830483833353139324a202020202053616d73756e:1
mpx.vmhba32:C0:T0:L0:8                                                      vml.0000000000766d68626133323a303a30:1                                      vml.010000000053335a384e42304b4234363330384a202020202053616d73756e
mpx.vmhba32:C0:T0:L0:9                                                      vml.0000000000766d68626133323a303a30:5                                      vml.0100000000533556534e47304e41303533353748202020202053616d73756e
mpx.vmhba35:C0:T0:L0                                                        vml.0000000000766d68626133323a303a30:6                                      vml.0100000000533556534e4a304e43303038393444202020202053616d73756e
mpx.vmhba35:C0:T0:L0:1                                                      vml.0000000000766d68626133323a303a30:7
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____    vml.0000000000766d68626133323a303a30:8
[root@esx2:~] partedUtil mklabel /dev/disks/vml.0000000000766d68626133323a303a30:7 gpt
[root@esx2:~] partedUtil getptbl /dev/disks/vml.0000000000766d68626133323a303a30:7
gpt
14 255 63 225248

esxcfg-module -e xhci
echo "vmkload_mod xhci" >> /etc/rc.local.d/local.sh

[root@esxtest:~] /etc/init.d/usbarbitrator start
UsbUtil: Attempting to reserve for VMkernel USB adapter(s): vmhba32
usbarbitrator started
Hostd must be restarted to enable USB passthrough functionality on any VM. After hostd is restarted, to enable USB passthrough functionality on a powered on VM, the VM must be powered off and powered on again.


targetVmdk=/vmfs/volumes/6009f07e-d6fb7a24-a1e8-309c2369d30b/OpenMediaVault/nas_usb1.vmdk
deviceId=vml.0000000000766d68626133353a303a30
vmkfstools -z /vmfs/devices/disks/$deviceId $targetVmdk

[root@esxtest:~] vmkfstools -z /vmfs/devices/disks/$deviceId $targetVmdk
Failed to create virtual disk: The specified device is not a valid physical disk device (20).

/etc/init.d/usbarbitrator stop
chkconfig usbarbitrator off
partedUtil getptbl /dev/disks/mpx.vmhba35:C0:T0:L0

[root@esxtest:~] partedUtil getptbl /dev/disks/vml.0000000000766d68626133353a303a30
msdos
254964 255 63 4096000000
1 32 4095999999 7 128

[root@esxtest:~] partedUtil getptbl /dev/disks/mpx.vmhba35:C0:T0:L0
msdos
254964 255 63 4096000000
1 32 4095999999 7 128

[root@esxtest:~] partedUtil getptbl /dev/disks/mpx.vmhba35:C0:T0:L0
Error: The primary GPT table on '/dev/disks/mpx.vmhba35:C0:T0:L0' is OK, but secondary is corrupt. Fix secondary table? This will move secondary at the end in case it is not at the end already. It will also set LastUsableLBA to use all the space at the end. diskSize (4096000000) AlternateLBA (4095999999) LastUsableLBA (4095999966)
gpt
254964 255 63 4096000000

partedUtil fixGpt /dev/disks/mpx.vmhba35:C0:T0:L0

[root@esxtest:~] esxcfg-scsidevs -m
t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 /vmfs/devices/disks/t10.ATA_____Samsung_SSD_850_PRO_512GB_______________S250NX0H835192J_____:1 6009f07e-d6fb7a24-a1e8-309c2369d30b  0  ESX2-500GB
[root@esx2:~] partedUtil fixGpt /dev/disks/mpx.vmhba35:C0:T0:L0

FixGpt tries to fix any problems detected in GPT table.
Please ensure that you don't run this on any RDM (Raw Device Mapping) disk.
Are you sure you want to continue (Y/N): y
Error: The primary GPT table on '/dev/disks/mpx.vmhba35:C0:T0:L0' is OK, but secondary is corrupt. Fix secondary table? This will move secondary at the end in case it is not at the end already. It will also set LastUsableLBA to use all the space at the end. diskSize (4096000000) AlternateLBA (4095999999) LastUsableLBA (4095999966)
Fix/Ignore/Cancel? fix
gpt
254964 255 63 4096000000

[root@esxtest:~] partedUtil getptbl /dev/disks/mpx.vmhba35:C0:T0:L0
gpt
254964 255 63 4096000000

# Calculate
# 254964 * 255 * 63 - 1 = 4095996659

partedUtil setptbl /dev/disks/mpx.vmhba35:C0:T0:L0 gpt "1 2048 4095996659 AA31E02A400F11DB9590000C2911D1B8 0"

[root@esxtest:~] /etc/init.d/usbarbitrator start
UsbUtil: Attempting to reserve for VMkernel USB adapter(s): vmhba32
usbarbitrator started
Hostd must be restarted to enable USB passthrough functionality on any VM. After hostd is restarted, to enable USB passthrough functionality on a powered on VM, the VM must be powered off and powered on again.

chkconfig usbarbitrator on

[root@esxtest:~] /etc/init.d/hostd restart
watchdog-hostd: Terminating watchdog process with PID 2098597
hostd stopped.
hostd started.
[root@esxtest:~] 
[root@esxtest:~] /etc/init.d/vpxa restart
watchdog-vpxa: Terminating watchdog process with PID 2099111
vpxa stopped.
vpxa started.

# At this point, the USB device could be attached to a VM

Leave a Reply

Your email address will not be published. Required fields are marked *