{"id":270,"date":"2020-02-03T09:40:32","date_gmt":"2020-02-03T09:40:32","guid":{"rendered":"https:\/\/bene.webtopia.ch\/?p=270"},"modified":"2021-10-26T07:29:07","modified_gmt":"2021-10-26T07:29:07","slug":"https-www-altaro-com-vmware-directpath-io-esxi","status":"publish","type":"post","link":"https:\/\/bene.webtopia.ch\/?p=270","title":{"rendered":"https:\/\/www.altaro.com\/vmware\/directpath-io-esxi\/"},"content":{"rendered":"\n<p>I was recently toying with the idea of setting up a FreeNAS virtual machine on my <a href=\"https:\/\/www.altaro.com\/vmware\/deploying-vsphere-esxi-6-5\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESXi 6.5<\/a>\n host. This would give me an alternative shared storage resource to add \nto my testing environment. With that in mind, I sat down and started \nlooking around for recommendations and what not, on how to accomplish \nthe task. Many of the posts I came across, recommended to go for \npassthrough, or passthru, technically known as DirectPath I\/O. My \noriginal thought was to use RDM or a plain old vmdk and attach it to the\n FreeNAS VM.<\/p>\n\n\n\n<p>The problem with the latter solution is mainly one of performance \nregardless of this being a testing environment. With DirectPath&nbsp;enabled,\n I can give the FreeNAS VM direct access to a couple of unused drives \ninstalled on the host. So, without giving it further thought, I went \nahead and enabled pass-through on the storage controller on my testing \nESXi host.<\/p>\n\n\n\n<p>And here comes the big disclaimer.&nbsp;<strong>DO NOT DO THIS ON A LIVE SYSTEM<\/strong>. You have been warned!<\/p>\n\n\n\n<p>This post exists for the sole reason of helping some poor soul, out \nthere, to recover from what turned out to be a silly oversight. More to \ncome on this.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What went wrong?<\/strong><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The physical host I chose for my grandiose plan, has a single IBEX \nSATA controller with 3 disks attached to it. Nothing fancy. It\u2019s just \nsoftware emulated RAID which ESXi doesn\u2019t even recognize hence the \nnon-utilized drives. I\u2019m only using one drive which I\u2019ve also used to \ninstall ESXi on. Remember, this is a testing environment. On \nthis&nbsp;one&nbsp;drive, there\u2019s also the default local datastore and a couple of\n VMs.<\/p>\n\n\n\n<p>The drive, by default, is split into a number of partitions during the ESXi installation. Two of the partitions, called <em>bootbank<\/em> and <em>altbootbank<\/em>, hold the ESXi binaries that are loaded into memory during the booting process. I\u2019ll come back to this later.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof2.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p>Back to the business of enabling <a href=\"https:\/\/docs.vmware.com\/en\/VMware-vSphere\/6.5\/com.vmware.vsphere.networking.doc\/GUID-BF2770C3-39ED-4BC5-A8EF-77D55EFE924C.html\" target=\"_blank\" rel=\"noreferrer noopener\">DirectPath I\/O<\/a>\n on a PCI card such as a storage controller. In the next screenshot, \nI\u2019ve highlighted the ESXi host in question and labeled the steps taken \nto enable DirectPath for a PCI device. This is enabled by simply ticking\n a box next to the device name. In this case, I enabled pass-through on \nthe Ibex Peak SATA controller. Keep in mind that this is my one and only\n storage controller.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof3.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p>After enabling DirectPath&nbsp;, you are reminded that the host must be rebooted for the change to take root.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof4.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p>Again, without giving it much thought, I rebooted the host. Five \nminutes later and the host was back on line. I proceeded to create the \nnew VM for FreeNAS but I quickly found out that I no longer had a \ndatastore where to create it. And it suddenly dawned on me! With \nDirectPath&nbsp;enabled, the hypervisor will no longer have access to the \ndevice. Darn!<\/p>\n\n\n\n<p>And that\u2019s when I ended up with a bunch of inaccessible VMs on a datastore that was no more.<\/p>\n\n\n\n<p>At this point, panic would have quickly ensued if this were a live \nsystem but thankfully it was not. I started digging around in vSphere \nclient, and one of first things noticed was that the Ibex storage \nadapter was not listed under <em>Storage Adapters<\/em>&nbsp;irrespective of the number of rescans carried out.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof5.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p>The logical solution that first came to mind was, disable DirectPath \nI\/O on the storage controller, reboot the host and restore everything to\n its former glory. So I did, rebooted the host and&nbsp; waited for another 5\n minutes only to discover the host was still missing the datastore and \nstorage adapter.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof6.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Fix<\/strong><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The first fix I found on the net is the one described in&nbsp;<a href=\"https:\/\/kb.vmware.com\/s\/article\/1022011\" target=\"_blank\" rel=\"noreferrer noopener\">KB1022011<\/a>. Basically, you SSH to ESXi and inspect <em>\/etc\/vmware\/esx.conf<\/em>&nbsp;looking for the line where a device\u2019s <em>owner<\/em>&nbsp;value is set to&nbsp;<em>passthru<\/em>. This&nbsp;must be changed to <em>vmkernel <\/em>to disable pass-through. To verify the device is the correct one, look at the \/d<em>evice&nbsp;<\/em>value and compare it to the <em>Device ID<\/em> value in vSphere Web client; <em>Configure -&gt; PCI Devices<\/em> -&gt; <em>Edit<\/em>.<\/p>\n\n\n\n<p>In this example, the device ID, for the storage controller, is&nbsp;<em>3b25<\/em>&nbsp;meaning I know I\u2019m changing the correct one. You can see this in the next screenshot.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof7.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p>To replace the entry, use&nbsp;<em>vi<\/em>, substituting&nbsp;<em>passthru<\/em>&nbsp;with <em>vmkernel<\/em>,&nbsp;which\n is what I did. I rebooted the host a third time and much to my \nannoyance it was still missing the datastore. After some more digging \naround, I came across these two links;&nbsp;<a href=\"http:\/\/pleasework.robbievance.net\/howto-the-wrong-way-to-use-vmware-directpath\/\" target=\"_blank\" rel=\"noreferrer noopener\">The wrong way to use VMware DirectPath<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/kb.vmware.com\/s\/article\/2043048\" target=\"_blank\" rel=\"noreferrer noopener\">KB2043048<\/a>.<\/p>\n\n\n\n<p>The first link is what helped me fix the issue and also provided me \nwith the inspiration to write this post, so kudos goes to the author.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>So, why did the fix fail?<\/strong><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The simple explanation is that the changes done, given my setup, \nwon\u2019t persist because everything is running off volatile memory, in RAM \nthat is. This means that once ESXi is rebooted, the change done to <em>esx.conf&nbsp;<\/em>is lost too and it\u2019s back to square one. During the booting process, the ESXi binaries are loaded from partition <em>sda5<\/em>&nbsp;(bootbank) or&nbsp;<em>sda6<\/em>&nbsp;(altbootbank) depending on which one is currently marked active.<\/p>\n\n\n\n<p>The host\u2019s configuration files are automatically and periodically backed up via script to an archive called <em>state.tgz<\/em>\n which is copied to both partitions depending on which one is active at \nthe time. This backup mechanism is what allows you to revert to a \nprevious state using&nbsp;<a href=\"https:\/\/kb.vmware.com\/s\/article\/1033604\" target=\"_blank\" rel=\"noreferrer noopener\">Shift-R<\/a>&nbsp;while\n ESXi is booting. Unfortunately, in my case, the pass-through change was\n backed up as well and copied to both partitions or so it seemed.<\/p>\n\n\n\n<p>ESXi has full visibility of the drive while booting up, which \nexplains why it manages to in the first place despite the pass-through \nsetting. It is only when <em>esx.conf<\/em> is read, that the pass-through setting is enforced\/<\/p>\n\n\n\n<p>Reverting to a previous state using <em>Shift-R<\/em> did not work for me, so I went down the GParted route.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The GParted Fix<\/strong><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>GParted, GNOME Partition Editor, is a free Linux-based disk \nmanagement utility that has saved my skin on countless occasions. You \ncan create a GParted bootable USB stick by downloading the ISO from <a href=\"https:\/\/gparted.org\/download.php\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> and using <a href=\"https:\/\/rufus.akeo.ie\/\" target=\"_blank\" rel=\"noreferrer noopener\">Rufus<\/a>.<\/p>\n\n\n\n<p>As mentioned already, we need to change the <em>passthru<\/em> setting in the backed up <em>esx.conf<\/em> file found in the&nbsp;<em>state.tgz<\/em> archive. To do this, we must first uncompress <em>state.tgz<\/em> which contains a second archive,&nbsp;<em>local.tgz.<\/em><\/p>\n\n\n\n<p>Uncompressing <em>local.tgz<\/em> yields&nbsp;<em>\/etc<\/em> folder where we find&nbsp;<em>esx.conf.&nbsp;<\/em>Once there, open<em> esx.conf<\/em> in an editor<em>.&nbsp;<\/em>Find and change the <em>passthru<\/em> entry and compress the <em>\/etc<\/em> folder back to <em>state.tgz.&nbsp;<\/em><\/p>\n\n\n\n<p>Finally we overwrite the original <em>state.tgz<\/em> files under \/sda5 and \/sda6 and reboot the host.<\/p>\n\n\n\n<p>Here\u2019s the whole procedure in step form.<\/p>\n\n\n\n<p><strong>Step 1<\/strong> \u2013 Boot the ESXi server off the GParted USB stick. Once it\u2019s up, open a terminal window.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof8.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p><strong>Step 2<\/strong>&nbsp;\u2013 Run the following commands.\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tcd \/\nmkdir \/mnt\/hd1 \/mnt\/hd2 \/temp\nmount -t vfat \/dev\/sd5 \/mnt\/hd1\nmount -t vfat \/dev\/sd6 \/mnt\/hd2\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>\n\t\t\t\t\t1234\n\t\t\t\t<\/td><td>cd \/mkdir \/mnt\/hd1 \/mnt\/hd2 \/tempmount -t vfat \/dev\/sd5 \/mnt\/hd1mount -t vfat \/dev\/sd6 \/mnt\/hd2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Step 3<\/strong> \u2013 Determine which <em>state.tgz<\/em>&nbsp;file is \nmost current. Run the following commands and look at the time stamps. \nYou\u2019ll need to uncompress the most recent one to keep using the current \nhost configuration save for the changes we\u2019ll be making.\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tls -l \/mnt\/hd1\/state.tgz\nls -l \/mnt\/hd2\/state.tgz\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>\n\t\t\t\t\t12\n\t\t\t\t<\/td><td>ls -l \/mnt\/hd1\/state.tgzls -l \/mnt\/hd2\/state.tgz<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Here I\u2019m showing the file while SSH\u2019ed to the host<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof9.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p><strong>Step 4<\/strong> \u2013 Copy the most current <em>state.tgz<\/em> to <em>\/temp<\/em>. Here, I\u2019ve assumed that the most current file is the one under <em>\/mnt\/hd1<\/em>. Yours could be different.\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tcp \/mnt\/hd1\/state.tgz \/temp\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>\n\t\t\t\t\t1\n\t\t\t\t<\/td><td>cp \/mnt\/hd1\/state.tgz \/temp<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Step 5<\/strong> \u2013 Uncompress <em>state.tgz<\/em> and the resulting <em>local.tgz<\/em> using tar. You should end up with an <em>etc<\/em> directory as shown.\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tcd \/temp\ntar -xf state.tgz\ntar -xf local.tgz\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>\n\t\t\t\t\t123\n\t\t\t\t<\/td><td>cd \/temptar -xf state.tgztar -xf local.tgz<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof10.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p><strong>Step 6<\/strong> \u2013 Navigate to <em>\/temp\/etc\/vmware<\/em> and open <em>esx.conf<\/em> in <em>vi<\/em>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/112417_1102_Theperilsof11.png\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li>Press [\/] and type <em>passthru<\/em> followed by Enter. This takes you to the line you need to edit assuming <em>passthru<\/em> has been enabled just for one device. If not, make sure the device ID matches as explained above.<\/li><li>Press [Insert] and change the value to <em>vmkernel<\/em>.<\/li><li>Press [ESC], [:] and type <em>wq.<\/em><\/li><li>Press [Enter] to save the changes.<\/li><\/ul>\n\n\n\n<p><strong>Step 7<\/strong> \u2013 Compress the archive and copy it back to <em>\/mnt\/hd1<\/em> and <em>\/mnt\/hd2<\/em>.\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tcd \/temp\nrm *.tgz\ntar -cf local.tgz etc\ntar -cf state.tgz local.tgz\ncp state.tgz \/mnt\/hd1\ncp state.tgz \/mnt\/hd2\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>\n\t\t\t\t\t123456\n\t\t\t\t<\/td><td>cd \/temprm *.tgztar -cf local.tgz etctar -cf state.tgz local.tgzcp state.tgz \/mnt\/hd1cp state.tgz \/mnt\/hd2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Reboot the host and your datastore and virtual machines should spring\n back to life. The procedure worked for me. The storage adapter, \ndatastore and VM all came back to life with no apparent issues.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/s25967.pcdn.co\/vmware\/wp-content\/uploads\/2017\/11\/ibex-controller.png\" alt=\"ibex controller\" class=\"wp-image-18053\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The moral of the story is to test, test and test before replicating \nsomething on a production system. Reading the manual and doing some \nresearch first goes a long way in avoiding similar situations. The \ncorrect solution of course, in this case, would have been to install a \n2nd storage controller and enable DirectPath on it. The optimal solution\n would be to install FreeNas on proper hardware instead of virtualizing \nit, something I haven\u2019t written about but might cover in a future post. \nIn the meantime, have a look at the <a href=\"https:\/\/www.altaro.com\/vmware\/list-vmware-articles\/\" target=\"_blank\" rel=\"noreferrer noopener\">complete list<\/a> of VMware posts on this blog for more interesting topics to learn from.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently toying with the idea of setting up a FreeNAS virtual machine on my ESXi 6.5 host. This would give me an alternative shared storage resource to add to my testing environment. With that in mind, I sat down and started looking around for recommendations and what not, on how to accomplish the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[11,19],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-edv-ecke","category-esxi"],"_links":{"self":[{"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":1,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":271,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions\/271"}],"wp:attachment":[{"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bene.webtopia.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}