The workaround is straightforward: keep creating separate, differently-named zeroing files until the disk actually runs out of space. This effectively meant that offset results were limited to 2^31 bytes without special measures. This was common at the time because many file operations returned results in signed 32-bit integers, so that negative values could report error codes. If this occurs, you have most likely hit a 2GB file size limitation.
As a result, when attempting to consume all free space by writing a file of zeroes (which should always be done as root, to include root's privileged free space, which no one else can touch), you may see: In general, the techniques in the answers previously given are valid HOWEVER, there is a very important special case.įor a period of some years- perhaps 1997-2007 or so- 32-bit operating systems were still the norm, but hard disks larger than 2GB were already in use. IMPORTANT NOTE FOR LEGACY (~1997-2007) OPERATING SYSTEMS I left the links in the comments so you can (sort of) tell how it works.Įdit Well, after all that, I tried the CloneVDI tool and it did a good job in much less time and in one click. "C:\Program Files\Oracle\VirtualBox\VboxManage.exe" modifyhd "%%G" -compact ) (ref: debian wiki, lvm.conf example) devices. If LVM is in use, change the discard setting in /etc/lvm/lvm.conf. (ref: vbox forums, discard support) īoot the VM up, and verify that TRIM support is enabled: sudo hdparm -I /dev/sda | grep TRIM At this time discard is not in the GUI, but nonrotational is exposed as the "Solid-state Drive" checkbox. With VBox exited and no VMs running, add discard support to your disks by setting both discard and nonrotational for each disk in the config file for the VM. In theory, this will work for all Linux guests on VBox hosts using VDI storage.
The Arch Linux wiki has information about TRIM and dm-crypt devices. The Arch Linux wiki has a list of filesystems supporting TRIM operations.įDE and cryptoroot are specifically not covered, as there are security concerns and none of the other solutions to this question would allow compacting either. This solution requires a guest filesystem that supports continuous TRIM. Instead of periodically compacting the image, this solution uses discard to automatically remove unused blocks in the host's VM disk image. This isn't a direct answer per se, as I'm addressing the problem, not the question. Debian guest on Windows host using discard/TRIM.