I have read How to create a virtual machine from a .img disk image? but here the goal is slightly different.
With a VirtualBox machine, I know how to:
- add a .vdi disk
- mount a .iso as a (read-only) Optical Drive
- convert a vdi => img and vdi => img with
VBoxManage internalcommands converttoraw test.vdi test.imgandVBoxManage convertfromraw --format VDI test.img test.vdi
Question: how to mount a .img as a read-only disk in VirtualBox, and boot on it?
Important: without having to rewrite a new .vdi file from the .img file, because my .img are often 50 GB large, so I'd like to avoid to rewrite everything with VBoxManage convertfromraw and avoid using 100 GB instead of 50 GB.
Example situation: you have an internal disk with Linux on partition sda3. You create an image from another Linux with dd if=/dev/sda3 of=output.img. Now I would like to temporarily run (read-only) this Linux installation from output.img in VirtualBox.