diff --git a/README.md b/README.md index 0c4ac1f..c54d269 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,199 @@ -# VMware-to-Proxmox_Migration_Guide +# VMware to Proxmox Practical Migration_Guide + +Easy guide on how to migrate your Windows VMs from WMvare to Proxmox. + +You can eather use variant one which is transfaring VMs faster. But you need at least 2 servers to use this variant. + +Or you can try variant two which is easier but VMs migrate much more slowly and you need space on your computer to do this. + +# Variant 1. server to server migration (better one) + +You will need to have VMware and Proxmox server for this running both at the same time. And SSH acess to both of them. + +### 1. Create Ubuntu 20.04 container + +Login into Proxmox web interface. + +Navigate to storage ``Local > CT Storage > Templates``. + +Click on ``Templates`` and download Ubuntu 20.04. + +After finishing, right-click on server and create new cotainter with Ubuntu 20.04. + +### 2. Download OVFtool to Ubuntu container + +``Server > Ubuntu > Console`` + +Navigate to work folder and donwload OVFtool using this command: +```bash +cd /home/ +wget LINKINVALID +``` + +*Alternatively you can download it to your computer using [official link](https://developer.vmware.com/web/tool/ovf-tool/), or [download it from this guide](https://weforgecode.xyz/#). And the transfare the OVFtool to Ubuntu container using SCP.* + +### 3. Install OVFtool + +```bash +chmod +x ./VMware-ovftool-4.4.3-18663434-lin.x86_64.bundle +./VMware-ovftool-4.4.3-18663434-lin.x86_64.bundle +``` +After running this command, Terms of use should appear. Press spacebar until you get to end and then type ``yes`` and press enter. + +### 4. Copy export script + +Create new file named export.sh using: + +```bash +nano export.sh +``` + +Copy this script and paste into that file by right-click and paste. + +_export.sh_ +```bash +#!/bin/bash + +# Variables +VM_NAME=$1 +VMID=$2 + +VCENTER_USERNAME="root" +VCENTER_PASSWORD="YOUR-VCENTER-ROOT-PASSWORD" +VCENTER_HOST="YOUR-VCENTER-IP-ADRESS" + +PROXMOX_USER="root" +PROXMOX_PASSWORD="YOUR-PROXMOX-ROOT-PASSWORD" +PROXMOX_HOST="YOUR-PROXMOX-IP-ADRESS" + +if [[ -z "$VM_NAME" || -z "$VMID" ]]; then + echo "Usage: $0 " + exit 1 +fi + +# VMware OVF Tool Path +OVFTOOL_PATH="ovftool" + +# Create temporary directory on Proxmox +TMP_DIR=$(ssh ${PROXMOX_USER}@${PROXMOX_HOST} "mktemp -d -p /var/lib/vz/template/${PROXMOX_STORAGE}") +echo "Temporary directory created at: $TMP_DIR on Proxmox" + +# Export VM to OVA and copy directly to Proxmox +echo "Exporting VM to OVA and copying directly to Proxmox..." +"$OVFTOOL_PATH" --noSSLVerify "vi://$VCENTER_USERNAME:$VCENTER_PASSWORD@$VCENTER_HOST/$VM_NAME" | sshpass -p "$PROXMOX_PASSWORD" ssh -C ${PROXMOX_USER}@${PROXMOX_HOST} "c> + +# Run import script on Proxmox +echo "Running import script on Proxmox..." +sshpass -p "$PROXMOX_PASSWORD" ssh ${PROXMOX_USER}@${PROXMOX_HOST} "bash /var/lib/vz/template/inport3.sh $VM_NAME $VMID" + +# Clean up the temporary files on Proxmox +echo "Cleaning up temporary files on Proxmox..." +sshpass -p "$PROXMOX_PASSWORD" ssh ${PROXMOX_USER}@${PROXMOX_HOST} "rm -rf ${TMP_DIR}" + +echo "VM export and import process completed." +``` +#### ! You need to change "YOUR-VCENTER-ROOT-PASSWORD" "YOUR-VCENTER-IP-ADRESS" "YOUR-PROXMOX-ROOT-PASSWORD" "YOUR-PROXMOX-IP-ADRESS" ! + +After that code save and exit using ``ctrl+x`` and then ``enter``. + +Now make it executable using: + +```bash +chmod +x ./export.sh +``` + +### 5. Copy import script + +``Server > Console`` + +Navigate to /var/lib/vz/template and create import.sh using same priciple like in step 4. + +```bash +cd /var/lib/vz/template +nano inmport.sh +``` + +__import.sh__ +```bash +#!/bin/bash + +# Script to import VMware images (OVF or OVA based) to Proxmox VE, executed locally on the Proxmox host + +PROXMOX_STORAGE=local-lvm +VM_PATH=/var/lib/vz/template +VM_NAME=$1 +VMID=$2 + +if [[ -z "$VM_NAME" || -z "$VMID" ]]; then + echo "Usage: $0 " + exit 1 +fi + +# Determine file extension to handle OVF and OVA appropriately +FILE_EXTENSION="${VM_NAME##*.}" + +# Import VM on Proxmox based on file type +echo "Importing VM..." +if [ "$FILE_EXTENSION" == "ova" ]; then + # Assuming qm supports OVA directly; if not, this needs to be extracted first + qm importova $VMID "$VM_PATH/$VM_NAME" $PROXMOX_STORAGE +else + qm importovf $VMID "$VM_PATH/$VM_NAME.ovf" $PROXMOX_STORAGE +fi + +# Ensure VM is fully stopped before making hardware changes +echo "Ensuring VM is stopped..." +qm stop $VMID --skiplock +sleep 10 + +# Set the SCSI controller to LSI Logic +echo "Setting SCSI hardware type to LSI..." +qm set $VMID -scsihw lsi + +# Transition each detected SCSI disk to IDE interface +DISKS=$(qm config $VMID | grep -oP 'scsi\d+: \K.*') +DISK_ID=0 +for DISK_PROP in $DISKS; do + echo "Transitioning SCSI disk to IDE..." + qm set $VMID -scsi$DISK_ID none + qm set $VMID -ide$DISK_ID $DISK_PROP + ((DISK_ID++)) +done + +# Set network and boot order +echo "Setting network model and boot order..." +qm set $VMID -net0 model=vmxnet3,bridge=vmbr0 +qm set $VMID -boot order=ide0 + +# Start the VM +echo "Starting VM..." +qm start $VMID +``` + +At first few lines of the script you can change ``local-lvm`` to change storage on your Proxmox and the script will import VM to that storage. + +And make it executable: + +```bash +chmod +x ./export.sh +``` + +### 6. Migrate VM using script + +Turn off the VM you want to migrate in VMware. + +Navigate to Ubuntu container and import and export VM using this command. + +```bash +./export.sh NAME-OF-VM NUMBER-FOR-ROXMOX +``` +You need to use exact name of the VM from VMware and NUMBER-FOR-ROXMOX is required for proxmox. If you dont know what number to use then just use 100 and increase the number with each VM. + +#### ! Migration requires at least double the size of VM on Proxmox for it to work. ! + +### 7. Enjoy + +Congratulations! If you did everything right the VM will export and inport automatically and start when the process ends. + +# Variant 2. server-desktop-server migration (easier) -Practical guide on how to migrate Windows VMs from VMware to Proxmox. \ No newline at end of file