{"id":603,"date":"2016-08-14T17:45:09","date_gmt":"2016-08-14T21:45:09","guid":{"rendered":"https:\/\/ithinkvirtual.com\/?p=603"},"modified":"2018-02-10T09:33:36","modified_gmt":"2018-02-10T14:33:36","slug":"create-vmfs5-datastore-on-a-usb-drive","status":"publish","type":"post","link":"https:\/\/ithinkvirtual.com\/2016\/08\/14\/create-vmfs5-datastore-on-a-usb-drive\/","title":{"rendered":"How To: Create A VMFS5 Datastore On A USB Drive"},"content":{"rendered":"
Create A VMFS5 Datastore On A USB Drive<\/strong><\/em><\/p>\r\n Ever wondered if it was possible to use a USB Drive as a VMFS5 datastore in VMware vSphere 6.0? \u00a0I sure know that I have! \u00a0Not that I would like to run any VM’s on said datastore, as I’m sure performance would not be optimal, but instead to test its functionality and use it for storing ESXi host logs for example. \u00a0Well, I ran into an issue today where I needed to unmount all of my NFS mounts on ESXi 6.0 U2 in order to recreate some of the volumes before remounting them. \u00a0The problem was that I was unable to unmount one of my volumes because it was bound to the ESXi host for scratch logs. \u00a0As I didn’t have a spare drive of any sort to attach to my host so that I could reconfigure the location for scratch logs, I began tinkering with the idea of using a small USB drive as a temporary datastore for these logs.<\/p>\r\n After doing a little research, I came across a post from Florian Grehl<\/a> aka @virten<\/a>\u00a0 showing exactly how to accomplish this so I figured I’d share the process of doing so. \u00a0Keep in mind that this should only be used for testing purposes and should not be used in production environments. \u00a0This is unsupported by VMware. \u00a0Here we go!<\/p>\r\n Ensure that the USB device is\u00a0unplugged from the ESXi host then begin by connecting to your ESXi host and stopping the USB arbitrator service. \u00a0This service is responsible for allowing USB device passthrough from an ESXi host to a virtual machine, so keep in mind that you will no longer be able to pass through USB devices to VM’s until this is restarted. \u00a0(Note: restarting service after creating and mounting USB datastore will break connectivity and recognition of the USB datastore). \u00a0\u00a0To stop the service, run the following command:<\/p>\r\n <\/a><\/a><\/p>\r\n Optionally, if you’d like to permanently disable the service so it persists thru reboots, run the following command:<\/p>\r\n Plug the USB drive into your ESXi host. \u00a0For the purposes of this tutorial, I am using a small Lexar 8GB USB device. \u00a0If you navigate to the storage\u00a0devices section on your host, you should now see the connected USB device is recognized by the hypervisor. \u00a0Make note of the device identifier number (mpx.vmhbaXX) for this device.<\/p>\r\n vSphere Client:<\/p>\r\n \u00a0<\/a><\/p>\r\n vSphere Web Client:<\/p>\r\n <\/a><\/p>\r\n vSphere HTML5 Web Client:<\/p>\r\n <\/a><\/p>\r\n You can also list the device information to determine the identifier by running the following command:<\/p>\r\n <\/a><\/p>\r\n As we can see, my identifier is mpx.vmhba40:C0:T0:L0\u00a0<\/strong><\/em>for this device which also matches the identifier from the GUI pics above. \u00a0Note: The other USB (mpx.vmhba32:C0:T0:L0) is a separate USB where ESXi is installed on.<\/p>\r\n <\/a><\/p>\r\n Next, we need to create a GPT (GUID Partition Table) label on the device. \u00a0To do so, run the following command using the correct identifier for the drive. \u00a0In my case, I will run with mpx.vmhba40<\/strong>\u00a0for all of the following commands. \u00a0Be sure to change this to your correct ID.<\/p>\r\n <\/a><\/p>\r\n Now run the following command to get the partition table information.<\/p>\r\n <\/a><\/p>\r\n This returned the following output for me…<\/p>\r\n <\/a><\/p>\r\n Next, we need to create a partition in which you will need to know the start sector and end sector which all depend on the size of the device drive and GUID. \u00a0As an FYI…<\/p>\r\n <\/a><\/p>\r\n We can also run the following command to calculate the end sector value. \u00a0This should return an identical value that matches the previous calculation.\u00a0<\/p>\r\n <\/a><\/a><\/p>\r\n If everything has gone smoothly so far, you should be ready to create the VMFS partition. \u00a0Run the following command, ensuring to replace the identifier and end sector values with your own.<\/p>\r\n <\/a><\/a><\/p>\r\n Lastly, we need to format the partition with VMFS using vmkfstools<\/strong><\/em>. \u00a0Do so by running the following (Note: “” in the command below can be any name you like so feel free to use a different name for your datastore):<\/p>\r\n <\/a><\/p>\r\n Sit tight…wait about one minute…and…voila! \u00a0<\/p>\r\n <\/a><\/p>\r\n After a quick rescan\/refresh you should now have and see your mounted VMFS5 USB Datastore!<\/p>\r\n vSphere Client:<\/p>\r\n <\/a><\/p>\r\n vSphere Web Client:<\/p>\r\n <\/a><\/p>\r\n vSphere HTML5 Web Client:<\/p>\r\n <\/a><\/p>\r\n After I changed the “Syslog” configuration for my scratch logs to use this new datastore, I was finally able to unmount my NFS datastores. \u00a0I hope this helps so please feel free to comment below.<\/p>\r\n Shoutout to Florian Grehl for his wonderful post!<\/p>\r\n Cheers!<\/p>\r\n -virtualex-<\/p>\r\n Pingbacks:<\/p>\r\n USB Devices as VMFS Datastore in vSphere ESXi 6.0<\/a><\/p>\/etc\/init.d\/usbarbitrator stop<\/pre>\r\n
chkconfig usbarbitrator off<\/pre>\r\n
ls \/dev\/disks\/<\/pre>\r\n
partedUtil mklabel \/dev\/disks\/mpx.vmhba40\\:C0\\:T0\\:L0 gpt<\/pre>\r\n
partedUtil getptbl \/dev\/disks\/mpx.vmhba40\\:C0\\:T0\\:L0<\/pre>\r\n
gpt\r\n\r\n973 255 63 15634432<\/pre>\r\n
\r\n\t
\r\n\t
eval expr $(partedUtil getptbl \/dev\/disks\/mpx.vmhba40\\:C0\\:T0\\:L0 | tail -1 | awk '{print $1 \" \\\\* \" $2 \" \\\\* \" $3}') - 1<\/span><\/pre>\r\n
partedUtil setptbl \/dev\/disks\/mpx.vmhba40\\:C0\\:T0\\:L0 gpt \"1 2048 15631244 AA31E02A400F11DB9590000C2911D1B8 0\"<\/pre>\r\n
vmkfstools -C vmfs5 -S USB_Datastore \/dev\/disks\/mpx.vmhba40\\:C0\\:T0\\:L0:1<\/pre>\r\n