1

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?

arrowd
  • 288

1 Answers1

2

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"
done

sync

rm -f /empty.*
grawity
  • 501,077