Update README.md

This commit is contained in:
Internet Addict 2024-04-19 14:47:04 +02:00
parent a05f064004
commit 04e86b37cb

115
README.md
View file

@ -86,7 +86,7 @@ echo "Exporting VM to OVA and copying directly to Proxmox..."
# Run import script on Proxmox # Run import script on Proxmox
echo "Running 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" 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 # Clean up the temporary files on Proxmox
echo "Cleaning up temporary files on Proxmox..." echo "Cleaning up temporary files on Proxmox..."
@ -191,7 +191,7 @@ Navigate to Ubuntu container and import and export VM using this command.
``` ```
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. 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. ! #### ! Migration requires at least double the size of VM in Proxmox for it to work. !
### 7. Enjoy ### 7. Enjoy
@ -199,3 +199,114 @@ Congratulations! If you did everything right the VM will export and inport autom
# Variant 2. server-desktop-server migration (easier) # 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
```
### 3. Import VM
Open Proxmox web interface.
Navigate to server terminal.
``Server > Console``
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.
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.