Effortlessly Import Your VirtualBox/VMware VMs to Proxmox Using Bash Script

Sumit SurSumit Sur
2 min read

๐Ÿ“– Description:

This script streamlines the process of provisioning a VM in Proxmox from an OVA file. It performs the following steps:

  1. Extracts the specified OVA archive.

  2. Converts the contained virtual disk (VMDK/VHD) to QCOW2 format.

  3. Creates a new Proxmox VM with basic resources.

  4. Imports the QCOW2 disk into a specified Proxmox storage.

  5. Attaches the imported disk as a SCSI device to the created VM.

๐Ÿ”ง Prerequisites

  • Proxmox VE with qm and qemu-img utilities installed and accessible in your PATH.

  • Appropriate permissions to create VMs and access storage on the Proxmox host.

  • The OVA file and working directory must be readable/writable by the script user.

๐Ÿš€ Usage

./import_ova.sh <OVA_FILE> <VM_ID> [STORAGE] [TEMPLATE_DIR]

๐Ÿ“‹ OVA Import Parameters

<OVA_FILE>
Full OVA filename (including the .ova extension)

<VM_ID>
Proxmox VM ID to create and import the disk into

[STORAGE] (Optional)
Proxmox storage target for the disk
Default: local-lvm

[TEMPLATE_DIR] (Optional)
Directory containing the OVA file and generated images
Default: /var/lib/vz/import

๐Ÿ“ค Upload the OVA to Proxmox server

  • Web interface:

    • you can upload the .ova file in the import section of the local storage Using the proxmox web interface
    • This is put the file at /var/lib/vz/import/

  • Using SCP:

      scp vm01.ova root@<proxmox server ip>:/var/lib/vz/template/
    

    โ–ถ๏ธ Run the script:

    Get the script at the Github Link

    Locally:

      git clone https://github.com/sumitsaz23/proxmox-scripts.git
    
      cd proxmox-scripts/import_ova/
    
      ./import_ova.sh my-vm.ova 123 my-storage /var/lib/vz/template
    

    Download & Run Directly using curl:

      curl -sSL \
        https://raw.githubusercontent.com/sumitsaz23/proxmox-scripts/main/import_ova/import_ova.sh \
        | bash -s -- my-vm.ova 123 my-storage /var/lib/vz/template
    

    VM Successfully booting up

0
Subscribe to my newsletter

Read articles from Sumit Sur directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sumit Sur
Sumit Sur