winnielinnie
MVP
- Joined
- Oct 22, 2019
- Messages
- 3,641
Prerequisites:
The Test:
The reason for this test:
I'm trying to gauge if block-cloning in OpenZFS 2.2 works with ZFS snapshots, in that it will simply reference the existing blocks.
This already works on a dataset's live filesystem.
But what if it works across a snapshot? This means you can restore individual files without consuming additional space. (Currently, when someone restores a single file, there are duplicate records that are referenced separately. Blocks pointed at from the file in the snapshot PLUS blocks pointed at from the "restored" file in the live filesystem. This is more noticeable for large files.)
Here is an earlier discussion before block-cloning was available for ZFS:
www.truenas.com
Can you see why this would be a stellar feature?
WARNING: Please double and triple check your commands. There's no need to accidentally destroy important data just for this test. If you don't feel comfortable, don't even bother. (I could try this on a VirtualBox VM, but I figured it's a bit excessive just to literally test out a single command.)
- You have TrueNAS SCALE Cobia
- Your ZFS version is 2.2.0 (-rc4 or whatever, doesn't matter)
- You are comfortable creating a temporary dataset for this test (you will delete the dataset when you're done)
The Test:
- Create a new temporary dataset with the default options
- Inside its path (e.g, /mnt/tank/temporary/) create a large 4 GB file
- (You can either use dd with /dev/urandom or copy a large video file)
- Create a snapshot for the dataset
- Delete the large 4 GB file from the live filesystem
- Notice that the dataset still consumes 4 GB because of the snapshot?
- Now copy (using "cp") the 4 GB file from the hidden snapshot "directory" back to your live filesystem
- (What happens if you invoke
--reflink=always
in your cp command?)
- (What happens if you invoke
- How much space does your dataset now consume? 4 GB or 8 GB?
- Bonus: What happens if you destroy the snapshot?
The reason for this test:
I'm trying to gauge if block-cloning in OpenZFS 2.2 works with ZFS snapshots, in that it will simply reference the existing blocks.
This already works on a dataset's live filesystem.
But what if it works across a snapshot? This means you can restore individual files without consuming additional space. (Currently, when someone restores a single file, there are duplicate records that are referenced separately. Blocks pointed at from the file in the snapshot PLUS blocks pointed at from the "restored" file in the live filesystem. This is more noticeable for large files.)
Here is an earlier discussion before block-cloning was available for ZFS:
Can ZFS even *do* this? (Restore *file*, not rollback, an *entire* snapshot)
We all know we can revert a dataset to a previous snapshot. It's like hitting the "undo" or "rewind" button. Simple enough. Now you have your dataset as it was, record-by-record, in a previous state. Everything you deleted is restored 100%, as long as it lived on the snapshot. No additional...

Can you see why this would be a stellar feature?
WARNING: Please double and triple check your commands. There's no need to accidentally destroy important data just for this test. If you don't feel comfortable, don't even bother. (I could try this on a VirtualBox VM, but I figured it's a bit excessive just to literally test out a single command.)
Last edited: