I want to look at a raw block device (as in /dev/sda
) and know how much space is being used on the drive.
I don't know what type of file system is on the harddrive, nor do I have any way of figuring this out. A harddrive can obviously not be "empty", but what I do know is "empty space" is represented as bunch of zeroes (as in, output from /dev/zero
, not the ASCII character 0
).
How do I scan a block device, and then get an output telling me how many of the blocks are only filled with zero values?
sudo blkid
? That should tell you the filesystem type. (Or a filesystem type for each partition, if there is more than one.) – Wildcard Oct 14 '15 at 06:20testdisk
orphotorec
do what you want? (http://www.cgsecurity.org/). If you are running debian, they are in thetestdisk
package. Probably packaged for other distros too. I presume you ultimately have some other task (like recovering files) beyond just getting the disk utilisation. – cas Oct 14 '15 at 06:25partclone
(http://partclone.org) may do what you want...but will probably get horribly confused by the fact that the partition table has been changed because the disk is now being used by ZFS. – cas Oct 14 '15 at 06:36