Migration from ESXi to Proxmox

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

VlaKl

New Member
Apr 26, 2019
23
0
1
Hi.


How to migrate VM from Esxi 5.5 to Proxmox VE 5.4-3

VM > 100 (Windows, Linux)


Manually is a very long time (is there a way to automate migration?
 

Monoman

Active Member
Oct 16, 2013
420
178
43
If you're clever you can script it. Otherwise it's a slow process. I can tell you how to script it if you like.
 

VlaKl

New Member
Apr 26, 2019
23
0
1
It would be nice if you told me how to write a script.
This is done by copying .vmdk file on proxmox and qemu-img convert ?

How to do it properly ? My very bad script

#! /bin/bash
echo -n 'Esxi:'
read ESXI
echo -n 'Path to vmdk :'
read VMD
echo $VMD
echo -n 'User :'
read User
echo -n 'Name old disk :'
read OldDisk
qemu-img convert /root/$OldDisk -O vmdk /root/vm-500-disk-1.vmdk
 

Monoman

Active Member
Oct 16, 2013
420
178
43
We need a LOT more info about your proxmox setup.

How are you handing networking?

What's your storage setup currently?

if all your windows/linux VM's are the same size/spec, then you can do something like this.

create a single vm template how you want them all to be (cpu/ram/network)

pseudo code...

for i in total_vm_count,
loop
qm clone vmid %i --full

This will create all your VM's.

the hard part will then be to convert each of your existing disks into the new format.

for i in total_vm_count,
loop
dd if=%i.vmdk of=/dev/VG_iscsi/vm-%i-disk-1 (for LVM)
dd if=%i.vmdk of=/dev/zvol(needs_to_be_decided)/vm-%i-disk-1 (for ZFS)
qemu convert %i.vmdk -O /path/tp/storage/images/%i/vm-%i-disk-0.qcow2

This is the basis for the script. I omitted the networking part, but we're lacking details here. Also assuming your local numbering of VM's on esxi will be a 1 to 1 for proxmox. If you decide to change this up, it becomes a lot more difficult and you should just do it all manually sadly.

Hope this helps.
 

VlaKl

New Member
Apr 26, 2019
23
0
1
Thanks so much.

Checked manually Need to do so:
1) Copy files flat.vmdk by scp.
2) Convert them to raw
3) dd

How to pass a flat path to the script.vmdk ? From a file ?
Is that correct ?

!/bin/bash
echo -n 'User:'
read User
while read VMDK;
do
scp $User@10.50.10.154: $VMDK /dev/vg_ibm_01-1/TEST_VM_DISKS
done
exit
 

VlaKl

New Member
Apr 26, 2019
23
0
1
FIX
#!/bin/bash
while read VMDK;
do
scp root@10.50.10.154:$VMDK /dev/vg_ibm_01-1/TEST_VM_DISKS
done < DISKS
exit
Copying works
Next I want to convert
For example so
find /dev/vg_ibm_01-1/TEST_VM_DISKS -iname *-flat.vmdk -exec qemu-img convert {} /dev/vg_ibm_01-1/TEST_VM_DISKS/Converted/{}.raw\;

But there is an error
find: missing argument to `-exec'
I would appreciate your help
 

iamthewalrus

New Member
Jun 28, 2017
3
0
1
45
Add a space between .raw and \; and that should fix the missing argument to -exec error. ( \; is what find needs in order to figure out where the command it is being asked to execute ends)

FIX
#!/bin/bash
while read VMDK;
do
scp root@10.50.10.154:$VMDK /dev/vg_ibm_01-1/TEST_VM_DISKS
done < DISKS
exit
Copying works
Next I want to convert
For example so
find /dev/vg_ibm_01-1/TEST_VM_DISKS -iname *-flat.vmdk -exec qemu-img convert {} /dev/vg_ibm_01-1/TEST_VM_DISKS/Converted/{}.raw\;

But there is an error
find: missing argument to `-exec'
I would appreciate your help
 

VlaKl

New Member
Apr 26, 2019
23
0
1
Thanks. But find /dev/vg_ibm_01-1/TEST_VM_DISKS -iname *-flat.vmdk -exec qemu-img convert {} /dev/vg_ibm_01-1/TEST_VM_DISKS/Converted/{}.raw \;

qemu-img: /dev/vg_ibm_01-1/TEST_VM_DISKS/Converted//dev/vg_ibm_01-1/TEST_VM_DISKS/TEST_CentOS-flat.vmdk.raw: error while converting raw: Could not create file: No such file or directory

I generally need to convert and then dd. How it can be implemented. There was an idea to find everything in the folder and convert , but there were problems. And the next step is dd from the converted disk. Let's say I pass the disks for Proxmox as a file. How can I do to have the drive copied to the desired drive Proxmox. In General, how to convert and dd ? )
 

VlaKl

New Member
Apr 26, 2019
23
0
1
FIX.
This is the correct script. But when dd if is correct but of the same.
That is
dd if=/dev/vg_ibm_01-1/TEST_VM_DISKS/TEST_CentOS-flat.vmdk.raw of=/dev/vg_ibm_01-1/vm-201-disk-0

dd if=/dev/vg_ibm_01-1/TEST_VM_DISKS/TEST_WIN7-flat.vmdk.raw of=/dev/vg_ibm_01-1/vm-201-disk-0

And should be correctly

dd if=/dev/vg_ibm_01-1/TEST_VM_DISKS/TEST_CentOS-flat.vmdk.raw of=/dev/vg_ibm_01-1/vm-201-disk-0

dd if=/dev/vg_ibm_01-1/TEST_VM_DISKS/TEST_WIN7-flat.vmdk.raw of=/dev/vg_ibm_01-1/vm-202-disk-0

#!/bin/bash
while read VMDK
do
scp root@10.50.10.154:$VMDK /dev/vg_ibm_01-1/TEST_VM_DISKS
done < ESXI
find /dev/vg_ibm_01-1/TEST_VM_DISKS -iname *-flat.vmdk -exec qemu-img convert {} {}.raw \;
while read RAW
do
for i in `find /dev/vg_ibm_01-1/TEST_VM_DISKS -iname *.raw`
do
echo "copy $i ==> $RAW"
dd if=$i of=$RAW
done
done < PROXMOX
 
Last edited:

zxv

The more I C, the less I see.
Sep 10, 2017
156
57
28
This may help both in terms of time to copy, and take less disk space.

If the vmdk is 'Thin provisioned', then the 'flat' vmdk files is sparse, meaning there are many sectors that are unallocated.

For thin provisioned disks, DD will expand the file.
Other tools such as "cp --sparse=always" or 'qemu-img convert -S <blocksize>' retain the sparse allocation.

scp does not support sparse files, while rsync does. So one option for remote transfer would be:
rsyanc -aS root@10.50.10.154:$VMDK /dev/vg_ibm_01-1/TEST_VM_DISKS
 
  • Like
Reactions: BoredSysadmin