Tuesday, 30 September 2008

Moving VMs from local disk to shared storage

We've had VMware Infrastructure 3 for over a year, but our usage of it has been "organic" (read: unplanned and unstructured). Yesterday I started making moves to rectify that.

One of the things we didn't get right at the start was setting up the SAN to store all VMs. This resulted in a number of VMs crammed onto internal storage. Some VMs were loaded on SAN LUNs, but we didn't have the LUN mappings setup to allow multiple ESX servers to see them.

As I said, it was an organic install.

So yesterday I created a new 250GB LUN on the SAN and mapped it to our "infrastructure" ESX servers (three HP DL360 G4 servers - not super fast, but sufficient for domain controllers etc.). For the first time, multiple ESX servers could see the same storage.

My first action was to create a small Linux server on the shared storage and test Vmotion. This worked fine, so I started copying the VMs from internal storage to the shared LUN. To do this, I shutdown the VM, browsed to the VM folder in the datastore browser, highlighted it and selected "Move to..." from the context sensitive menu. I then selected the new SAN LUN and started the move.

Once moved, the VMX file needs to have the execute bit set (using chmod from the ESX service console), and I then removed the VM from the Virtual Center inventory. I then re-added the VM by right-clicking the VMX file in the datastore browser and selecting "Add to inventory".

Upon starting the VM, a question needs to be answered (the icon for the VM changes to a speech bubble - right click and select Answer Question). Because the VM has been moved, elect to "Keep" the VM id. The VM will then fire up properly.

Or it did in most cases. One VM gave an error that it was "Unable to lock file". A quick Google suggested a LCK file, but I didn't have one of those. To resolve this problem, I edited the VM settings and removed the hard disk (from the VM, NOT the disk file!). I then re-added the same disk, and the VM started without problems.

1 comment:

JR said...

Having just completed the VMware Fastrack training, I now know that I should have just cold migrated the VMs and it would have done the same thing.

Live and learn...