Pass through disks into ESXi VM

With Raw Device Mapping (RDM) it is possible to add a disk directly into a VM, without using the Datastore of VMware ESXi.

If you add a new VM in ESXi the storage for virtual disk is provided by a Datastore, which is an extra layer as a vmdk file on the real hard disk of your virtualization host.

But if you want to have real disk directly inside a VM for exclusive usage without a VMware layer in between, you could use Raw Device Mapping (RDM). This is also a good idea for backup or possible disaster recovery, because you can boot the host by a live system without ESXi and will have the real data on the disk.

RDMs can be added in physical or virtual compatibility mode. In virtual mode, the RDM device is able to behave like a virtual hard disk so that functions such as snapshots, cloning etc. can be used. While physical mode enables the guest operating system to directly access the hardware, but no function such as snapshots and cloning will work in this mode.

1. Activate SSH on ESXi VMware host

RDMs have to be created manually by terminal. First activate SSH and connect to the ESXi host.

2. Create RDM device in physical mode

The RDM devices will be stored inside an existing datastore. A new directory could be created for that. With vmkfstools -z /vmfs/devices/disks/<source> /vmfs/volumes/<destination> the real disks will be added as RDM devices in physical mode. A vmdk and mapping file is created on the datastore for each disk.

[root@localhost:~] ls -lah /vmfs/devices/disks/
[root@localhost:~] mkdir /vmfs/volumes/ssd/rdm
[root@localhost:~] vmkfstools -z /vmfs/devices/disks/t10.ATA_____ST4000DM0002D1F2168__________________________________Z3006NWW /vmfs/volumes/ssd/rdm/hdd-Z3006NWW.vmdk

3. Add physical devices to a VM

While creation of a new VM, go to “Add hard disk” and choose the vmdk file from the datastore.

4. Congratulations

Inside the VM you can list all block devices with the lsblk command. At this point you will do anything with the disks, like fdisk /dev/sdb to create a partition.

root@vm201:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 16G 0 disk
├─sda1 8:1 0 15G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 1022M 0 part [SWAP]
sdb 8:16 0 3,7T 0 disk
sdc 8:32 0 3,7T 0 disk
sdd 8:48 0 3,7T 0 disk
sde 8:64 0 3,7T 0 disk
sr0 11:0 1 335M 0 rom

Raw Device Mapping (RDM) Festplatte in VMware erstellen

Author: admirableadmin

Hello World! Ich bin Andreas Peichert und entwickle und programmiere Software seit 2000. Zurzeit arbeite ich als Senior Solution Architect.

Leave a Reply

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