<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Quick-Script on MichelleWayZ | Michelle Goossens | Blog</title><link>https://blog.michellewayz.com/categories/quick-script/</link><description>Recent content in Quick-Script on MichelleWayZ | Michelle Goossens | Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>Copyright © 2019-2026, Michelle Goossens.</copyright><lastBuildDate>Sat, 24 Dec 2022 00:47:48 +0000</lastBuildDate><atom:link href="https://blog.michellewayz.com/categories/quick-script/index.xml" rel="self" type="application/rss+xml"/><item><title>[Quick script] – Automatically scan for unmounted VMFS datastores and mount them</title><link>https://blog.michellewayz.com/quick-script-automatically-scan-for-unmounted-vmfs-datastores-and-mount-them/</link><pubDate>Sat, 24 Dec 2022 00:47:48 +0000</pubDate><guid>https://blog.michellewayz.com/quick-script-automatically-scan-for-unmounted-vmfs-datastores-and-mount-them/</guid><description>
&lt;p&gt;Today while I installed two new servers in the rack, I had to mount some iSCSI datastores to these servers as I also have them mounted on other servers.&lt;/p&gt;
&lt;p&gt;I wrote a quick script to do this because I am lazy, and decided to share it here in case it may be useful:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;esxcfg-volume -l &amp;gt; /tmp/dump.log
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;cat /tmp/dump.log &lt;span class="p"&gt;|&lt;/span&gt; grep UUID &lt;span class="p"&gt;|&lt;/span&gt; awk -F &lt;span class="s1"&gt;&amp;#39;:&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;{print $2}&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; awk -F &lt;span class="s1"&gt;&amp;#39;/&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;{print $1}&amp;#39;&lt;/span&gt; &amp;gt; /tmp/dump2.log
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;5&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;6&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; line&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; esxcfg-volume -M &lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;lt&lt;span class="p"&gt;;&lt;/span&gt;/tmp/dump2.log
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;7&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;8&lt;/span&gt;&lt;span class="cl"&gt;rm /tmp/dump.log
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;9&lt;/span&gt;&lt;span class="cl"&gt;rm /tmp/dump2.log&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Pretty much what it does is it scans for unmounted VMFS datastores and puts that into a file (line 3). Then on line 4 I have a filter to just take the UUID and put that into another file. On line 6 we take those UUIDs and mount them persistently. Line 8 and 9 are cleaning up.&lt;/p&gt;</description></item></channel></rss>