Search
StarWind is a hyperconverged (HCI) vendor with focus on Enterprise ROBO, SMB & Edge

How to Create VMware vSphere VMs with RDM Disks

  • December 23, 2024
  • 23 min read
Vitalii is a Post-Sales Support Engineer at StarWind about 2 years. Has a broad knowledge of storage, virtualization, backup, and infrastructure implementation. Ping pong as a hobby.
Vitalii is a Post-Sales Support Engineer at StarWind about 2 years. Has a broad knowledge of storage, virtualization, backup, and infrastructure implementation. Ping pong as a hobby.

One powerful technique for connecting virtual machines to physical storage is using Raw Device Mapping (RDM). This article will guide you through the process of creating VMware vSphere VMs with RDM disks, providing a comprehensive understanding of RDM, its benefits, and how to implement it effectively. We’ll explore everything from the basics of RDM to advanced techniques, ensuring you have the knowledge to make informed decisions about your storage infrastructure.

Introduction to VMware RDM

Let’s start with the fundamentals. What exactly is RDM, and why should you consider using it in your vSphere environment? Understanding these basics is crucial before diving into the technical details.

What is Raw Device Mapping (RDM)?

Raw Device Mapping (RDM) is a feature in VMware vSphere that allows a virtual machine (VM) to directly access a Logical Unit Number (LUN) on a storage system. Think of it as a bridge between your VM and the physical storage, enabling the VM to bypass the VMFS (Virtual Machine File System) layer for certain operations. Instead of storing data within a VMDK file on a VMFS volume, the VM interacts directly with the LUN, offering certain performance and management advantages.

There are two compatibility modes for RDM: Virtual Compatibility Mode (also known as Virtual RDM) and Physical Compatibility Mode (also known as Physical RDM). In Virtual Compatibility Mode, the VM sees the RDM disk as a virtual disk, and VMFS metadata is still used for certain operations like snapshots. In Physical Compatibility Mode, the VM has almost direct access to the LUN, with minimal VMFS intervention. This mode is suitable for applications that require direct SCSI commands.

Why Use RDM?

So, why would you choose RDM over traditional VMDK files? There are several compelling reasons:

  • Performance: For applications that are I/O intensive, RDM can provide better performance because the VM can directly access the storage without the overhead of the VMFS layer. This is especially beneficial for databases and other applications that require low latency.
  • SAN Management: RDM allows you to leverage the features of your Storage Area Network (SAN) directly from the VM. This includes features like hardware snapshots, replication, and other advanced storage functionalities. You can manage the storage using the SAN’s native tools, which can simplify administration.
  • Compatibility: Some applications require direct access to the physical storage for compliance or functionality reasons. RDM provides this direct access while still allowing the VM to be managed by vSphere.
  • VMFS Limitations: While VMFS is a robust file system, it can have limitations in terms of file size and the number of files it can support. RDM bypasses these limitations by allowing the VM to directly access the LUN.

For example, consider a large database server. By using RDM, you can take advantage of the SAN’s snapshot capabilities for backup and recovery, which can be faster and more efficient than using software-based snapshots. Similarly, if you have an application that requires direct SCSI commands, Physical Compatibility Mode RDM is the way to go.

Understanding RDM Disks and LUN Presentation

Now that you understand what RDM is and why it’s useful, let’s dive deeper into how it works and how LUNs are presented to vSphere hosts.

How RDM Works

At its core, RDM works by creating a mapping file on a VMFS volume that points to the physical LUN. This mapping file contains metadata about the LUN, such as its device ID and size. When the VM accesses the RDM disk, vSphere redirects the I/O operations directly to the LUN, bypassing the VMFS file system for data access. The compatibility mode determines how much of the VMFS layer is involved.

In Virtual Compatibility Mode, the VMkernel still handles certain operations, such as locking and snapshots. This mode provides better portability and compatibility with vSphere features. In Physical Compatibility Mode, the VM has almost complete control over the LUN, allowing it to send native SCSI commands. However, this mode has limitations in terms of vSphere features like snapshots and vMotion.

LUN Presentation to vSphere

