[Quick script] – Automatically scan for unmounted VMFS datastores and mount them

Share on:

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.

I wrote a quick script to do this because I am lazy, and decided to share it here in case it may be useful:

3esxcfg-volume -l > /tmp/dump.log
4cat /tmp/dump.log  | grep UUID | awk -F ':' '{print $2}' | awk -F '/' '{print $1}' > /tmp/dump2.log
6while read line; do esxcfg-volume -M $line; done</tmp/dump2.log
8rm /tmp/dump.log
9rm /tmp/dump2.log</code></pre>

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.

You can also find it here, and pull requests are welcome!