Moving large VMDK’s from one Windows File Server to another in vSphere 4.X
At my Job we are nearing the end of our W2k8R2 upgrades. The only W2k3 servers left are our file servers. In planning to upgrade these W2k3 file servers we decided to create the new W2k8R2 file servers in advanced and during scheduled down time migrate the VMDK’s holding the shares to the new VM. An overview of the plan was as follows:
- Create a new W2K8R2 VM, called NewFileServer
- On FileServer (W2k3) remove the virtual hard drive holding the share info
- Move the VMDK to the datastore folder of NewFileServer and attach it to NewFileServer
- Verify data is ok, if so rename FileServer to OldFileServer and rename NewFileServer to FileServer
- Recreate shares and verify access works on FileServer (W2K8R2), if so remove OldFileServer
Below are the actual steps
- Ensure a recent backup of the W2k3 source VM has been made
- Remove all snapshots from the W2k3 source VM
- Export Share information from the Registry of the W2K3 source VM
-
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares
- This contains names and security for all types of shares (printers, files, etc)
- Under Windows uninstall the hard drive containing the share data and power down the W2K3 source VM
- In the vSphere client remove the virtual hard drive from the W2K3 source VM
- While still in the vSphere client go to the Datastores and move the VMDK to the proper datastore folder where the W2k8R2 target VM is located
- In the vSphere client add the new disk to the W2k8R2 target VM
- Go to Disk management and bring the disk online
- It may show up as a foreign disk that needs to be imported
- Verify file data is intact
- Rename or dis-join the old VM from the domain and change IP from static to DHCP
- The AD account should remove itself if renamed.
- If disjoined the AD account will rename but the AD account cannot be reset, it will need to be deleted and a new one will need to be created
- On the new VM rename it’s Window’s computer name to match the old VM, and change IP to static and then restart
- Once rebooted Import the exported registry file and restart
- Or just restart the Windows Server Service
- Verify that the shares work
House Keeping
This doesn’t need to be done but it helps make sure the VM files and Datastore folders match the VM’s AD name
- Shutdown and remove both VM’s from the inventory of vCenter (DO NOT DELETE THE VM’s)
- Browse to the datastore and create a new folder for the old VM
- Move all the files of the old VM to the new folder
- Move all the files of the new VM to the old VMs folder, delete the now empty new VM folder
- Login to the to a host that has access to the Datastore
- Login into the ESXi host via SSH
- If SSH is not on then login into ESXi console of the host you’re working with
- Turn on SSH access
- Set the SSH timeout for 30 or 60 minutes so you don’t have to remember to turn it off
- Browse to the data store, eg.
-
cd "/vmfs/volumes/NX4-SATA-RAID5-01/Intranet/"
- The CLI is case sensitive
- Find the VMDK in question and rename it by
-
vmkfstools -E mail2_2.vmdk intranet_2.vmdk
- The Flat file will get renamed once the vmdk is renamed
- Verify the file was renamed by running ls- l
- The various other files can also be renamed in in the CLI as well, e.g.
-
mv vm-old.vmx vm-new.vmx
- This needs to be done for the following file types
- NVRAM
- VMSD
- VMX
- VMXF
- Description of those files if you are curious
- Stay logged in on the off-chance you need to reenter the SSH, otherwise logout
- Once finished browse to the datastore and rename any non VMDK file that still has the old name
- Re-Add both VMs to the inventory
- For both VMS, In the VM settings remove the entry for the OLD VMDK and add the renamed VMDK (make sure it’s SCSI (0:0) Hard disk 1)
- Turn both on VMs, when prompted select “I moved it”
- Verify both still function.
- Check any auxiliary info (Repoint Backup Agents etc.)
- Log out of the SSH session if you already haven’t