So I’ve added a disk of one of my Linux machines to my ESXi host, created a new VM and wanted to add the physical disk to the VM as a raw device. (As a means of quick and dirty P2V.) However I found out that the “New raw disk” option is greyed out in my (stand alone) ESXi, so there is no way to add the physical disk to the VM.
Well, there is an option, using the CLI.
Enable SSH on your host, login and first find the device you added. In my case a Seagate device, so easily recognizable:
[root@localhost:~] ls /dev/disks/
t10.ATA_____KINGSTON_SA400M8120G_..._
t10.ATA_____KINGSTON_SA400M8120G_..._:1
t10.ATA_____KINGSTON_SA400M8120G_..._:5
t10.ATA_____KINGSTON_SA400M8120G_..._:6
t10.ATA_____KINGSTON_SA400M8120G_..._:7
t10.ATA_____KINGSTON_SA400M8120G_..._:8
t10.ATA_____ST8000DM0042D2CX188_...
t10.ATA_____ST8000DM0042D2CX188_...:1
t10.ATA_____ST8000DM0042D2CX188_...:2
t10.ATA_____ST8000DM0042D2CX188_...:3
vml.0100000000...
...
As you can see by listing the “/dev/disks” folder, there are 2 devices. The Kingston device is my boot SSD, the Seagate device (ST…) is the device I added.
The :1, :5, etc numbering refers to the partitions on the device. We want to passthrough the while disk, so we use “t10.ATA_____ST8000DM0042D2CX188_… ” (without any colon after it).
Now create the pointer file:
vmkfstools -z /vmfs/devices/disks/t10.ATA_____ST8000DM0042D2CX188_... /vmfs/volumes/datastore1/vm/seagate.vmdk
The first parameter is the disk we want to passthrough, the second parameter is the location where we want to save the vmdk (preferably save it with your VM).
(/vmfs/devices is a symlink to /dev, so you are actually working on the same location)
Close your SSH console, do not forget to disable your SSH service.
Now, edit your VM, add an existing disk, and select the VMDK you just created (seagate.vmdk in our example).
A tip, add the VMDK to the SATA controller of the VM, or it may not boot due to missing drivers.
Have fun, and don’t break production environments! 😉