qm-importdisk
Import a disk image into Proxmox VE
TLDR
View documentation for the original command
SYNOPSIS
qm importdisk <vmid> <source_file> <target_storage> [OPTIONS]
PARAMETERS
<vmid>
The ID of the virtual machine to which the disk will be imported/attached.
<source_file>
The absolute path to the external disk image file (e.g., .raw, .qcow2, .vmdk) on the Proxmox host.
<target_storage>
The ID of the Proxmox storage where the new virtual disk will be created (e.g., local-lvm, local-zfs, NFS-storage).
--format <fmt>
Specifies the format of the source disk image. Supported formats include raw, qcow2, and vmdk. If omitted, `qm-importdisk` attempts to auto-detect the format.
--sparse <boolean>
Set to true to create a sparse image on filesystems that support it (e.g., ZFS, Ext4). This means only used blocks are allocated, saving space. Defaults to false.
--discard <boolean>
Enable or disable TRIM/discard support for the virtual disk. Set to true to allow the guest OS to issue TRIM commands to the underlying storage. Defaults to false.
--bwlimit <integer>
Sets a bandwidth limit for the import operation, in KiB/s. Useful to prevent the import from saturating network or disk I/O during large transfers.
--skip-check <boolean>
Set to true to skip the disk format consistency check. Use with caution, as it may lead to corrupted disks if the source file is malformed. Defaults to false.
--target-disk <string>
Specifies the filename or volume ID for the new disk on the target storage. Useful for custom naming, otherwise Proxmox generates a name.
--vm-disk <string>
Directly attach the imported disk to the VM using a specific bus and ID, e.g., scsi0, ide2, virtio0. If this option is not specified, the disk will be created as an 'unused disk' and must be attached manually later using qm set.
DESCRIPTION
The `qm-importdisk` command, a subcommand of Proxmox VE's primary `qm` utility, facilitates the seamless import of an existing disk image file into a Proxmox virtual machine. This command is crucial for scenarios such as migrating VMs from other hypervisors, adding pre-existing data disks, or converting external disk images into a format suitable for Proxmox.
It takes a source disk image file (e.g., raw, qcow2, vmdk) and copies its content to a specified Proxmox storage, creating a new virtual disk. Optionally, it can also attach this newly created disk directly to a virtual machine's configuration using a specific bus type (e.g., SCSI, VirtIO, IDE) and disk ID. If not attached directly, the disk will be available as an 'unused' disk within the VM's storage settings, requiring manual attachment later. `qm-importdisk` streamlines the process of integrating external storage resources into the Proxmox ecosystem, making it a fundamental tool for managing VM storage.
CAVEATS
Ensure the source_file is accessible by the Proxmox host and that target_storage has sufficient free space for the imported disk.
If --vm-disk is not used, the imported disk will be added to the VM's hardware list as an 'unused disk' and will require a manual qm set command to attach it.
Disk format auto-detection is generally reliable, but explicitly specifying --format can prevent issues.
This command imports the raw disk image; it does not modify or partition the guest's filesystem.
USAGE EXAMPLES
Here are some common ways to use qm-importdisk:
Import a QCOW2 image as an unused disk:
qm importdisk 100 /path/to/image.qcow2 local-lvm --format qcow2
Import a RAW image and attach it as VirtIO disk 0:
qm importdisk 101 /mnt/backup/data.raw zfs-storage --format raw --vm-disk virtio0 --sparse true
Import a VMDK disk with a bandwidth limit:
qm importdisk 102 /var/lib/vmware/myvm.vmdk nfs-share --format vmdk --bwlimit 50000 (50MB/s)
DISK FORMATS
raw: A bit-for-bit copy of the disk. Simple but does not support advanced features like snapshots directly.
qcow2: QEMU Copy-On-Write format. Supports snapshots, compression, and thin provisioning. Very common in QEMU/KVM environments.
vmdk: VMware Virtual Machine Disk format. Used for compatibility with VMware images, allowing easier migration from VMware platforms.
HISTORY
The qm-importdisk command is an integral part of the Proxmox VE (Virtual Environment) management toolkit, which has been under continuous development since its inception. It was introduced to simplify the process of bringing external disk images, often from other virtualization platforms or backups, into the Proxmox environment. Over time, its capabilities have expanded, notably with the addition of options like --vm-disk to allow direct attachment during import, significantly streamlining workflows for administrators. Its evolution reflects Proxmox's commitment to providing robust and user-friendly VM management features.