This article describes how you can connect a USB drive directly to an esx4/esxi4(vSphere) host
As most people know, this is an unsupported method and undocumented by vmware
Refer to KB Article: 1015
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1015&sliceId=2&docTypeID=DT_KB_1_1&dialogID=53350659&stateId=0Hopefully this will be the first article to discuss about copying files to USB drive under vmware esx/esxi console, as most returned results from Google search are basically for a VM(Virtual Machine) to access USB drive on the vSphere host via VMDirectPath. For short, VMDirectPath requires IOMMU feature enabled in BIOS and allows VM to access an USB drive attached to esx4/esxi4 host directly
Why do you want to connect a USB drive to an esx4/esxi4 host under console?
Quick copy/backup of virtual machine files or other files such as dump, log, txt, conf, etc. at the console without needing a vSphere Client or other machine to download the files
Requirements:
1. Server hardware with USB controller/port (It may not work for all hardware)
2. esxi4/esx4 installed (First release, haven't tried on Update 1 yet)
3. USB drive (any type of USB drive should work but must be formatted correctly, refer steps below)
4. Yourself physically at the server and a bit of luck with the hardware
5. Minor unix skills
STEPS FOR VMware ESX 4
1. Format the USB drive with the classic FAT aka FAT16 or FAT32 filesystem
2. If you need linux ext3 you can format it with mke2fs -j /dev/sdXX (refer to step 6 for the correct device)
3. FAT/ ext3 will work but since Windows based machines are highly available today, it is recommended that to format the USB drive with FAT using any Windows based machine, for example you can format the USB drive under Windows XP Professional
4. FAT is also the prefered file system for this because it can be read by almost any OS, so you can still use the USB drive for other purposes but take note due to FAT file system limitation, you can't copy large files more than 4GB, so if you really need to copy huge vmdk files, format drive with ext3 instead or use the split command to split the huge file to smaller files(for eg. split -b 2000m /path/to/large/file prefix_name)
5. Login to your esx service sonsole with a non root, always use sudo to run command
6. List current partition in with sudo fdisk -l | more (lines shortened to simplify output)
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 140 1124518+ 83 Linux
/dev/sda2 141 154 112455 fc VMware VMKCORE
/dev/sda3 155 1305 9245407+ 5 Extended
/dev/sda5 155 1305 9245376 fb VMware VMFS
Disk /dev/sdb: 7973 MB, 7973371904 bytes
255 heads, 63 sectors/track, 969 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 76 610438+ 82 Linux swap / Solaris
/dev/sdb2 77 331 2048287+ 83 Linux
/dev/sdb3 332 969 5124735 5 Extended
/dev/sdb5 332 969 5124703+ 83 Linux
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Select allOpen in new window
7. List current path (lines shortened to simplify output)
ide.vmhba32-ide.0:0-mpx.vmhba32:C0:T0:L0
Runtime Name: vmhba32:C0:T0:L0
Device: mpx.vmhba32:C0:T0:L0
Device Display Name: Local NECVMWar CD-ROM (mpx.vmhba32:C0:T0:L0)
State: active
Transport: ide
pscsi.vmhba0-pscsi.0:0-mpx.vmhba0:C0:T0:L0
Runtime Name: vmhba0:C0:T0:L0
Device: mpx.vmhba0:C0:T0:L0
Device Display Name: Local VMware, Disk (mpx.vmhba0:C0:T0:L0)
State: active
Transport: parallel
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Select allOpen in new window
8. Now plug in the drive to any available USB port
9. Wait for few seconds for the device to initialize or wait until LED to stop blinking(if any)
10. Sudo tail -n 30 /var/log/messages
Nov 10 00:13:01 esx kernel: [ 1846.960769] scsi6 : usb-storage
Nov 10 00:13:04 esx kernel: [ 1849.251287] Vendor: Kingston Model: DataTraveler 2.0 Rev: PMAP
Nov 10 00:13:04 esx kernel: [ 1849.257273] Type: Direct-Access ANSI SCSI revision: 02
Nov 10 00:13:04 esx kernel: [ 1849.296265] SCSI device sde: 3919872 512-byte hdwr sectors (2007 MB)
Nov 10 00:13:04 esx kernel: [ 1849.319976] sde: Write Protect is off
Nov 10 00:13:04 esx kernel: [ 1849.372450] sde: got wrong page
Nov 10 00:13:04 esx kernel: [ 1849.374587] sde: assuming drive cache: write through
Nov 10 00:13:04 esx kernel: [ 1849.407522] SCSI device sde: 3919872 512-byte hdwr sectors (2007 MB)
Nov 10 00:13:04 esx kernel: [ 1849.418315] sde: Write Protect is off
Nov 10 00:13:04 esx kernel: [ 1849.431574] sde: got wrong page
Nov 10 00:13:04 esx kernel: [ 1849.440507] sde: assuming drive cache: write through
Nov 10 00:13:04 esx kernel: [ 1849.440514] sde: sde1
Nov 10 00:13:04 esx kernel: [ 1849.447718] sd 4:0:4:0: Attached scsi removable disk sde
Nov 10 00:13:04 esx kernel: [ 1849.449689] sd 4:0:4:0: Attached scsi generic sg5 type 0
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Select allOpen in new window
11. As you can see the USB drive is detected & initialized by host
12. Now verify current partition in with sudo fdisk -l | more
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 140 1124518+ 83 Linux
/dev/sda2 141 154 112455 fc VMware VMKCORE
/dev/sda3 155 1305 9245407+ 5 Extended
/dev/sda5 155 1305 9245376 fb VMware VMFS
Disk /dev/sdb: 7973 MB, 7973371904 bytes
255 heads, 63 sectors/track, 969 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 76 610438+ 82 Linux swap / Solaris
/dev/sdb2 77 331 2048287+ 83 Linux
/dev/sdb3 332 969 5124735 5 Extended
/dev/sdb5 332 969 5124703+ 83 Linux
Disk /dev/sde: 2006 MB, 2006974464 bytes
16 heads, 32 sectors/track, 7656 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 7656 1959920 6 FAT16
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Select allOpen in new window
13. From the output above, /dev/sde1 is actually the USB drive (it may be different on your machine but it will be in this format /dev/sdXX)
14. Now verify current path with esxcfg-mpath -l (lines shortened to simplify output)
ide.vmhba32-ide.0:0-mpx.vmhba32:C0:T0:L0
Runtime Name: vmhba32:C0:T0:L0
Device: mpx.vmhba32:C0:T0:L0
Device Display Name: Local NECVMWar CD-ROM (mpx.vmhba32:C0:T0:L0)
State: active
Transport: ide
pscsi.vmhba0-pscsi.0:0-mpx.vmhba0:C0:T0:L0
Runtime Name: vmhba0:C0:T0:L0
Device: mpx.vmhba0:C0:T0:L0
Device Display Name: Local VMware, Disk (mpx.vmhba0:C0:T0:L0)
State: active
Transport: parallel
usb.vmhba34-usb.0:0-mpx.vmhba34:C0:T0:L0
Runtime Name: vmhba34:C0:T0:L0
Device: mpx.vmhba34:C0:T0:L0
Device Display Name: Local USB Direct-Access (mpx.vmhba34:C0:T0:L0)
State: active
Transport: usb
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Select allOpen in new window
15. As you can see, the USB drive is active and ready to be mounted
16. Type sudo mkdir /mnt/myusb
17. Type sudo mount /dev/sde1 /mnt/myusb
18. Note, you don't even have to specify the filesystem with -t
19. Now verify current mount points by typing mount
/dev/sdb5 on / type ext3 (rw)
None on /proc type proc (rw)
None on /sys type sysfs (rw)
None on /dev/pts type devpts (rw)
/dev/sda1 on /boot type ext3 (rw)
/dev/sdb2 on /var/log type ext3 (rw,errors=panic)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sde1 on /mnt/myusb type vfat (rw)
1:
2:
3:
4:
5:
6:
7:
8:
9:
Select allOpen in new window
20. Your USB drive is now mounted as vfat
21. Try copying files from /vmfs/volumes/your_datastore/your_vm to your USB drive
22. For example, sudo cp /vmfs/volumes/iscsi-50GB/VDR-01/*.log /mnt/myusb
23. Now verify copied files in your USB drive, sudo ls -lah /mnt/myusb
total 548K
drwxr-xr-x 2 root root 16K Nov 10 00:32 .
drwxr-xr-x 6 root root 4.0K Nov 10 00:23 ..
-rwxr-xr-x 1 root root 35K Nov 10 00:32 vmware-1.log
-rwxr-xr-x 1 root root 52K Nov 10 00:32 vmware-2.log
-rwxr-xr-x 1 root root 55K Nov 10 00:32 vmware-3.log
-rwxr-xr-x 1 root root 56K Nov 10 00:32 vmware-4.log
-rwxr-xr-x 1 root root 56K Nov 9 23:26 vmware-5.log
-rwxr-xr-x 1 root root 56K Nov 9 23:26 vmware-6.log
-rwxr-xr-x 1 root root 58K Nov 9 23:26 vmware-7.log
-rwxr-xr-x 1 root root 52K Nov 10 00:32 vmware.log
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Select allOpen in new window
24. Now you get the idea, happy copying files to USB drive on your esx host!
25. By the way, if you are wondering what happen if you try to mount NTFS drive, you will get this friendly message "mount: unknown filesystem type 'ntfs'"
STEPS FOR VMware ESXi 4
1. Note, ext3 will not work with esxi!
2. Assuming USB drive is already formatted with FAT, login to "unsupported mode"
3. At the esxi console, press alt+F1 and Type: unsupported (you can't see what you type and hit ENTER)
4. Key in the root password(you can't see what you type and hit ENTER)
5. View current partition with fdisk -l
Disk /dev/disks/mpx.vmhba1:C0:T0:L0: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/disks/mpx.vmhba1:C0:T0:L0p1 5 900 917504 5 Extended
/dev/disks/mpx.vmhba1:C0:T0:L0p2 901 4995 4193280 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p3 4996 10240 5370880 fb VMFS
/dev/disks/mpx.vmhba1:C0:T0:L0p4 * 1 4 4080 4 FAT16 <32M
/dev/disks/mpx.vmhba1:C0:T0:L0p5 5 254 255984 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p6 255 504 255984 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p7 505 614 112624 fc VMKcore
/dev/disks/mpx.vmhba1:C0:T0:L0p8 615 900 292848 6 FAT16
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Select allOpen in new window
6. View current path with esxcfg-mpath -l
ide.vmhba32-ide.0:0-mpx.vmhba32:C0:T0:L0
Runtime Name: vmhba32:C0:T0:L0
Device: mpx.vmhba32:C0:T0:L0
Device Display Name: Local MagicISO CD-ROM (mpx.vmhba32:C0:T0:L0)
State: active
Transport: ide
pscsi.vmhba1-pscsi.0:0-mpx.vmhba1:C0:T0:L0
Runtime Name: vmhba1:C0:T0:L0
Device: mpx.vmhba1:C0:T0:L0
Device Display Name: Local VMware, Disk (mpx.vmhba1:C0:T0:L0)
State: active
Transport: parallel
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Select allOpen in new window
7. Now plug in the drive to any available USB port
8. Wait for few seconds for the device to initialize or wait until LED to stop blinking(if any)
9. Sudo tail -n 30 /var/log/messages
Dec 13 02:01:21 vmkernel: 0:00:04:46.032 cpu0:4298)<6>usb 1-1: New USB device found, idVendor=0951, idProduct=1607
Dec 13 02:01:21 vmkernel: 0:00:04:46.032 cpu1:8807)<7>usb-storage: device found at 2
Dec 13 02:01:21 vmkernel: 0:00:04:46.032 cpu0:4298)<6>usb 1-1: new device strings: Mfr=1, Product=2, SerialNumber=3
Dec 13 02:01:21 vmkernel: 0:00:04:46.032 cpu1:8807)<7>usb-storage: waiting for device to settle before scanning
Dec 13 02:01:21 vmkernel: 0:00:04:46.043 cpu0:4117)ScsiNpiv: 1304: GetInfo for adapter vmhba33, [0x410004103bc0], max_vports=0, vports_inuse=0, linktype=0, state=0, failreason=0, rv=-1, sts=bad0020
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu0:8806)usb-storage: detected SCSI revision number 0 on vmhba33
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu0:8806)usb-storage: patching inquiry data to change SCSI revision number from 0 to 2 on vmhba33
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu1:8807)ScsiScan: 839: Path 'vmhba33:C0:T0:L0': Vendor: 'Kingston' Model: 'DataTraveler 2.0' Rev: 'PMAP'
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu1:8807)ScsiScan: 842: Path 'vmhba33:C0:T0:L0': Type: 0x0, ANSI rev: 2, TPGS: 0 (none)
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu0:8807)ScsiUid: 268: Path 'vmhba33:C0:T0:L0' does not support VPD Device Id page.
Dec 13 02:01:23 vmkernel: 0:00:04:48.038 cpu0:8807)ScsiScan: 954: Path 'vmhba33:C0:T0:L0' : No standard UID: Failure. ANSI version 'SCSI-2' (0x2).
Dec 13 02:01:23 vmkernel: 0:00:04:48.039 cpu0:8807)VMWARE SCSI Id: Could not get disk id for vmhba33:C0:T0:L0
Dec 13 02:01:23 vmkernel: 0:00:04:48.040 cpu0:8807)ScsiPath: 3698: Plugin 'NMP' claimed path 'vmhba33:C0:T0:L0'
Dec 13 02:01:23 vmkernel: 0:00:04:48.046 cpu1:8806)usb-storage: detected SCSI revision number 0 on vmhba33
Dec 13 02:01:23 vmkernel: 0:00:04:48.046 cpu1:8806)usb-storage: patching inquiry data to change SCSI revision number from 0 to 2 on vmhba33
Dec 13 02:01:23 vmkernel: 0:00:04:48.046 cpu0:8807)ScsiUid: 268: Path 'vmhba33:C0:T0:L0' does not support VPD Device Id page.
Dec 13 02:01:23 vmkernel: 0:00:04:48.047 cpu1:8807)VMWARE SCSI Id: Could not get disk id for vmhba33:C0:T0:L0
Dec 13 02:01:23 Hostd: [2009-12-13 02:01:23.768 33018B90 verbose 'StorageSystem'] StoragePathUpdate Refresh --: [N11HostdCommon25VmkernelUpdateStoragePathE:0xec882f8] timestamp=1260669683768212 updated=0xecd3a08
Dec 13 02:01:23 Hostd: [2009-12-13 02:01:23.768 33018B90 verbose 'StorageSystem'] SendStorageInfoEvent() called
Dec 13 02:01:23 Hostd: [2009-12-13 02:01:23.769 33018B90 verbose 'StorageSystem'] StoragePathUpdate: Path state change event generated Storage related Notifications
Dec 13 02:01:23 vmkernel: 0:00:04:48.047 cpu1:8807)VMWARE SCSI Id: Could not get disk id for vmhba33:C0:T0:L0
Dec 13 02:01:23 vmkernel: 0:00:04:48.047 cpu1:8807)ScsiDeviceIO: 2114: Get VPD 80 Inquiry for device "mpx.vmhba33:C0:T0:L0" from Plugin "NMP" failed. Not supported
Dec 13 02:01:23 vmkernel: 0:00:04:48.047 cpu1:8807)ScsiDeviceIO: 2124: Get VPD 83 Inquiry for device "mpx.vmhba33:C0:T0:L0" from Plugin "NMP" failed. Not supported
Dec 13 02:01:23 vmkernel: 0:00:04:48.102 cpu1:8807)FSS: 3647: No FS driver claimed device 'mpx.vmhba33:C0:T0:L0:1': Not supported
Dec 13 02:01:23 vmkernel: 0:00:04:48.102 cpu1:8807)ScsiDevice: 1757: Successfully registered device "mpx.vmhba33:C0:T0:L0" from plugin "NMP" of type 0
Dec 13 02:01:23 vmkernel: 0:00:04:48.104 cpu1:8807)<7>usb-storage: device scan complete
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Select allOpen in new window
10. As you can see the USB drive is detected as vmhba33:C0:T0:
11. Now verify current partition in with sudo fdisk -l | more
Disk /dev/disks/mpx.vmhba33:C0:T0:L0: 2006 MB, 2006974464 bytes
16 heads, 32 sectors/track, 7656 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System
/dev/disks/mpx.vmhba33:C0:T0:L0p1 1 7656 1959920 6 FAT16
Disk /dev/disks/mpx.vmhba1:C0:T0:L0: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/disks/mpx.vmhba1:C0:T0:L0p1 5 900 917504 5 Extended
/dev/disks/mpx.vmhba1:C0:T0:L0p2 901 4995 4193280 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p3 4996 10240 5370880 fb VMFS
/dev/disks/mpx.vmhba1:C0:T0:L0p4 * 1 4 4080 4 FAT16 <32M
/dev/disks/mpx.vmhba1:C0:T0:L0p5 5 254 255984 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p6 255 504 255984 6 FAT16
/dev/disks/mpx.vmhba1:C0:T0:L0p7 505 614 112624 fc VMKcore
/dev/disks/mpx.vmhba1:C0:T0:L0p8 615 900 292848 6 FAT16
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Select allOpen in new window
12. From the output, we can see that the drive partition is detected fine as well
13. Now verify all paths with esxcfg-mpath -l
ide.vmhba32-ide.0:0-mpx.vmhba32:C0:T0:L0
Runtime Name: vmhba32:C0:T0:L0
Device: mpx.vmhba32:C0:T0:L0
Device Display Name: Local MagicISO CD-ROM (mpx.vmhba32:C0:T0:L0)
State: active
Transport: ide
usb.vmhba33-usb.0:0-mpx.vmhba33:C0:T0:L0
Runtime Name: vmhba33:C0:T0:L0
Device: mpx.vmhba33:C0:T0:L0
Device Display Name: Local USB Direct-Access (mpx.vmhba33:C0:T0:L0)
State: active
Transport: usb
pscsi.vmhba1-pscsi.0:0-mpx.vmhba1:C0:T0:L0
Runtime Name: vmhba1:C0:T0:L0
Device: mpx.vmhba1:C0:T0:L0
Device Display Name: Local VMware, Disk (mpx.vmhba1:C0:T0:L0)
State: active
Transport: parallel
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Select allOpen in new window
14. Looks good, but how do we mount it?
15. Well the answer is you don't have to! It's already magically mounted! As long as the USB drive is formatted with FAT, esxi4 will mount it as NO NAME under /vmfs/volumes/
16. To check this, simply ls -lah /vmfs/volumes (lines shortened to simplify output)
l--------- 0 root root 1.9k Jan 1 1970 Hypervisor1 -> 8cb4ed7d-7ff4129e-ea93-3a40177d3073
l--------- 0 root root 1.9k Jan 1 1970 Hypervisor2 -> be05e675-6944d5d6-989a-883d97a99f55
l--------- 0 root root 1.9k Jan 1 1970 Hypervisor3 -> efd8efe3-03bc1cbf-15e0-080efd9e7379
l--------- 0 root root 1.9k Jan 1 1970 NO NAME -> mpx.vmhba33:C0:T0:L0:1
l--------- 0 root root 1.9k Jan 1 1970 datastore1 -> 4b2448d6-67f9bb38-2010-000c2963e851
1:
2:
3:
4:
5:
Select allOpen in new window
17. Meaning you can copy files from anywhere to /vmfs/volumes/NO\ NAME/
18. Again, it is actually /vmfs/volumes/NO\ NAME/ with the backslash in between NO and NAME not /vmfs/volumes/NO NAME/ or you can use the TAB button to complete it as you type /vmfs/volumes/N
19. If that is too complicated, mkdir /myusb
20. Create a soft symbolic link(shortcut), ln -s /vmfs/volumes/NO\ NAME /myusb/
21. From now on, you can copy files to /myusb for example cp /etc/*.conf /myusb/
22. Now you get the idea, happy copying files to USB drive on your esxi host!
Thanks for reading my article and try this on a test server first!
If you dont understand or not sure, i recommend to get someone familiar with esx/esxi to assist you.
Cheers!
by: rindi on 2009-12-16 at 01:50:45ID: 6752
Maybe a simple Question, but how do you get to the Console ("CLI") in ESXi 4 Server? On the Server itself I only get a simple interface where I can change the network setting, passwords, view logs etc, but I don't have any normal bash prompt access. I also tried connecting to the server from a Linux PC using ssh, but there doesn't seem to be any SSH Server running on the ESXi Server. The ViClient tool running on a Windows 7 PC also doesn't have any options that I can find with which I can get to a command prompt on the ESXi server.