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
  • 2
  • 9

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.*
u1686_grawity
  • 426,297
  • 64
  • 894
  • 966