FileCloud customers may choose to use a virtual machine (VM) in an ESXI server. At times, ESXI servers may be decommissioned, requiring a migration. When FileCloud is hosted on one ESXI server, it can be moved to another using this method. This is generally a bare metal migration. Yet migrating VMware ESXI servers has always […]
FileCloud customers may choose to use a virtual machine (VM) in an ESXI server. At times, ESXI servers may be decommissioned, requiring a migration. When FileCloud is hosted on one ESXI server, it can be moved to another using this method. This is generally a bare metal migration.
Yet migrating VMware ESXI servers has always been difficult, at times even requiring the use of a third-party paid application. In this blog, we discuss a simple method to transfer VMs using the basic SCP command. We also ensure that the transferred VM disks are configured in thin provisioning.
Follow the steps below to migrate the ESXi servers:
To enable the SSH service, log in to the web interfaces for your ESXI servers. Then click on Host at the top right. Click Actions -> Services -> Enable Secure Shell (SSH) (if it is not already enabled).
Log in to the SSH of the source ESXI server using the putty tool. You may need to run the below commands:
esxcli network firewall ruleset list --ruleset-id sshClient
Check if the SSH client service is enabled. If disabled, the command will return a result of ‘False’. If a ‘False’ response is returned, run this next command. If ‘False’ is not the returned response, proceed to the next step!
esxcli network firewall ruleset set --ruleset-id sshClient --enabled=true
Before running the below commands, make sure the VM that will be migrated is turned off in the source ESXI server.
Connect to your source ESXI server using putty or your favorite SSH client (depending on Windows or Mac OS).
Navigate to your datastore where your guest VM resides. By default, it will show as below.
cd /vmfs/volumes/datastore1/
Next, migrate the data to the proper datastore path in the Destination VM.
Afterward, execute the below command in the source ESXI server:
scp -rv /vmfs/volumes/datastore1/VM_NAME root@xx.xx.xx.xx:/vmfs/volumes/datastore1/
Press ‘Enter.’ You should be prompted for a password – then the migration process will begin. The time to complete the transfer depends on the network speed between the ESXI servers.
Log in to your SSH console of the destination server. Then, navigate to the datastore path where the new VM data will be migrated from the old server.
cd /vmfs/volumes/datastore1/ VM_NAME
Run the below command to clone the VMDK to a thin provisioned disk using vmkfstools
vmkfstools -i VM_NAME.vmdk -d thin VM_NAME -thin.vmdk.
After the cloning is complete, list the files in the directory and verify that two files were created:
VM_NAME.vmdk and VM_NAME -thin.vmdk.
Rename the old flat file to a different name (e.g., mv VM_NAME-flat.vmdk VM_NAME-flat.vmdk.old)
Rename the new flat file to a different name (e.g., mv VM_NAME-thin-flat.vmdk VM_NAME-flat.vmdk)
Log in to the web interface of the destination ESXI server where the VM was migrated from the source server.
Click on Virtual Machines --> Create/Register VM
Select ‘Register an Existing Virtual Machine.' Then select one or more virtual machines, a datastore, or a directory. Select the folder of the VM Guest you moved to the new server. Click: Select --> Next --> Finish
Once you turn on the migrated VM in the destination ESXI server for the first time, you will be prompted to answer if you moved or copied the guest machine. Leave the default “I Copied It” and click “Answer.”
If the migration was completed without any errors, the VMs should start in the new host.
Article written by Nandakumar Chitra Suresh and Katie Gerhardt