Re: Zero-clearing all zero-clearable bytes.

From: Henrique de Moraes Holschuh
Date: Sun Nov 23 2008 - 06:25:35 EST


On Sun, 23 Nov 2008, Tetsuo Handa wrote:
> What I wanted to do is "Zero-clearing *all zero-clearable* bytes".

Other than acessing the fs directly with something fs-specific that knows
how to do it, the following trick comes to mind:

1. compress all files to a tar.bz2.
2. remove all files
3. zero fs using dd to a file (will zero all blocks except for the ones used
by the tar.bz2
4. unpack tar.bz2
5. remove tar.bz2
6. redo the dd trick. This will now zero all blocks that were in use by
the tar.bz2.

Of course, this only works if the (kernel, glibc, tar) are not writing
random junk to the unused parts of a fs block.

The cost is from 1 to 3 rm'ed inodes left behind. If you use two
filesystems (i.e. tar to outside the filesystem), you avoid that
possibility.

> I wished there is a utility to zero-fill such bytes.

So do I. And a IOCTL/syscall/whatever that we could use to sanitize (i.e.
fill with an user-supplied byte) half-used blocks, so that we could have it
on the most used filesystems (ext2, ext3, xfs, reiser...), and that we could
implement scrub-erasing of unused filesystem areas properly.

--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/