Import Disk Image to VM

Disk Manager · VM~5 minView script

Import a disk image file (.img, .qcow2, .vmdk or .raw) into an existing Proxmox VM. ProxMenux collects every decision up-front — target VM, Proxmox storage, source directory, interface, SSD emulation, boot order — and then runs qm importdisk for every selected image.

What this does

Unlike Import Disk to VM (which attaches a raw physical disk), this flow takes a file sitting on the host — exported from another hypervisor, downloaded as a cloud image, extracted from a backup — and converts it into a proper Proxmox VM disk on the storage volume of your choice. The original file is preserved; ProxMenux copies it, it does not move it.

How the script runs

The flow has two phases. Phase 1 collects every decision (VM, storage, source directory, images, per-image options) up-front via dialogs. Phase 2 runs qm importdisk for each selected image. Until Phase 2 begins, nothing is copied and the VM config is not touched.

┌─────────────────────────────────────────────┐
│  PHASE 1 — Collect every decision           │
│  (nothing touched yet)                      │
└──────────────────┬──────────────────────────┘
                   ▼
      qm list — user picks target VM
      (target VM should be powered off)
                   │
                   ▼
      pvesm status -content images
      ├─ 0 candidates → abort
      │   "no storage for disk images"
      ├─ 1 candidate  → auto-select, skip dialog
      └─ 2+           → user picks
                   │
                   ▼
      Source directory
      ├─ default: /var/lib/vz/template/iso
      └─ custom:  user types absolute path
          └─ not a directory → abort
                   │
                   ▼
      Scan the directory (maxdepth 1)
      for *.img *.qcow2 *.vmdk *.raw
      ├─ 0 results → abort
      │   "no compatible disk images found"
      └─ N results → continue
                   │
                   ▼
      User selects one or several images
      (checklist — multiple allowed)
                   │
                   ▼
      For each image, user picks:
      ├─ Bus:   scsi (default) / virtio / sata / ide
      ├─ SSD emulation (ssd=1)
      │   └─ offered only when bus ≠ virtio
      └─ Bootable? (adds to boot order in Phase 2)
                   │
                   ▼
      Summary of everything Phase 2 will do
                   │
   ┌──────── Cancel   OR   Confirm ────┐
   ▼                                   ▼
Exit, nothing        ┌─────────────────┴─────────────────┐
was changed          │  PHASE 2 — Import and attach       │
                     └─────────────────┬─────────────────┘
                                       ▼
                       For each selected image:
                       ├─ qm importdisk <VMID> \
                       │      <source-file> \
                       │      <target-storage>
                       │    (format conversion is transparent:
                       │     qcow2/vmdk/img → raw when the
                       │     target cannot hold the source
                       │     format natively — LVM, ZFS, …)
                       │
                       ├─ Find next free {bus}N slot
                       │   (scans qm config)
                       │
                       └─ qm set <VMID> -{bus}N \
                             <storage>:vm-<VMID>-disk-N[,ssd=1]
                                       │
                                       ▼
                       If any image was marked bootable:
                       └─ qm set <VMID> --boot order={bus}N
                          (first bootable wins; others can be
                           reordered later in the Proxmox UI)
                                       │
                                       ▼
                       Verify: qm config <VMID> shows the
                       new slot(s) and, if applicable, the
                       new boot order
                                       │
                                       ▼
                       Source image file on the host is
                       kept unchanged (copied, not moved)

Prerequisites

  • At least one VM defined on the host. The target VM should be powered off.
  • At least one image file of a supported format in the source directory. Supported: .img, .qcow2, .vmdk, .raw.
  • Enough free space on the target Proxmox storage to hold each imported disk.
  • ProxMenux looks for images in /var/lib/vz/template/iso by default. You can point it to any other directory on the host when it asks.

Step-by-step

Step 1

Pick the target VM

ProxMenux reads qm list and shows every VM. Pick the one that will receive the imported disk(s).

Step 2

Pick the Proxmox storage

The list contains every storage that has the images content type enabled. If there is only one candidate it is auto-selected and the dialog is skipped.

Step 3

Pick the source directory

Choose the default directory (/var/lib/vz/template/iso) or type a custom path — typically where you downloaded / uploaded the image. The script rejects paths that do not exist.

Step 4

Pick one or several images

The directory is scanned for .img / .qcow2 / .vmdk / .raw files. You can select several at once; each will go through the per-image options in the next step.

Step 5

Per-image options

For every selected image ProxMenux asks:

  • Interfacescsi (default), virtio, sata or ide. Matches how the guest will see the disk.
  • SSD emulation — only offered for non-VirtIO interfaces. Adds ssd=1 so the guest advertises the disk as solid-state (useful for OS-level TRIM / alignment).
  • Bootable — if yes, ProxMenux adds the disk to the boot order so it becomes the primary boot device of the VM.
Step 6

Import and attach

ProxMenux runs qm importdisk for every image (converting format on the fly where needed), attaches the resulting disk to the next free slot (scsiN, sataN, …) with your chosen options and — if you marked any disk as bootable — updates the boot order. Progress shows in the terminal.

Manual equivalent

A single-image import maps to three qm commands:

# 1. import the image file into the target storage (here: local-lvm)
qm importdisk 101 /var/lib/vz/template/iso/server.qcow2 local-lvm

# 2. attach the imported disk as scsi1 with SSD emulation
qm set 101 -scsi1 local-lvm:vm-101-disk-1,ssd=1

# 3. (optional) make it the primary boot device
qm set 101 --boot order=scsi1

Image format conversion

When the target storage cannot hold the source format natively (for example, LVM storage cannot hold .qcow2), qm importdisk converts the image transparently. This can take several minutes for multi-GB images; plan accordingly and do not interrupt the script.

Troubleshooting

"No compatible disk images found"

The script scanned the directory but found no .img / .qcow2 / .vmdk / .raw file. Check the extension (case matters), that the file sits directly in the selected directory (no sub-directories are searched) and that permissions allow root to read it.

Import is slow

VMDK → QCOW2 → raw conversions are CPU- and I/O-bound. Import speed depends on the source read speed, the target storage write speed and CPU for decompression. Prefer raw or qcow2 sources when possible.

Imported disk boots into UEFI shell

The image was built for legacy (SeaBIOS) but the VM uses OVMF (or vice versa). Either switch the VM's BIOS in Proxmox to match the image, or rebuild the image in the correct mode before importing.

Related