{"id":212,"date":"2010-02-15T20:04:35","date_gmt":"2010-02-15T09:04:35","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=212"},"modified":"2010-07-13T18:12:38","modified_gmt":"2010-07-13T08:12:38","slug":"the-danger-of-multiple-storage-vmotions","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=212","title":{"rendered":"The danger of multiple Storage VMotions"},"content":{"rendered":"<p>Today I received a bunch of new LUNs for some VMs in a development environment. The task is to move all the VMs off the old LUNs to the new LUNs, so great I thought I can use PowerCLI to move a whole bunch at a time. In this case, 10 VMs to one LUN (don&#8217;t ask about VMs per LUN ratios). So this is what I did.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$rp = Get-ResourcePool -name &quot;MyResourcePool&quot;\r\n$ds = Get-Datastore -Name &quot;MyDatastore&quot;\r\n$vmlist = Get-VM -Location $rp\r\n$vmlist | Move-VM -Datastore $ds\r\n<\/pre>\n<p>What did this do? Well it kicked off all 10 SVMotions at the same time! This consequently caused all but one ESX host in the cluster to enter a disconnected state. Holy cow I thought, have a crashed them all? A quick look at the iLO on the servers showed that the servers were still running, had not purple screened. Phew, now what? Quickly went to the VI Client and attempted to Cancel all the Storage VMotions currently in progress. One stopped successfully and the others did not change their state. Well one by one the servers came back after about 5 minutes.<br \/>\nSince I didn&#8217;t have the -RunASync switch I presumed that it would only do one at a time, as logically I did not intend to do all at once expressly because of the performance hit on the SAN back end. No, it didn&#8217;t work the way I was expecting it to go.<br \/>\nSo by having a look at the help about_runasync I found this snippet of information:<br \/>\nTo make sure that tasks initiated by a cmdlet do not run in parallel, run the cmdlet in a loop, each time applying it to a single object.<\/p>\n<p>Example 2: Removing Virtual Machines Consecutively.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nforeach ($vm in $vmList)\r\n{\r\nRemove-VM $vm1\r\n}\r\n<\/pre>\n<p>So by simply changing my last line to the following, each VM was Storage VMotioned one at a time.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$vmlist | % { Move-VM -Datastore $ds -VM $_ }\r\n<\/pre>\n<p>Mission accomplished, just beware.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I received a bunch of new LUNs for some VMs in a development environment. The task is to move all the VMs off the old LUNs to the new <a href=\"https:\/\/threemillion.net\/blog\/?p=212\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":""},"categories":[8,18],"tags":[36,35],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212"}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":6,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}