Introduction on the qcow2 disk image file format
This article will show how to convert qcow2 disk image file to vdi Virtualbox disk image file. Before going further, it is important to know what is qcow2 disk image file actually is. It is a type of file format for disk image files. The disk image file itself is a representation of fixed size block device in a file. The type of file format are the format that QEMU supports. Furthermore, QEMU is a hosted virtual machine monitor that stands for “Quick Emulator”. It helps server to perform hardware virtualization. It is a free and an open-source emulator. Back to the qcow2 disk image file format, it is a format uses a disk storage optimization strategy that delays allocation of storage until it is actually needed.
Introduction on the vdi disk image file format
On the other hand, vdi disk image file format is a format that Virtualbox supports. To be more specific, Virtualbox is a free and open-source hosted hypervisor. It is a program for open-source virtualization runs on a PC or desktop. The file format that Virtualbox supports for the disk image files has a .vdi extension. While on the other hand, qcow2 is an extension for disk image file runs with the help of QEMU. So, the main point on this article is to show how to convert the qcow2 disk image file to a vdi disk image file. One of the main reason is to run the virtual machine in Virtualbox with the vdi extension disk image file. And it is a lot easier to use a virtualization program running in a PC or desktop to run a virtual machine.
How to Convert the file ?
In order to convert the file, this article will demonstrates on how to do it in a Linux-based operating system. Below are the steps for converting the file :
1. Check the tool or the program to convert the disk image file. It is available on the operating system or not. The tool or the program is ‘qemu-img’. Below is an example on how to check the tool or program availability in Linux Ubuntu operating system distribution :
Check the full path of the tool or program location by executing the following command pattern :
For an example in this article context :
user@hostname:~$ which qemu-img /usr/bin/qemu-img user@hostname:$
After founding the full path of the tool or program, check the original package name that actually has the ‘qemu-img’ command to execute the tool or the program. The following is the command :
dpkg -S full_path_of_command_tool_or_program
In this article context, the command execution shows below :
user@hostname:~$ dpkg -S /usr/bin/qemu-img qemu-utils: /usr/bin/qemu-img user@hostname:~$ apt show --names ^qemu-utils$
Finally, using the package name as in the above output shows, check whether the program is exist and it is available :
user@hostname:~$ apt-cache search ^qemu-utils$ qemu-utils - QEMU utilities user@hostname:~$ apt search ^qemu-utils$ Sorting... Done Full Text Search... Done qemu-utils/bionic-updates,now 1:2.11+dfsg-1ubuntu7.7 amd64 [installed,automatic] QEMU utilities
user@hostname:~$ apt list --installed | grep qemu-utils WARNING: apt does not have a stable CLI interface. Use with caution in scripts. qemu-utils/bionic-updates,now 1:2.11+dfsg-1ubuntu7.7 amd64 [installed,automatic] user@hostname:~$
Although the above steps are effective to check the availability of a tool or program, there is another simple way to do it. Just type the program in the command line as follows :
user@hostname:~$ qemu-img qemu-img: Not enough arguments Try 'qemu-img --help' for more information user@hostname:~$
2. The next step, it is an important step. Execute the command to convert the disk image file using the following command pattern :
qemu-img convert -O vdi qcow_file_name.qcow2 vdi_file_name.vdi
For an example :
user@hostname:~$ qemu-img convert -O vdi gnome.qcow2 gnome.vdi user@hostname:~$
3. Last but not least, try to use it in the Virtualbox. See if the vdi disk image file attached to the running virtual machine actually runs well.