326 lines
No EOL
9.4 KiB
Markdown
326 lines
No EOL
9.4 KiB
Markdown
# This guide is no logner needed since Proxmox added easy way to import VMs
|
|
|
|
## https://youtu.be/mFkEW2Fwreg&t=61
|
|
|
|
# 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 ``Server > 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.
|
|
|
|
*[Here](https://www.youtube.com/embed/EUNzHU09MYc?t=147) is a quick tutorial if you dont know how to make LXC containers.*
|
|
|
|
### 2. Download OVFtool to Ubuntu container
|
|
|
|
``Server > Ubuntu > Console``
|
|
|
|
Navigate to work folder and donwload OVFtool from this repo using this command:
|
|
```bash
|
|
cd /home/
|
|
wget https://weforgecode.xyz/amogus/VMware-to-Proxmox_Migration_Guide/raw/branch/main/ovftool.tar.gz
|
|
tar -xzvf ./ovftool.tar.gz
|
|
rm ./ovftool.tar.gz
|
|
```
|
|
|
|
*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/amogus/VMware-to-Proxmox_Migration_Guide/raw/branch/main/ovftool.zip). And the transfare the OVFtool to Ubuntu container using [SCP](https://en.wikipedia.org/wiki/Secure_copy_protocol).*
|
|
|
|
### 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 <vm_name> <vm_id>"
|
|
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/inport.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``
|
|
|
|
Open server terminal.
|
|
|
|
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 <vm_name> <vm_id>"
|
|
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.
|
|
|
|
``Server > Ubuntu > Console``
|
|
|
|
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 in 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)
|
|
|
|
### 1. Export VM
|
|
|
|
Open VMware vSphare web interface.
|
|
|
|
Shutdown VM you want to export.
|
|
|
|
Right-click on the VM and select ``Template > Export OVF Template`` then dowload VM files.
|
|
|
|
### 2. Move saved files to Proxmox
|
|
|
|
You will need SCP for transfaring files, easiest method is to [download and install PuTTY](https://putty.org/). And dont forget to add PSCP utility during the installation.
|
|
|
|
Open cmd.exe and copy files to proxmox.
|
|
```powershell
|
|
pscp C:\path\to\VM-NAME.ovf root@IP-ADRESS-OF-PROXMOX:/var/lib/vz/template
|
|
pscp C:\path\to\VM-NAME-1.vmdk root@IP-ADRESS-OF-PROXMOX:/var/lib/vz/template
|
|
```
|
|
|
|
You will need to navigate to path where the VM files are and replace the ``C:\path\to\``, use the VMs name ``VM-NAME`` and also add correct IP of Proxmox ``IP-ADRESS-OF-PROXMOX``.
|
|
|
|
### 3. Import VM
|
|
|
|
Open Proxmox web interface.
|
|
|
|
``Server > Console``
|
|
|
|
Navigate to server terminal.
|
|
|
|
In terminal navigate to /var/lib/vz/template directory
|
|
|
|
```bash
|
|
cd /var/lib/vz/template
|
|
```
|
|
|
|
Create import.sh file and copy my script.
|
|
|
|
```bash
|
|
nano import.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 <vm_name> <vm_id>"
|
|
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.
|
|
|
|
After that code save and exit using ``ctrl+x`` and then ``enter``.
|
|
|
|
And make it executable:
|
|
|
|
```bash
|
|
chmod +x ./import.sh
|
|
```
|
|
|
|
Now we are ready to import, you can import VM using this command:
|
|
|
|
```bash
|
|
./import.sh NAME-OF-VM NUMBER-OF-VM
|
|
```
|
|
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.
|
|
|
|
### 4. Enjoy
|
|
|
|
Congratulations! If you did everything right the VM will export and inport automatically and start when the process ends. |