{"id":806,"date":"2015-02-05T12:30:52","date_gmt":"2015-02-05T11:30:52","guid":{"rendered":"http:\/\/vthink.fr\/2015\/02\/script-extension-de-datastores-en-ligne-de-commandes-2\/"},"modified":"2015-02-19T17:48:13","modified_gmt":"2015-02-19T16:48:13","slug":"script-grow-vmfs-datastores-in-command-line","status":"publish","type":"post","link":"https:\/\/vthink.fr\/en\/2015\/02\/script-grow-vmfs-datastores-in-command-line\/","title":{"rendered":"Script &#8211; Grow VMFS datastores in command line"},"content":{"rendered":"\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"e93ad9a1ff002511692efbd236903a83\" data-index=\"1\" style=\"float: left; margin: 10px 10px 10px 0;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- ads1 -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:inline-block;width:300px;height:250px\"\r\n     data-ad-client=\"ca-pub-9785518987307332\"\r\n     data-ad-slot=\"8809267401\"><\/ins>\r\n<script>\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<p><span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"hps\">Recently, i have worked on a script to automate these operations because it involved a lot of datastores. The script only works if the LUN hosting the datastore has previously been expanded.<\/span><\/span><\/p>\n<p>For more information regarding the command line describe in this article you can check this\u00a0 <a title=\"2002461\" href=\"http:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=2002461&amp;src=vmw_so_vex_jvare_772\" target=\"_blank\">2002461<\/a>.<\/p>\n<hr \/>\n<p><strong><span style=\"color: #ff0000;\">Update :02\/06\/2015 &#8211; Add Powershell + plink<\/span><\/strong><\/p>\n<p>In my powershell script i used a script from\u00a0<a href=\"%20http:\/\/virtu-al.net\"> virtu-al.net<\/a> @Alan Renouf that will generate a choice box (Cluster,ESX,Datastore)<\/p>\n<p>So in this script, you will be able to choice in which cluster and esx the script will be launched.<\/p>\n<p>The script has been tested in ESXi 5.0 U2 but should work with 5.x.<\/p>\n<p><span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"hps\">Unzip<\/span> <span class=\"hps\">the file<\/span> <span class=\"hps\">and run<\/span> <span class=\"hps\">the script<\/span> <span class=\"hps\">DatastoreExtend.ps1<\/span><\/span><\/p>\n<p>&#8211; 1 : Enter the vCenter Name<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-647\" src=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/11.png?resize=520%2C51&#038;ssl=1\" alt=\"Extend-1\" width=\"520\" height=\"51\" srcset=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/11.png?w=520&amp;ssl=1 520w, https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/11.png?resize=300%2C29&amp;ssl=1 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" data-recalc-dims=\"1\" \/><\/p>\n<p>&#8211; 2 : Provide the vCenter credentials<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-648\" src=\"https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/21.png?resize=330%2C251&#038;ssl=1\" alt=\"Extend-2\" width=\"330\" height=\"251\" srcset=\"https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/21.png?w=330&amp;ssl=1 330w, https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/21.png?resize=300%2C228&amp;ssl=1 300w\" sizes=\"(max-width: 330px) 100vw, 330px\" data-recalc-dims=\"1\" \/><\/p>\n<p>&#8211; 3 : Then provide the root password of your ESXi.<img loading=\"lazy\" class=\"aligncenter size-full wp-image-649\" src=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/31.png?resize=662%2C66&#038;ssl=1\" alt=\"Extend-3\" width=\"662\" height=\"66\" srcset=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/31.png?w=662&amp;ssl=1 662w, https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/31.png?resize=300%2C30&amp;ssl=1 300w\" sizes=\"(max-width: 662px) 100vw, 662px\" data-recalc-dims=\"1\" \/>&#8211; 4 : Select your cluster<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter  wp-image-650\" src=\"https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/41.png?resize=518%2C256&#038;ssl=1\" alt=\"Extend-4\" width=\"518\" height=\"256\" srcset=\"https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/41.png?w=664&amp;ssl=1 664w, https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/41.png?resize=300%2C148&amp;ssl=1 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" data-recalc-dims=\"1\" \/><\/p>\n<p>&#8211; 5 : Select your host<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter  wp-image-651\" src=\"https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/51.png?resize=553%2C202&#038;ssl=1\" alt=\"Extend-5\" width=\"553\" height=\"202\" srcset=\"https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/51.png?w=668&amp;ssl=1 668w, https:\/\/i1.wp.com\/vthink.fr\/wp-content\/uploads\/51.png?resize=300%2C110&amp;ssl=1 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" data-recalc-dims=\"1\" \/><\/p>\n<p>&#8211; 6 : Select your dastatore. The script files will be uploaded on it.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter  wp-image-652\" src=\"https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/61.png?resize=589%2C287&#038;ssl=1\" alt=\"Extend-6\" width=\"589\" height=\"287\" srcset=\"https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/61.png?w=665&amp;ssl=1 665w, https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/61.png?resize=300%2C146&amp;ssl=1 300w\" sizes=\"(max-width: 589px) 100vw, 589px\" data-recalc-dims=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-624\" src=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?resize=489%2C292&#038;ssl=1\" alt=\"Capture\" width=\"489\" height=\"292\" srcset=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?w=489&amp;ssl=1 489w, https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?resize=300%2C179&amp;ssl=1 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"hps\">Once the<\/span> <span class=\"hps\">script is done, you<\/span> <span class=\"hps\">can choose<\/span> <span class=\"hps\">to restart<\/span> <span class=\"hps\">it on another<\/span> <span class=\"hps\">cluster.<\/span><\/span><\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-654\" src=\"https:\/\/i2.wp.com\/vthink.fr\/wp-content\/uploads\/8.png?resize=223%2C123&#038;ssl=1\" alt=\"Extend-8\" width=\"223\" height=\"123\" data-recalc-dims=\"1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"hps\">This is the content<\/span> <span class=\"hps\">of<\/span> &#8220;<span class=\"hps\">resize.sh&#8221;<\/span> <span class=\"hps\">script that will generate<\/span> <span class=\"hps\">a list of<\/span> <span class=\"hps\">datastores<\/span><span class=\"hps\">.<\/span> <span class=\"hps\">The script will check only vmfs datastore.<\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"color: #999999;\">\u00a0<\/span><\/p>\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"e93ad9a1ff002511692efbd236903a83\" data-index=\"1\" style=\"float: left; margin: 10px 10px 10px 0;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- ads1 -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:inline-block;width:300px;height:250px\"\r\n     data-ad-client=\"ca-pub-9785518987307332\"\r\n     data-ad-slot=\"8809267401\"><\/ins>\r\n<script>\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n\n<p><span style=\"color: #999999;\">#!\/bin\/sh<\/span><br \/>\n<span style=\"color: #999999;\"> # Julien VARELA<\/span> <span style=\"color: #999999;\">Script\u00a0 <\/span><br \/>\n<span style=\"color: #999999;\"> # Release v1.0 02\/03\/2015<\/span><br \/>\n<span style=\"color: #999999;\"> #Grow VMFS Datastore<br \/>\n<\/span><\/p>\n<p><span style=\"color: #999999;\">#Export Datastore List<\/span><br \/>\n<span style=\"color: #999999;\"> esxcli storage filesystem list &gt; \/tmp\/vmfs.txt<\/span><br \/>\n<span style=\"color: #999999;\"> cat \/tmp\/vmfs.txt | grep &#8220;VMFS&#8221; | awk &#8216;{print $2}&#8217; &gt; \/tmp\/datastorelist.txt # <strong>C<\/strong><br \/>\n<\/span><br \/>\n<span style=\"color: #999999;\"> while read i; do \/tmp\/traitement.sh $i;done &lt;\u00a0 \/tmp\/datastorelist.txt<\/span><\/p>\n<p><span style=\"color: #999999;\">#Remove temporary files<\/span><br \/>\n<span style=\"color: #999999;\"> rm -rf \/tmp\/vmfs.txt<\/span><br \/>\n<span style=\"color: #999999;\"> rm -rf \/tmp\/datastorelist.txt<\/span><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>Content of\u00a0 traitement.sh script.<\/p>\n<p><span style=\"color: #999999;\">#!\/bin\/sh<\/span><br \/>\n<span style=\"color: #999999;\"># Julien VARELA <\/span><span style=\"color: #999999;\">Script <\/span><br \/>\n<span style=\"color: #999999;\"># Release v1.0 02\/03\/2015<\/span><br \/>\n<span style=\"color: #999999;\">#Grow VMFS Datastores<\/span><\/p>\n<p><span style=\"color: #999999;\"># Retrieve naa.<\/span><br \/>\n<span style=\"color: #999999;\">parted=$(vmkfstools -P \/vmfs\/volumes\/$1 | grep &#8220;naa.&#8221; | sed &#8216;s\/..$\/\/&#8217;)<\/span><br \/>\n<span style=\"color: #999999;\">naa=$(echo $parted\u00a0 | sed &#8216;s\/ \/\/g&#8217;)<\/span><\/p>\n<p><span style=\"color: #999999;\">#Retrieve last sector available<\/span><br \/>\n<span style=\"color: #999999;\">endsecavailable=$(partedUtil getUsableSectors \/vmfs\/devices\/disks\/$naa | awk &#8216;{print $2}&#8217;)<\/span><\/p>\n<p><span style=\"color: #999999;\">#Retrieve current last sector<\/span><br \/>\n<span style=\"color: #999999;\">endsecactive=$(partedUtil get \/vmfs\/devices\/disks\/$naa | sed &#8216;1d&#8217; |awk &#8216;{print $3}&#8217;)<\/span><\/p>\n<p><span style=\"color: #999999;\">#Retrieve partition number<\/span><br \/>\n<span style=\"color: #999999;\">numpartition=$(partedUtil get \/vmfs\/devices\/disks\/$naa | sed &#8216;1d&#8217; |awk &#8216;{print $1}&#8217;)<\/span><\/p>\n<p><span style=\"color: #999999;\">#Retrieve first sector<\/span><br \/>\n<span style=\"color: #999999;\">firstsector=$(partedUtil get \/vmfs\/devices\/disks\/$naa | sed &#8216;1d&#8217; |awk &#8216;{print $2}&#8217;)<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Nom du datastore a traiter : &#8221; $1<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Identifiant du lun : &#8221; $naa<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Premier secteur : &#8221; $firstsector<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Dernier secteur en place : &#8221; $endsecactive<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Dernier secteur disponible : &#8220;$endsecavailable #| awk &#8216;{print $2}&#8217;<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Numero de la partion : &#8221; $numpartition<\/span><\/p>\n<p><span style=\"color: #999999;\">if [ $endsecactive = $endsecavailable ]<\/span><br \/>\n<span style=\"color: #999999;\">then<\/span><br \/>\n<span style=\"color: #999999;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;Le datastore est deja etendu&#8221;<\/span><br \/>\n<span style=\"color: #999999;\">else<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;VMFS Resize&#8221;<\/span><br \/>\n<span style=\"color: #999999;\">partedUtil resize \/vmfs\/devices\/disks\/$naa $numpartition $firstsector $endsecavailable<\/span><\/p>\n<p><span style=\"color: #999999;\">echo &#8220;Rescan&#8221;<\/span><br \/>\n<span style=\"color: #999999;\">vmkfstools -V<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;growfs&#8221;<\/span><br \/>\n<span style=\"color: #999999;\">vmkfstools &#8211;growfs \/vmfs\/devices\/disks\/$naa:$numpartition \/vmfs\/devices\/disks\/$naa:$numpartition<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Rescan&#8221;<\/span><br \/>\n<span style=\"color: #999999;\">vmkfstools -V<\/span><br \/>\n<span style=\"color: #999999;\">echo &#8220;Grow VMFS Datastore ended on : &#8221; $1<\/span><br \/>\n<span style=\"color: #999999;\">fi<\/span><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Will not be processed, datastore that were already expanded<\/span><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-624\" src=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?resize=489%2C292&#038;ssl=1\" alt=\"Capture\" width=\"489\" height=\"292\" srcset=\"https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?w=489&amp;ssl=1 489w, https:\/\/i0.wp.com\/vthink.fr\/wp-content\/uploads\/Capture.png?resize=300%2C179&amp;ssl=1 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" data-recalc-dims=\"1\" \/><\/p>\n<p>You can download the zip file here : <a href=\"https:\/\/vthink.fr\/wp-content\/uploads\/ExtendDatastore.zip\">ExtendDatastore<\/a><\/p>\n<p><span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"hps\">Unzip<\/span> <span class=\"hps\">the file<\/span> <span class=\"hps\">and run<\/span> <span class=\"hps\">the script<\/span> <span class=\"hps\">DatastoreExtend.ps1<\/span><\/span> \ud83d\ude09 have fun<\/p>\n<p>&nbsp;<\/p>\n<p>The script will be translate in few days.<\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Recently, i have worked on a script to automate these operations because it involved a lot of datastores. The script only works if the LUN hosting the datastore has previously been expanded. For more information regarding the command line describe in this article you can check this\u00a0 2002461. Update :02\/06\/2015 &#8211; Add Powershell + plink&hellip;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":2,"featured_media":717,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1132,1088],"tags":[1133,1153,1037,1096,1160,1134,1171,1135,1131,1643,1099,1137,1155,1154,1138,1139,1140,1141,1161,1142,1151,1150,1157,1152,1043,1143,1144,1102,1145,1146,1147,1058,1156,1059,1148,1067,1158,1159,1069,1073,1149,1076,1121],"_links":{"self":[{"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/posts\/806"}],"collection":[{"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/comments?post=806"}],"version-history":[{"count":11,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":832,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/posts\/806\/revisions\/832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/media\/717"}],"wp:attachment":[{"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/media?parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/categories?post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vthink.fr\/en\/wp-json\/wp\/v2\/tags?post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}