0

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.

  • This seems like a really poor way to go about backups. This produces a significant amount of strain on the SD card, for little actual benefit. – Jacobm001 Mar 13 '16 at 18:08
  • Strain would be minimal if you're just zeroing unused non-zero blocks, which I believe is what zerofree does. The catch is you can't easily do it to your root filesystem. – db2 Mar 13 '16 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.