I have a FreeBSD system installed in VirtualBox and i want to compact its vdi. AFAIK, before doing this i need to fill unused space with zeros so VirtualBox can shrink it.

On Windows there is sdelete utility, that does exactly this. What can be used on FreeBSD?


The usual method – also used by sdelete – is to fill the disk with files containing only null bytes:

dir="/" i=0

while dd if=/dev/zero of="$dir/empty.$((++i))" bs=8M count=128; do
    echo "wrote empty.$i"


rm -f /empty.*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.