1

convertfromraw can be used to produce a dynamically sized VDI file. Does it process unallocated disk space?

For example, say /dev/sda points to a 1 TB hard drive with partitions on the first 10 GB and the rest unallocated. Running the following command,

VBoxManage convertfromraw /dev/sda MyDisk.vdi --format VDI
  • is the entire 1 TB disk processed?
  • is the resulting file ~ 10 GB or ~ 1 TB?
1

1 Answer 1

1

Convertfromraw has no idea what sectors the guest OS uses or doesn't use, so the virtual image will contain the entire source disk. In fact the source file can be anything - it doesn't even have to be a disk image.

The only space optimization is that large chunks (>1MB) that are filled with zero bytes will merely be flagged as zero and not written to the target file. This is a simple form of lossless compression, perhaps resembling simplified run-length encoding.

This is the same mechanism that causes VDI files to get smaller if you zerofill/sdelete and then clone them.

To minimize the size of the VDI file, you should therefore zero all the unused sectors on the source disk before doing convertfromraw. Defragmenting (if possible) all used sectors to the beginning of the disk will also help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .