How to Convert the IMG files to VirtualBox Vdi format

Today I will show you how easily convert the IMG files to Virtualbox VDI format.
Oracle VM VirtualBox is a virtualization software that allows additional guest operating systems to be loaded and run, each with its own virtual environment, on top of the host operating system of your computer. It is widely used by many users and businesses every day to test new projects, operating systems and especially to run applications that are not originally developed for the host operative system.

VirtualBox can load an ISO image file or directly a CD/DVD in order to install a guest operative system, like Linux, Microsoft Windows, etc., but it doesn’t currently support images saved in IMG format (normally used to create USB pendrive). Therefore, to use them it is necessary to convert the IMG files to Virtualbox VDI format (Virtual Desktop Infrastructure).
In order to convert the IMG files to Virtualbox VDI format we will use VBoxManage, a tool developed by Oracle and included by default in VirtualBox, with which we can resize the virtual machine, change the resolution, and so on.
To convert the IMG files to VirtualBox VDI format in Linux is very simple; just type:
VBoxManage convertdd NameOfIMGFile.img NameOfTheVirtualMachine.vdi
To convert the IMG files to VirtualBox VDI format in Microsoft Windows, the process is the same, but you must specify the full path to the files. Open the Command Prompt and type:
cd c:\Program Files\Oracle\VirtualBox\
Or whatever other path where you have installed VirtalBox and execute:
VBoxManage.exe convertdd "filepath\NameOfIMGFile.img" "filepath\NameOfTheVirtualMachine.vdi
For example, if you have a Gentoo image in “C:\VirtualMachines” and you wanto to save the VDI in the same folder, type:
VBoxManage.exe convertdd "C:\VirtualMachines\Gentoo.img" "C:\VirtualMachines\GentooVM.vdi"
Once you created the VDI file, just create a new virtual machine and when you get to the “Hard Drive” window, select “Use an existing virtual hard drive file” and select the VDI file you created earlier.
If you are interested, there is also a guide on how to convert Vmware files to VirtualBox Vdi format.