Before you can create an RDM, you need to present the LUN to your vSphere host. This involves configuring your SAN to allow the ESXi host to access the LUN. Here’s a general overview of the process:

  1. LUN Creation: Use your SAN’s management interface to create a new LUN. Make sure to allocate sufficient space for your application’s needs.
  2. Host Group Configuration: Create a host group on your SAN that includes the ESXi hosts that will access the LUN. This ensures that only authorized hosts can access the storage.
  3. LUN Mapping: Map the LUN to the host group. This step makes the LUN visible to the ESXi hosts.
  4. Storage Rescan: In the vSphere Client, navigate to the ESXi host and perform a storage rescan. This will detect the new LUN.

Once the LUN is presented to the ESXi host, you can create an RDM mapping to it. Remember to consider the compatibility mode when creating the RDM. Virtual Compatibility Mode is generally recommended for most use cases, as it provides better compatibility with vSphere features. Physical Compatibility Mode should only be used when the application requires direct SCSI access.

For example, if you’re using StarWind Virtual SAN Controller Virtual Machine (CVM), and if your HBA card cannot be passed through, then physical disks can be added to StarWind VSAN CVM via RDM.

Steps to Create RDM Disks for vSphere VMs

Now, let’s get practical and walk through the steps to create RDM disks for your vSphere VMs. The steps below describe a common use case when you need to RDM LUNs served by your SAN (or a virtual SAN).

Creating the LUN

The first step is to create the LUN on your SAN. This process will vary depending on your SAN vendor:

  1. Access SAN Management Interface: Log in to your SAN management interface.
  2. Create New LUN: Navigate to the LUN management section and create a new LUN. Specify the size and other parameters of the LUN based on your application’s requirements.
  3. Configure Host Access: Create a host group that includes the ESXi hosts that will access the LUN. Add the ESXi hosts to the host group using their iSCSI IQNs or WWPNs.
  4. Map LUN to Host Group: Map the newly created LUN to the host group. This makes the LUN visible to the ESXi hosts.
  5. Verify LUN Presentation: Ensure that the LUN is properly presented to the ESXi hosts. You can use the SAN’s management interface to verify this.

For instance, if you’re using StarWind Virtual SAN, you would use the StarWind Web Management Console to create and configure the LUN, and the necessary iSCSI/NVMe-oF targets.

Adding RDM to a VM

Once the LUN is presented to the ESXi host, you can add it to a VM as an RDM disk. Here are the steps:

  1. Edit VM Settings: In the vSphere Client, right-click the VM and select “Edit Settings.”
  2. Add New Device: Click “Add New Device” and select “RDM Disk.”
  3. Select LUN: Choose the LUN that you want to use for the RDM. The LUN should be visible in the list if it has been properly presented to the ESXi host.
  4. Choose Compatibility Mode: Select the compatibility mode for the RDM. As mentioned earlier, Virtual Compatibility Mode is generally recommended unless you have a specific need for Physical Compatibility Mode.
  5. Specify Datastore: Choose a datastore to store the RDM mapping file. This file is small and only contains metadata about the LUN.
  6. Save Settings: Click “OK” to save the settings. The RDM disk will now be added to the VM.

After adding the RDM disk, you may need to format the disk within the VM’s operating system. This will make the disk usable by the applications running in the VM. For example, if you’re using Windows, you would use Disk Management to format the disk. If you’re using Linux, you would use a tool like fdisk or parted to partition and format the disk.

Advantages and Limitations of RDM

Like any technology, RDM has its advantages and limitations. Understanding these pros and cons will help you determine whether RDM is the right choice for your specific needs.

Advantages of RDM

Here are some of the key advantages of using RDM:

  • Performance: As mentioned earlier, RDM can provide better performance for I/O intensive applications by allowing the VM to directly access the storage.
  • SAN Features: RDM allows you to leverage the advanced features of your SAN, such as hardware snapshots, replication, and thin provisioning.
  • Compatibility: RDM ensures compatibility with applications that require direct access to physical storage.
  • Storage Management: RDM simplifies storage management by allowing you to use the SAN’s native tools to manage the storage.

For instance, if you’re using a storage array that supports thin provisioning, you can use RDM to take advantage of this feature. Thin provisioning allows you to allocate more storage than is physically available, which can save you money and improve storage utilization. Similarly, if you’re using hardware snapshots, you can use RDM to create snapshots of the LUN directly from the SAN, which can be faster and more efficient than using software-based snapshots.

