At times you will have a QCOW2 file that you want to import into Proxmox. Although this is a fairly trivial process, if you only do it every now and again you’ll probably need some kind of playbook. In this article, we attempt to create a playbook, with some references if it’s not enough.
This process assumes you’ll be using FTP to get the remote QCOW2 file on the local box. This could be problematic if you don’t have the correct size of disk space available locally on the Proxmox server. But bear in mind if your remote QCOW file is 200GB, but you only use 50GB of disk space, the resultant file will be 50GB so you should be fine. The long term solution to this problem might be when installing Proxmox to ensure that the default 100 GB pve-root is made to something that will cater for future imports, perhaps 200 GB or so.
- SSH to the Proxmox server
- Check disk space on
pwdto make sure you’re in root
- A temporary directory
/root/vm.importwill be used. Create it, and make sure it’s cleaned afterwards once you’re 100% the import was a success
- Ftp / bin / hash
- get remotefilename.qcow2
At this point the remote QCOW2 backup file is on the Proxmox server on
pve-root in the
From here we have to convert it to a VM, but first make sure the VM is created and find the unique ID. In the example below, the unique ID is 106. Also note that when you create a new VM, it will automatically have a disk. Since we’re not going to be using this disk, it can be safely deleted afterwards by using the UI’s “remove” option. As with anything else to do with deletions, double check before pressing confirm.
Information required to complete this operation:
- CPU and memory of previous VM
- Enough disk space on the local root as it will be a temporary store for the FTP’ed file
- The Unique ID assigned when creating a VM in Proxmox
- New IP address to be assigned to the VM, subnet mask, and default gateway.
- You need this as once the VM is transferred the network configuration needs to be updated
Example of disk transfer statistics:
226-File successfully transferred 226 243.912 seconds (measured here), 11.10 Mbytes per second 2839448660 bytes received in 243.99 secs (11.0985 MB/s)
Once the file is local, you can import the disk.
Import the disk
qm importdisk 106 harddisk.qcow2 local-lvm|raid1|raid0
local-lvm|raid1|raid0 is a collection of disks we have on our system, substitute that with whichever disk you want to import file to go to. You could try the
lsblk command to see your disk layout if you’re using the default thin provisioning.
Once the import is complete, the final lines of the output will look similar to this (note ` unused0:raid1:vm-106-disk-1` as part of that will be used next).
transferred: 161061273600 bytes remaining: 0 bytes total: 161061273600 bytes progression: 100.00 % Successfully imported disk as 'unused0:raid1:vm-106-disk-1'
Associate the disk
There are probably ways of associating the disk using the UI, but the command below will do the same. Remember when you set up a new VM with the CPU and memory, a default disk was created that can be deleted. The command below associates the newly imported disk with the VM and marks the newly created disk as Unused.
[email protected]:~/vm.import# qm set 106 --scsi0 raid1:vm-106-disk-1 update VM 106: -scsi0 raid1:vm-106-disk-1
That’s it! Now you can start the VM and reconfigure the IP address, subnet mask, and default gateway, and you should be good to go.
1 thought on “How to import a QCOW2 file to Proxmox”
This worked perfect for importing a qcow2 file in my proxmox vm. thanks for sharing!