How to migrate a VMWare vmdk to Proxmox 4.4 with local-lvm storage

32,541

That's a workaround for importing vmdk to proxmox vm. And that is what I've done.

1) You can as its as a lvm. You can look at https://www.howtoforge.com/linux_lvm about lvm. Brief structure;

  • pv physical volumes like /dev/sdb1
  • vg volume groups, group of physical volumes
  • lv logical volumes, allocations from vg
    • like /dev/vgname/lvname , you size it

So:

you can see it

lvdisplay

you can mkfs, but careful on proxmox

mkfs.ext4 /dev/vgname/lvname

you can mount it

mount /dev/vgname/lvname /mnt/lvname

2) You must first check vmdk image size. This is important because you can not put a larger image on a smaller block device. details: https://askubuntu.com/questions/657562/extracting-qcow2-image-to-a-smaller-real-drive/657682

qemu-img info disk0.vmdk

image: disk0.vmdk
file format: vmdk
virtual size: 82G (88081432576 bytes)
disk size: 2.0G

You can see disk size, it is vmdk file's disk usage. And virtual size, it is vm's harddisk size.

Then, you create a vm with 82G "ide" disk (in my case)

You can check disk path with:

lvdisplay

Then you copy vmdk over it in raw format:

qemu-img convert -p -O raw disk0.vmdk /dev/vgname/vm-111-disk-1

That's it, works for me.

For size problem, you can resize your vmdk with qemu-img resize your.vmdk 82G or you can resize vm's disk size on web interface. But you MUST check qemu-img info to be sure vmdk smaller than vm's disk.

You can upload files with SFTP or use USB as you can see above. Use different directories or disks, or mount them if it's necessary.

You can use SMB on proxmox, smbclient is already installed I guess. This is not going to break proxmox. Maybe security issues, you can check open ports on proxmox, and limit them for some IP subnets.

Share:
32,541

Related videos on Youtube

Ian Chilvers
Author by

Ian Chilvers

Updated on September 18, 2022

Comments

  • Ian Chilvers
    Ian Chilvers over 1 year

    Until recently I was using Proxmox 4.0 and this was my procedure for converting a VMWare VM to Proxmox

    • Create a working VM. Uninstall VMWare Tools
    • Mount the ProxMox
    • Drivers ISO and copy the necessary drivers to the C:\PVE folder
    • Start the Windows virtual machine on VMware and execute the File Mergeide.reg.
    • Make sure Atapi.sys, Intelide.sys, Pciide.sys, and Pciidex.sys are in the %SystemRoot%\System32\Drivers folder.
    • Shutdown Windows.

    Then prepare the VMDisk using the vdiskmanager

    "C:\Program Files\VMware\VMware Server\vmware-vdiskmanager" -r disk0.vmdk -t 0 disk0-pve.vmdk

    Then convert the vmdk to a qcow2 file

    qemu-img convert -f vmdk disk0-pve.vmdk -O qcow2 disk0-pve.qcow2

    Now in Proxmox create the VM using the same hardware spec as the VM in VMWare. Then rename the disk0-pve.qcow2 to vm-VID-disk-1.qcow2

    Then upload the qcow2 file to /var/lib/vz/images/VID

    Run the VM and sorted…

    Now here’s my problem.

    Just upgraded to Proxmox 4.4 and I believe it all changed from version 4.2 onwards

    My Proxmox server installation created to storage areas (local & local-lvm) When you create a VM the disks are placed on the local-lvm storage. The /etc/pve/qemu-server/VID.conf file shows the location as local-lvm:vm-VID-disk-1

    So my first question is this.

    1) What do I do with my .qcow2 file? I can’t upload it to /var/lib/vz/images as that’s empty and I have no idea how to navigate to local-lvm (I’m assuming you can’t as its a lvm)

    2) How do I get the vm-VID-disk-1.qcow2 file (I created above) to local-lvm:vm-VID-disk-1?

    Other questions…

    On the old Proxmox 4.0 I used to switch off the VM and download the qcow2 as a backup (I know I can snapshot) but the qcow2 file was for off site emergencies.

    3) So how do I get the local-lvm:vm-VID-disk-1 copied to a vm-VID-disk-1.qcow2?

    Of course the other problem is the "created" local storage was small in size (decided by the proxmox installer). It decided on 200Gb.

    4) However one of the disks (qcow2 file) is 500Gb so how do I get that to the local-lvm?

    Of course on version 4.0 it wasn't a problem because it was all one storage area under "/" and I could upload and download the qcow2 files via SFTP.

    I could put the disk on a USB Disk and mount it maybe?

    What's your thoughts on mounting to a SMB share from my PC that has the qcow2 file? Does proxmox even support SMB mounting? or will I need to install the debian packages? if so will that break the proxmox and its performance as a hypervisor?

    Sorry lots of questions :-)

  • Tmanok
    Tmanok almost 3 years
    Hey Mike, could you please elaborate on this portion of your answer: "I created a new VM in Proxmox, specifying the "Directory" storage" I'm having a hard time understanding what you mean. Thanks!
  • Tmanok
    Tmanok almost 3 years
    You are a life saver! Something to help others: If you have a dynamic or thin provisioned VHDX (hyperV) virtual disk, but the data inside is far less, you can convert to RAW on a physical (or logical) local-lvm that is smaller than the "RAW" disk size. So long as the VHDX was contiguous, the virtual disk won't corrupt. Trouble is, your local-lvm is immediately full because you technically just wrote a thin-provisioned file that is larger than the local-lvm. (I did this yesterday by accident and the Windows VM is perfectly fine).
  • Mike DeAngelo
    Mike DeAngelo almost 3 years
    Tmanok, the volumes that support VMs in Proxmox can be in a few different formats. The storage could just be a regular unix directory on the file system, or it can be a volume defined in ZFS, or a volume defined in LVM. If it is a regular file in a regular directory, you can copy an existing file there using normal tools like scp or sftp. You need special tools to do load a file into a volume in ZFS or LVM. I prefer to copy the file as a normal file, get the VM running, and then I can convert the file to a volume in ZFS or LVM using the ProxMox interface.