reduce dd backup image (how to count used disk space)

view full story

http://stackoverflow.com – I use dd to backup full disk image which includes partition table and two ext3 partitions. Before create the image. My backup method is: dd if=/dev/zero of=/dev/sda # blank it, /dev/sda is a 2G bytes usb stick mount /dev/sda /mnt/sda cd /mnt/sda tar xf my_filesystem.tgz # only 5M bytes cd / umount /mnt/sda dd if=/dev/sda of=/mnt/sdb/sda.dd If count how many space exist on it, I could use dd's bs and count parameters to reduce the backup size. But how to count? (HowTos)