Skip to main content
12 events
when toggle format what by license comment
Jan 21, 2020 at 5:37 comment added endolith I like how nobody's actually trying to answer your actual question and is just being pedantic. unix.stackexchange.com/q/458293/19012 is a similar question with actual answers
Oct 15, 2015 at 0:52 answer added Gilles 'SO- stop being evil' timeline score: 0
Oct 14, 2015 at 6:43 comment added cas the thing that you don't want to do (compression) IS the least hassle solution. anything else you will have to hack up yourself (e.g. read in a block at a time, discard the block if it's only NUL bytes) because there are no existing tools to do what you want (and, as i said, that's essentially impossible because it's file-system dependant).
Oct 14, 2015 at 6:39 comment added IQAndreas I appreciate the help, but stop trying to solve my exact problem, guys. I'm trying to learn a new skill (looping through a device block by block) that I can re-use outside of the exact situation I faced with right now. Just answer the question asked.
Oct 14, 2015 at 6:36 comment added cas partclone (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.
Oct 14, 2015 at 6:32 comment added cas what you are asking for (don't store blocks that contain no data) is file-system dependent. NULs are perfectly valid data in files and without the filesystem info there is no way to distinguish between blocks that just happen to be full of NULs and blocks that belong to a file that contains lots of NULs. Similarly, there's no way to distinguish between unused blocks that contain non-NUL data (e.g. that used to belong to a deleted file) and actual files.
Oct 14, 2015 at 6:27 comment added IQAndreas @Wildcard The question as I wrote it gets to the core of what I need to learn to continue; what I am trying to do is more complicated. Currently, the drive is using ZFS, but it used to be a different file system that was overwritten. I am trying to recover data from the old file system. In the process, I want to store an image of the block device, so I can recover it on a separate machine at a later time, but I don't want to store the blocks that contain no data. I do not want to compress the image.
Oct 14, 2015 at 6:25 comment added cas Does testdisk or photorec do what you want? (cgsecurity.org). If you are running debian, they are in the testdisk package. Probably packaged for other distros too. I presume you ultimately have some other task (like recovering files) beyond just getting the disk utilisation.
Oct 14, 2015 at 6:22 comment added IQAndreas @Wildcard I am very ready to check the drive bit by bit (in fact, that's what I was expecting to do, no way around it).
Oct 14, 2015 at 6:20 comment added Wildcard Did you try sudo blkid? That should tell you the filesystem type. (Or a filesystem type for each partition, if there is more than one.)
Oct 14, 2015 at 6:19 comment added Wildcard This would take a really really really long time, almost as long as copying the entire drive if it were completely full. Each bit on the drive would have to be checked. You really should find out what filesystem it is; with that data in hand, all that needs to be checked is the superblock, quickly, and you don't have to do it manually.
Oct 14, 2015 at 6:10 history asked IQAndreas CC BY-SA 3.0