Skip to Main Content

Developer Community

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ZFS zero out unused blocks, initialization does not work

Nem AdokMay 11 2025 — edited May 11 2025

I have an OmniOS VirtualBox VM and i'd like to compact the VDI. The problem is i cannot force ZFS to overwrite unused blocks with zeroes to make compact work.

I've already wrote set zfs:zfs_initialize_value=0 into /etc/system and then did zpool initialize rpool. This worked once. But now the pool is already initialized and i cannot re-initialize it, because unlike OpenZFS, this implementation lacks the -u flag for zpool initialize and thus, i cannot redo this to zero out the unused blocks.

I've disabled compression and deduplication via zfs set compression=off rpool ; zfs set dedup=off rpool and tried to do dd if=/dev/zero of=/tmp/whatever bs=16M ; rm /tmp/whatever, to no avail as ZFS swalloved all the zeroes dd wrote out. I found this article (http://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSZeroBlockDiscarding) which explains that blocks that contains only zeroes will be discarded by ZFS anyway and there is no way to disable this.

So, i cannot re-initialize the pool and i cannot fill it with a zeroes-only file, to overwrite the unused places. I thought, i can fill the space with another pattern (with the usual 0xDEADBEEFDEADBEEF pattern to be specific) and then i will replace those blocks from outside before compacting, but ZFS swallowed this one too. After 3.3 GiB being written out, df -h / told me, that it is still only 985 MiB is being used. Despite deduplication and compression being disabled.

I am out of ideas, manuals and internet searches. Whatever manual or forum/github/whatever topic i read, the suggested solution is either zpool initialize -u rpool ; zpool initialize rpool, or zfs set compression=off rpool ; zfs set dedup=off rpool ; dd if=/dev/zero of=/tmp/whatever bs=16M ; rm /tmp/whatever and neither works here.

Anyone have any idea what can i do? Anything is appreciated.

Comments
Post Details
Added on May 11 2025
1 comment
119 views