Limitations of Using RDM

Despite its advantages, RDM also has some limitations:

  • Complexity: Setting up and managing RDM can be more complex than using traditional VMDK files. You need to have a good understanding of both vSphere and your SAN’s management tools.
  • Portability: VMs with RDM disks can be less portable than VMs with VMDK files. Moving a VM with an RDM disk to a different vSphere environment can be challenging, especially if the target environment does not have access to the same LUN.
  • Compatibility Mode Restrictions: Physical Compatibility Mode has limitations in terms of vSphere features like snapshots and vMotion.
  • Dependency on SAN: RDM creates a dependency on the SAN. If the SAN is unavailable, the VM will not be able to access its storage.

For example, if you’re planning to migrate a VM with an RDM disk to a different vSphere environment, you need to ensure that the target environment has access to the same LUN. This may involve reconfiguring the SAN and updating the RDM mapping file. Similarly, if you’re using Physical Compatibility Mode, you need to be aware of the limitations in terms of vSphere features like snapshots and vMotion.

Understanding RDM Files

As mentioned earlier, RDM uses a mapping file that contains metadata about the LUN. This file is stored on a VMFS volume and is used by vSphere to redirect I/O operations to the LUN. Understanding the contents of this file can be helpful for troubleshooting RDM issues.

The RDM mapping file is a small text file that contains information such as the LUN’s device ID, size, and compatibility mode. You can view the contents of this file using a text editor. However, you should not manually modify this file, as this can cause issues with the RDM.

For example, if you’re having trouble with an RDM disk, you can check the RDM mapping file to ensure that it contains the correct information about the LUN. If the information is incorrect, you may need to recreate the RDM.

Conclusion

In conclusion, Raw Device Mapping (RDM) is a powerful technique for connecting virtual machines to physical storage in VMware vSphere. It offers performance benefits, allows you to leverage SAN features, and ensures compatibility with applications that require direct access to storage. However, it also has limitations in terms of complexity, portability, and dependency on the SAN. By understanding the advantages and limitations of RDM, you can make informed decisions about whether it’s the right choice for your specific needs. We have explored the creation process, the advantages and disadvantages, and some advanced techniques to improve the RDM disks management. Remember to always consider your application’s requirements and your infrastructure’s capabilities when deciding whether to use RDM. Further exploration of VMware technologies and continuous learning will help you optimize your virtual environment and achieve your business goals.

Frequently Asked Questions

Here are some frequently asked questions about RDM to help clarify any remaining doubts.

Q: When should I use RDM instead of VMDK?

A: Use RDM when you need better performance for I/O intensive applications, when you want to leverage SAN features, or when you need compatibility with applications that require direct access to storage.

Q: What is the difference between Virtual Compatibility Mode and Physical Compatibility Mode?

A: In Virtual Compatibility Mode, the VM sees the RDM disk as a virtual disk, and VMFS metadata is still used for certain operations. In Physical Compatibility Mode, the VM has almost direct access to the LUN, with minimal VMFS intervention.

Q: Can I use snapshots with RDM disks?

A: Yes, you can use snapshots with RDM disks, but the behavior depends on the compatibility mode. Virtual Compatibility Mode supports vSphere snapshots, while Physical Compatibility Mode has limitations.

Q: How do I troubleshoot RDM issues?

A: Start by checking the RDM mapping file to ensure that it contains the correct information about the LUN. Also, verify that the LUN is properly presented to the ESXi host and that the VM has the necessary permissions to access the LUN.

Q: Is RDM supported on all storage arrays?

A: RDM is supported on most storage arrays, but you should check the documentation for your specific storage array to ensure compatibility.

By addressing these common questions, you can gain a deeper understanding of RDM and its practical applications. Remember to always consult the official VMware documentation for the most up-to-date information and best practices.

Hey! Found Vitalii’s insights useful? Looking for a cost-effective, high-performance, and easy-to-use hyperconverged platform?
Taras Shved
Taras Shved StarWind HCI Appliance Product Manager
Look no further! StarWind HCI Appliance (HCA) is a plug-and-play solution that combines compute, storage, networking, and virtualization software into a single easy-to-use hyperconverged platform. It's designed to significantly trim your IT costs and save valuable time. Interested in learning more? Book your StarWind HCA demo now to see it in action!