Compact an encrypted VDI file?

This is for discussing general topics about how to use VirtualBox.
Post Reply
PeterE
Posts: 48
Joined: 10. Dec 2012, 16:13
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Arch Linux, Windows

Compact an encrypted VDI file?

Post by PeterE »

I am testing the encryption of VB Linux guests. Now I found a problem: I want to compact the VDI file (VBoxManage modifymedium --compact Filename.vdi) but because the disk is encrypted it cannot be done.
I found the old ticket #14977 about the same problem. At the end someone suggested a workaround. My question is if a newer solution is known?
Last edited by mpack on 1. Oct 2023, 11:26, edited 1 time in total.
Reason: Add link to ticket.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Compact an encrypted VDI file?

Post by mpack »

You can't compact an encrypted drive.

Dumb compaction works by eliminating zeroed blocks. Encrypted drives have randomized contents, so no zero blocks.

Smart compaction works by examining the guest filesystem and detecting unused areas due to deleted files. Again not possible on an encrypted drive: external tools can't read the filesystem or anything else. Obviously, if some tool could bypass the encryption then actually the drive is not encrypted.

Encrypted drives will also not be very compressible due to their randomized content.

Generally: don't count on being economical with disk space if you use encryption at VM level.
Post Reply