The other day I downloaded a Linux operating system for testing. The downloaded OS image was in IMG format, and Oracle VirtualBox doesn't support the IMG format. So, I had to find a way to use IMG file in VirtualBox. After a bit of google search, I found a simple command to convert the IMG file to VDI file using Virtualbox in Linux.
What are VDI and IMG files?
VDI file, stands for Virtual Disk Image, is the default disk image file for VirtualBox. In layman terms, VDI is the virtual hard disk of a guest machine. Unlike physical hard disk, we can expand the size of virtual hard disk without losing any data. The disk image files can be created either in fixed size or dynamically allocated size.
IMG file, also known as Image file, that can be used to distribute the whole image of a disc. It is similar to ISO file. It is mostly useful for dumping the video games. We can mount the IMG files in the computer and play the games without having to burn them in a physical disk. Not just games, we can write operating system and applications in IMG format. IMG is the default disk image format for QEMU, an open source virtualization software.
Hope you got the basic idea about VDI and IMG files. Now, let us see how to convert IMG file to VDI file using VirtualBox.
Convert IMG file to VDI file With Oracle VirtualBox
You must install Oracle VirtualBox before starting to convert the IMG files. Oracle VirtualBox is a cross-platform virtualization software. It is available in the default repositories of many GNU/Linux operating systems.
Once VirtualBox installed, go to the location where you have downloaded the IMG file.
The syntax to convert a IMG file to VDI file is:
VBoxManage convertdd input.img output.vdi
$ VBoxManage convertdd eos-eos3.0-amd64-amd64.161024-144409.base.img eos.vdi
Replace the img file with your own file.
Converting from raw image file="eos-eos3.0-amd64-amd64.161024-144409.base.img" to file="eos.vdi"... Creating dynamic image with size 6012964864 bytes (5735MB)...
The image conversion will take a few moment depending upon the size of the image file. The resulting image file will be saved in the current working directory.
Download - Free Guide: "VirtualBox Essentials Guide"
Import VDI file in Oracle VirtualBox
Open Oracle VirtualBox. Click New on the Menu bar to create a new Virtual machine.
Enter the name of the virtual machine. I named it as "Test".
Next assign the Memory size to the Virtual Machine.
Here comes the important part. As we already have created the virtual hard file (VDI), you must select the option "Use an existing virtual hard disk file". Choose the VDI file location and click Create.
That's it. Now, start exploring the Virtual Machine.
This is only for .IMG formats? or can i converter .iso to .vdi?
Thanks for the post, you save me!
Thank you so much for this tip! It reaaaaally helped me a lot.
i get this error:
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.20.8-110.current) or it failed to
load. Please recompile the kernel module and install it by
You will not be able to start VMs until this problem is fixed.
Converting from raw image file=”batocera.img” to file=”batocera.vdi”…
Creating dynamic image with size 1992938496 bytes (1901MB)…
I use Solus
Note that converting an IMG file that has “multiple” partitions does work using this method. All partition info is lost. It simply creates a non-partitioned disk VDI file. i.e. /dev/sda
Thanks for the heads up.
You did not tell how to put the vdi file somewhere in the system. Seems it was converted but since no location was specified, Virtualbox cannot find it. Would have been more impressed if the .img file had been changed to a .vdi file. Impossible or not?
The VDI file will be saved in the current working directory. You need to manually choose the path of the VDI file to import it.