ZFS Wipe free space

I'd imagine creating a file that uses up all of the available disk space would do the trick. Maybe something along the lines of:

Code:
dd if=/dev/random of=/zfs-pool/fill_file.dd
Delete the file when it's done to get your disk space back.
 
Keep in mind that ZFS is a copy-on-write filesystem. So these programs will not work (i.e. they won't overwrite old data).
 
Sorry guys, I'm not a file system expert by any means, but I'm trying to wrap my head around why the dd method wouldn't work. For example, say we have a 20 GB ZFS pool with 33% usage. I have a file called ssn_private_file. I delete the file using rm ssn_private_file and then issue dd if=/dev/random of=fill_free_space.dd and let it run until it eventually errors out with a out of disk space error. Now my current usage is 100% and I have exhausted all free space on the drive.

Where would the remnants of ssn_private_file reside?

If the file (and any other previously deleted file) was still was accessible on the drive, despite 100% disk usage, how would the file system be sustainable after several years of use?
 
If you have any snapshots of the filesystem where ssn_private_file was stored, then that file is still on disk as part of those snapshots.

As ZFS is a copy-on-write filesystem, writing random data to the pool won't overwrite the old data until near the end of the dd process. Depending on the bs= used, you may actually hose your pool due to spacemap fragmentation, and might end up not overwriting the block used by ssn_private_file. Also, if you fill the pool to 100%, you'll have other issues (like being unable to delete your fill_free_space.dd file). Plus, newer versions of ZFS reserve 3% of pool storage for admin purposes (to prevent the aforemention "can't delete due to full pool" issue), which means you may not overwrite the part of the pool that originally stored ssn_private_file).

Basically, all the "tricks" that you'd use with normal filesystem most likely won't work the way you think on ZFS.
 
Another example: Imagine your ssn_private_file is really tiny, say 100 bytes. Many file systems (perhaps also ZFS, don't know) will not actually store that file in a data area on disk, but will store it in the inode itself. Depending on file system design, files up to several Kilobytes can be stored in inodes. Now you come and write one new fill_free_space.dd. It will use one inode, but your file system has hundreds of thousands or millions of inodes that are free. Most likely, the inode containing the data is still on disk, and unallocated.

As phoenix said: In modern file systems (those with features like snapshots, CoW, multiple storage pools, policy-based allocation, built-in RAID or use of multiple devices, clustering, remote replication and so on), space allocation is way more complicated than filling all free space. If you want to securely erase a file, you need the cooperation of your file system, to locate all the places on disk where the file is stored (or was stored recently). I don't know whether ZFS has a feature like "secure erase an individual file".

And as was said above: If you really want to securely erase that file, and you can afford to take down the whole file system this file lived on, the best thing to do is to locate all physical devices that file system has used, and securely erase each one of them. That can be done with a variety of format commands, which are often hardware-specific (in particular on disks that are internally virtualized, like SSDs or RAID arrays).
 
Back
Top