1

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.img and VBoxManage 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.

Basj
  • 1,489
  • 7
  • 47
  • 90
  • 1
    _Maybe_ you could wrap it in a VMDK file without rewriting? But I'm not sure about the read-only part. Optical drive won't work I think, because optical disks need an ISO-9660 or UDF filesystem. – gronostaj May 17 '22 at 12:36

0 Answers0