My VMware blog

To help others as others have helped me

Quick Tip: How to create an RDM mapping file via the CLI

Before we begin

Before we can create an RDM mapping file using the CLI we need to locate the following information

  • The VML of the device
  • The file location of the Virtual Machine

The tools we will use to find this are

  • An SSH terminal
  • Vmkfstools
  • esxicli

Obtain the VML details

  1. Do not map the LUN to the host just yet
  2. Connect to the ESXi host via an SSH session
  3. Run the following command
    ls /vmfs/devices/disks
  4. The output will display all LUNS and disks available to the host
  5. Map the LUN to the host (This stage is done on your storage system)
  6. Run the following command to rescan for storage
    esxcli storage core adapter rescan –all
  7. Re-run the following command
    ls /vmfs/devices/disks
  8. The output will display all LUNS and disks available to the host which now includes one that was not there before

Locate the Existing VM storage location

  1. The next step is to locate the virtual machine directory to do this type the following command
    ls /vmfs/volumes
  2. This command will display the available volumes to the host
  3. You will now need to browse them to find the VM you wish to add the RDM too
  4. In my case the VM is located at /vmfs/volumes/FreeNAS-iSCSI/DSL2

Create the virtual RDM mapping file

  1. Now that we have all the information we need we can now add a Virtual RDM
  2. To add the virtual RDM use the following command replacing the vml and the VM directory with the one identified early
    vmkfstools -r /vmfs/devices/disks/vml.020001000030000000d6f5b656695343534920 /vmfs/volumes/FreeNAS-iSCSI/DSL2/rdm1.vmdk

Alternatively Create the Physical RDM mapping file

  1. Now that we have all the information we need we can now add a Physical RDM
  2. To add the physical RDM use the following command replacing the vml and the VM directory with the one identified early
    vmkfstools -z /vmfs/devices/disks/vml.020001000030000000d6f5b656695343534920 /vmfs/volumes/FreeNAS-iSCSI/DSL2/rdm1.vmdk

Add the RDM to the VM

  1. In the VMware Client right click on the VM and go to Edit
  2. Click Add, Select Hard Disk and Click Next
  3. Select Use existing disk and Click Next
  4. Browse and locate the VMDK that you created at the command line
  5. Once located click ok and then Next
  6. Click Next and then Click Finish.
  7. The RDM is not attached to the VM

If you spot any errors or get stuck somewhere please leave a comment and I will try to assist.

Jeremy

, , ,

4 thoughts on “Quick Tip: How to create an RDM mapping file via the CLI

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>