{"id":830,"date":"2010-08-06T15:42:52","date_gmt":"2010-08-06T20:42:52","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=830"},"modified":"2019-09-04T19:57:39","modified_gmt":"2019-09-05T00:57:39","slug":"creating-rdm-to-lun-san-mapping-on-vmware-esx-4-vcenter","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=830","title":{"rendered":"Creating RDM to LUN (SAN) mapping on VMware ESX 4, Vcenter."},"content":{"rendered":"<p>In the past I have written articles about how to create a RDM to LUN disk mapping for <a href=\"http:\/\/www.gamescheat.ca\/2009\/10\/scripts-to-automate-the-process-of-identifying-and-compiling-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/\">VMware ESX 3<\/a>.<br \/>\n<a href=\"http:\/\/www.gamescheat.ca\/2009\/10\/scripts-to-automate-the-process-of-identifying-and-compiling-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/\">http:\/\/www.gamescheat.ca\/2009\/10\/scripts-to-automate-the-process-of-identifying-and-compiling-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/<\/a> and <a href=\"http:\/\/www.gamescheat.ca\/2009\/10\/how-to-identify-and-compile-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/\">http:\/\/www.gamescheat.ca\/2009\/10\/how-to-identify-and-compile-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/<\/a><\/p>\n<p>The procedure to identify the path for the RDM (raw disk mapping) to LUN (disk on SAN) on Vmware ESX 4 is different from Vmware Esx 3.  There are a few more steps in version 4.  I will explain below how to determine the path for RDM to LUN in ESX 4.<\/p>\n<p>Login to the console with root permission.<\/p>\n<blockquote><p># find \/vmfs\/volumes -name **-rdm**<br \/>\n\/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1-rdmp.vmdk<\/p><\/blockquote>\n<p>Find all RDM file in .vmfs\/volumes. Remove -rdmp from the result and that is the path you need for the next step.<\/p>\n<blockquote><p># vmkfstools -q \/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1.vmdk<br \/>\nDisk \/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1.vmdk is a Passthrough Raw Device Mapping<br \/>\nMaps to: vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<\/p><\/blockquote>\n<p>Use the vmkfstools -q command to find the vml id of the LUN, it is vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56.<\/p>\n<blockquote><p># esxcfg-scsidevs -u | grep vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<br \/>\nnaa.60060e80058c7b0000008c7b0000310b                            vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<\/p><\/blockquote>\n<p>Now use the esxcfg-scsidevs command to find the Network Addressing Authority identifier (naa) for the LUN.<\/p>\n<blockquote><p># esxcfg-mpath -l \u2013device=naa.60060e80058c7b0000008c7b0000310b<br \/>\nfc.2001001b3232c093:2101001b3232c093-fc.50060e80058c7b55:50060e80058c7b55-naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Runtime Name: vmhba2:C0:T0:L10<br \/>\n   Device: naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Device Display Name: HITACHI Fibre Channel Disk (naa.60060e80058c7b0000008c7b0000310b)<br \/>\n   Adapter: vmhba2 Channel: 0 Target: 0 LUN: 10<br \/>\n   Adapter Identifier: fc.3001001b3232c093:2101001b3232c093<br \/>\n   Target Identifier: fc.60060e80058c7b55:50060e80058c7b55<br \/>\n   Plugin: NMP<br \/>\n   State: active<br \/>\n   Transport: fc<br \/>\n   Adapter Transport Details: WWNN: 22:01:00:1b:32:32:c0:93 WWPN: 23:01:00:1b:32:32:c0:93<br \/>\n   Target Transport Details: WWNN: 55:06:0e:80:05:8c:7b:55 WWPN: 56:06:0e:80:05:8c:7b:55<\/p>\n<p>fc.2000001b3212c093:2100001b3212c093-fc.50060e80058c7b45:50060e80058c7b45-naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Runtime Name: vmhba1:C0:T0:L10<br \/>\n   Device: naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Device Display Name: HITACHI Fibre Channel Disk (naa.60060e80058c7b0000008c7b0000310b)<br \/>\n   Adapter: vmhba1 Channel: 0 Target: 0 LUN: 10<br \/>\n   Adapter Identifier: fc.3000001b3212c093:2100001b3212c093<br \/>\n   Target Identifier: fc.60060e80058c7b45:50060e80058c7b45<br \/>\n   Plugin: NMP<br \/>\n   State: active<br \/>\n   Transport: fc<br \/>\n   Adapter Transport Details: WWNN: 22:00:00:1b:32:12:c0:93 WWPN: 23:00:00:1b:32:12:c0:93<br \/>\n   Target Transport Details: WWNN: 55:06:0e:80:05:8c:7b:45 WWPN: 56:06:0e:80:05:8c:7b:45<\/p><\/blockquote>\n<p>The esxcfg-mpath -l command generates the detailed information for the LUN.  Because there are redundant path to the LUN on the SAN, the result is listed twice with different fiber channel HBA interfaces.<\/p>\n<p>Now what if your VMware ESX server is hosting many servers all with different RDMs.  It would be very tedious to manually compile a report for RDM to LUN mapping.  I create a script that will automatically do all the above steps and will output the result to screen or you can redirect the result to a file.  This will script will search for all the RDMs and create the mappings.  Below is the script and explanation of how it works.<\/p>\n<p><strong><\/p>\n<blockquote><p>#!\/bin\/bash<br \/>\n# Andrew Lin<br \/>\n# August 4, 2010<br \/>\n# Pay Andrew Lin lot\u2019s of money before you<br \/>\n# can use this script<\/p>\n<p>date<br \/>\nhostname<\/p>\n<p>find \/vmfs\/volumes -name **-rdm** | sed \u2018s\/-rdmp.vmdk\/.vmdk\/g\u2019 | sed \u2018s\/-rdm.vmdk\/.vmdk\/g\u2019 | sed \u2018s\/^\/vmkfstools -q \/g\u2019 >> andrew-disk-map |<br \/>\nchmod 645 andrew-disk-map<\/p>\n<p>file=andrew-disk-map<br \/>\nwhile read line<br \/>\ndo<br \/>\n $line<br \/>\n $line | grep vml | sed \u2018s\/.*to:\/esxcfg-scsidevs -u | grep\/g\u2019 > andrew_lin1<\/p>\n<p>     chmod 755 andrew_lin1<br \/>\n     .\/andrew_lin1 | sed \u2018s\/ .*\/\/g\u2019<br \/>\n     .\/andrew_lin1 | sed \u2018s\/ .*\/\/g\u2019 | sed \u2018s\/^\/esxcfg-mpath -L \u2013device=\/g\u2019 >andrew_lin2<br \/>\n     # rm andrew_lin1<\/p>\n<p>     chmod 755 andrew_lin2<br \/>\n     .\/andrew_lin2<br \/>\n     # rm andrew_lin2<\/p>\n<p> echo -e \u201c\\n\u201d<br \/>\ndone <$file<\/p><\/blockquote>\n<p><\/strong><\/p>\n<p>I will explain below what the above script does.<\/p>\n<blockquote><p>find \/vmfs\/volumes -name **-rdm**<br \/>\n\/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1-rdmp.vmdk<\/p><\/blockquote>\n<p>Search for all RDM (raw disk mapping), VMware1_1-rdmp.vmdk is found.<\/p>\n<blockquote><p>sed \u2018s\/-rdmp.vmdk\/.vmdk\/g\u2019<\/p><\/blockquote>\n<p>Change the characters -rdmp.vmdk to .vmdk. The s\/ means to substitute, and \/g means globally apply the changes for all matches. Some RDM have the -rdmp.vmdk extension (not shown in the above example).<\/p>\n<blockquote><div style=\"float: right;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 234;\ngoogle_ad_height = 60;\ngoogle_ad_format = \"234x60_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p>sed \u2018s\/-rdm.vmdk\/.vmdk\/g\u2019<\/p><\/blockquote>\n<p>Change -rdm.vmdk to .vmdk for all matches.<\/p>\n<blockquote><p>sed \u2018s\/^\/vmkfstools -q \/g\u2019<\/p><\/blockquote>\n<p>Add the command vmkfstools -q to the beginning of each line.<\/p>\n<blockquote><p>>> andrew-disk-map | chmod 645 andrew-disk-map<\/p><\/blockquote>\n<p>Redirect the output to the file andrew-disk-map.  Change the file permission to 645 to make it executable.<\/p>\n<p>Below is the result of the above command stored in andrew-disk-map.<\/p>\n<blockquote><p>vmkfstools -q \/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1.vmdk<\/p><\/blockquote>\n<blockquote><p>file=andrew-disk-map<\/p><\/blockquote>\n<p>Define the variable called file which contains the name of the file andrew-disk-map.<\/p>\n<blockquote><p>while read line<br \/>\ndo<br \/>\n ..<br \/>\n \u2026<br \/>\n \u2026.<br \/>\ndone <$file<\/p><\/blockquote>\n<p>The while loop will read the contents of the file defined in the variable $file (which is andrew-disk-map).  The file is read one line at a time and the commands defined within the while loop are executed for each line read.<\/p>\n<blockquote><p>$line<\/p><\/blockquote>\n<p>Execute the line read from the file andrew-disk-map and send the output to screen.<\/p>\n<blockquote><p><strong>Command<\/strong><br \/>\nvmkfstools -q \/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1.vmdk<br \/>\n<strong>Output<\/strong><br \/>\nDisk \/vmfs\/volumes\/4c20ca1e-d32d6ed6-96cb-001e4f3fdc36\/VMware1\/VMware1_1.vmdk is a Passthrough Raw Device Mapping<br \/>\nMaps to: vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<\/p><\/blockquote>\n<blockquote><p>$line | grep vml | sed \u2018s\/.*to:\/esxcfg-scsidevs -u | grep\/g\u2019 > andrew_lin1<\/p><\/blockquote>\n<p>Grep will find the line that contains the characters vml,  this is the unique LUN id.  Replace all characters before and upto the characters to: with esxcfg-scsidevs -u | grep.  The result will look like the below line which is redirected to the file andrew_lin1.<\/p>\n<blockquote><p>esxcfg-scsidevs -u | grep vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<\/p><\/blockquote>\n<blockquote><p>chmod 755 andrew_lin1<\/p><\/blockquote>\n<p>Chmod 755 will make the file andrew_lin1 executable.<\/p>\n<blockquote><p>.\/andrew_lin1 | sed \u2018s\/ .*\/\/g\u2019<\/p><\/blockquote>\n<p>Execute the file andrew_lin1.  Sed \u2018s\/ .*\/\/g\u2019 will delete everything after the first space found, otherwise the output will look like the below.<\/p>\n<blockquote><p><strong>Command executed (this is the content of the file andrew_lin1).<\/strong><br \/>\nesxcfg-scsidevs -u | grep vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<br \/>\n<strong>Output<\/strong><br \/>\nnaa.60060e80058c7b0000008c7b0000310b                            vml.02000a000060060e80058c7b0000008c7b0000310b4f50454e2d56<\/p><\/blockquote>\n<blockquote><p>.\/andrew_lin1 | sed \u2018s\/ .*\/\/g\u2019 | sed \u2018s\/^\/esxcfg-mpath -l \u2013device=\/g\u2019 >andrew_lin2<\/p><\/blockquote>\n<p>Execute the file andrew_lin1, from the result remove everything after the LUN ID number (naa.60060e80058c7b0000008c7b0000310b). Then add the command esxcfg-mpath -L \u2013device= in front of the LUN ID number, see below example.  The output is redirected to the file andrew_lin2.<br \/>\nesxcfg-mpath -l \u2013device=naa.60060e80058c7b0000008c7b0000310b<\/p>\n<blockquote><p># rm andrew_lin1<\/p><\/blockquote>\n<p>You are done with file andrew_lin1 and can delete it. If you want to save the file for troubleshooting then comment out the above line with the # sign.<\/p>\n<blockquote><p>chmod 755 andrew_lin2<\/p><\/blockquote>\n<p>Make the file andrew_lin2 executable.<\/p>\n<blockquote><p>.\/andrew_lin2<\/p><\/blockquote>\n<p>Execute andrew_lin2.  Which contains the command esxcfg-mpath -l \u2013device=naa.60060e80058c7b0000008c7b0000310b.  The output below is displayed on screen.  Notice that there are redundant paths to the LUN on the SAN.<\/p>\n<blockquote><p>fc.2001001b3232c093:2101001b3232c093-fc.50060e80058c7b55:50060e80058c7b55-naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Runtime Name: vmhba2:C0:T0:L10<br \/>\n   Device: naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Device Display Name: HITACHI Fibre Channel Disk (naa.60060e80058c7b0000008c7b0000310b)<br \/>\n   Adapter: vmhba2 Channel: 0 Target: 0 LUN: 10<br \/>\n   Adapter Identifier: fc.3001001b3232c093:2101001b3232c093<br \/>\n   Target Identifier: fc.60060e80058c7b55:50060e80058c7b55<br \/>\n   Plugin: NMP<br \/>\n   State: active<br \/>\n   Transport: fc<br \/>\n   Adapter Transport Details: WWNN: 22:01:00:1b:32:32:c0:93 WWPN: 23:01:00:1b:32:32:c0:93<br \/>\n   Target Transport Details: WWNN: 55:06:0e:80:05:8c:7b:55 WWPN: 56:06:0e:80:05:8c:7b:55<\/p>\n<p>fc.2000001b3212c093:2100001b3212c093-fc.50060e80058c7b45:50060e80058c7b45-naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Runtime Name: vmhba1:C0:T0:L10<br \/>\n   Device: naa.60060e80058c7b0000008c7b0000310b<br \/>\n   Device Display Name: HITACHI Fibre Channel Disk (naa.60060e80058c7b0000008c7b0000310b)<br \/>\n   Adapter: vmhba1 Channel: 0 Target: 0 LUN: 10<br \/>\n   Adapter Identifier: fc.3000001b3212c093:2100001b3212c093<br \/>\n   Target Identifier: fc.60060e80058c7b45:50060e80058c7b45<br \/>\n   Plugin: NMP<br \/>\n   State: active<br \/>\n   Transport: fc<br \/>\n   Adapter Transport Details: WWNN: 22:00:00:1b:32:12:c0:93 WWPN: 23:00:00:1b:32:12:c0:93<br \/>\n   Target Transport Details: WWNN: 55:06:0e:80:05:8c:7b:45 WWPN: 56:06:0e:80:05:8c:7b:45<\/p><\/blockquote>\n<blockquote><p># rm andrew_lin2<\/p><\/blockquote>\n<p>Delete the file andrew_lin2 by removing the # comment.<\/p>\n<blockquote><p>echo -e \u201c\\n\u201d<\/p><\/blockquote>\n<p>Enter a line space.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past I have written articles about how to create a RDM to LUN disk mapping for VMware ESX 3. http:\/\/www.gamescheat.ca\/2009\/10\/scripts-to-automate-the-process-of-identifying-and-compiling-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/ and http:\/\/www.gamescheat.ca\/2009\/10\/how-to-identify-and-compile-an-rdm-to-lun-mapping-list-for-vmware-esx-30\/ The procedure to identify the path for the RDM (raw disk mapping) to LUN (disk on&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=830\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[65,19],"tags":[55,35,61],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/830"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=830"}],"version-history":[{"count":6,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/830\/revisions"}],"predecessor-version":[{"id":965,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/830\/revisions\/965"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=830"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}