I've got a ~32 GB ext4 root partition on my pi2 (Raspbian wheezy), and I'd like to zero the free space on a periodic basis (maybe every few weeks) so that SD card backups compress more easily.
I know you can use zerofree to do this, which requires either unmounting or remounting r/o, so it's not particularly suitable for automation. There's also the
dd if=/dev/zero approach, which isn't ideal, since you're effectively writing to nearly the entire card (and given the pi's I/O speed, I'm sure it wouldn't be all that quick on a 32 GB partition).
Any other ways to do this? It seems like something that ought to be unintrusive enough to do it on a r/w filesystem; you're just wiping blocks that aren't allocated anyway. There would be concurrency issues to contend with, but I can't imagine there aren't some kernel/filesystem hooks for reserving a block temporarily without allocating it.