I have recently moved us from having two boxes, the ESXi server and a file server, down to just the ESXi host. This is a great thing because what used to be 14 servers in a rack in the basement, all with howling fans and clunking harddrives, has been reduced to a single quad core chassis sitting lonely in a 7 foot rack. Where I’m not as comfortable though is with running a vm as my file server and having all of my data tied up in vmdks without a solid, enterprise storage array behind it. If something goes wrong I want the peace of mind of being able to rip the drives out of my server, pop them into another box and be back on my feet in a matter of minutes. I’m not certain I can do that if I have all of my data spread across 9 or 10 vmdk files on 3 drives, but I know I can pop a linux based, 3 disk RAID-5 set into any old linux machine and be online. My solution is to create a linux file server in vmware, but give it raw access to some attached SATA drives so the drives end up looking and working just like they had come out of a physical machine. No vmware vmdk or other info anywhere in sight. VMWare will allow you to setup raw disk maps to storage that is located on a SAN using the VI client, but not to local SATA storage. Fortunately it’s a very simple process to hack and works like a charm.
You’ll need ssh access to your esxi host, a vmfs that you are not doing raw access to in order to store a mapping file and drives to map.
First, ssh into your esxi server and run fdisk -l to get a listing of all of the drives that you esxi host sees. The format will look something like this
~ # fdisk -l
Disk /dev/disks/t10.ATA_____ST32000542AS________________________________________5XW205BS: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
The key being “/disks/t10.ATA_____ST32000542AS________________________________________5XW205BS” . That is how ESXi uniquely identifies your drive. I believe it breaks down to something along the lines of /disks/controler.interface_Drive-model_Drive-serial-number, but I’m mostly making that up as I go.
Now that we have the drive identified, we need to take that information and create a drive map file. cd over to a datastore that is NOT a raw mapping (i.e. I have a 500 gig drive in my box that hosts most of my vms called SATA-500 in /vmfs/volumes/SATA-500, so I would cd into there) and run the following, replacing with your own information as needed. Note that I use buslogic adapters on my VMs, if you use lsilogic, replace buslogic with lsilogic. The name “RAW-2TB.vmdk” is free form, but I would try to make it descriptive and it must be a .vmdk extension.
vmkfstools -z /vmfs/devices/disks/t10.ATA_____ST32000542AS________________________________________5XW205BS RAW-2TB.vmdk -a buslogic
Two files get created after you run that command. The RAW-2TB.vmdk file that we specified and a RAW-2TB-rdmp.vmdk . You can cat the RAW-2TB.vmdk file to get a look at how vmware saw your drive and what kind of information it’s passing back to the hypervisor on how to use it, but I would not mess with that rdmp file. Think of it as the actual disk, doing a cat on that file is going to give you nothing but a messy terminal if the console will allow you to do it at all.
At this point, switch into your vcenter client and go to the VM that you want to assign these drives to. Go into Edit Settings, Add a Hard Disk, Use an Existing Virtual Disk and browse to the RAW-2TB.vmdk file that was just created. When you select that file, ESXi reads all of the information in it and grants that VM access to that drive without any additional vmware specific info ever getting written to the disk. You can pop that disk into a physical machine and it would read it just as if it came out of a physical machine.