Thicket data repository for the EEG
1{
2 "id": "https://www.tunbury.org/2025/05/02/zfs-send-streams",
3 "title": "ZFS Send Streams",
4 "link": "https://www.tunbury.org/2025/05/02/zfs-send-streams/",
5 "updated": "2025-05-02T20:00:00",
6 "published": "2025-05-02T20:00:00",
7 "summary": "We often say that ZFS is an excellent replicated file system, but not the best local filesystem. This led me to think that if we run zfs send on one machine, we might want to write that out as a different filesystem. Is that even possible?",
8 "content": "<p>We often say that ZFS is an excellent replicated file system, but not the best <em>local</em> filesystem. This led me to think that if we run <code>zfs send</code> on one machine, we might want to write that out as a different filesystem. Is that even possible?</p>\n\n<p>What is in a ZFS stream?</p>\n\n<div><div><pre><code>fallocate <span>-l</span> 10G temp.zfs\nzpool create tank <span>`</span><span>pwd</span><span>`</span>/temp.zfs \nzfs create tank/home\n<span>cp </span>README.md /tank/home\nzfs snapshot tank/home@send\nzfs send tank/home@send | hexdump\n</code></pre></div></div>\n\n<p>I spent a little time writing an OCaml application to parse the record structure before realising that there already was a tool to do this: <code>zstreamdump</code>. Using the <code>-d</code> flag shows the contents; you can see your file in the dumped output.</p>\n\n<div><div><pre><code>zfs send tank/home@send | zstreamdump <span>-d</span>\n</code></pre></div></div>\n\n<p>However, this is <em>not</em> like a <code>tar</code> file. It is not a list of file names and their content. It is a list of block changes. ZFS is a tree structure with a snapshot and a volume being tree roots. The leaves of the tree may be unchanged between two snapshots. <code>zfs send</code> operates at the block level below the file system layer.</p>\n\n<p>To emphasise this point, consider a <code>ZVOL</code> formatted as XFS. The structure of the send stream is the same: a record of block changes.</p>\n\n<div><div><pre><code>zfs create <span>-V</span> 1G tank/vol\nmkfs.xfs /dev/zvol/tank/vol\nzfs snapshot tank/vol@send\nzfs send tank/vol@send | zstreamdump <span>-d</span>\n</code></pre></div></div>\n\n<p>ZVOLs are interesting as they give you a snapshot capability on a file system that doesn’t have one. However, some performance metrics I saw posted online showed disappointing results compared with creating a file and using a loopback device. Furthermore, the snapshot would only be in a crash-consistent state as it would be unaware of the underlying snapshot. XFS does have <code>xfsdump</code> and <code>xfsrestore</code>, but they are pretty basic tools.</p>\n\n<p>[1] See also <a href=\"https://openzfs.org/wiki/Documentation/ZfsSend\">ZfsSend Documentation</a></p>",
9 "content_type": "html",
10 "author": {
11 "name": "Mark Elvers",
12 "email": "mark.elvers@tunbury.org",
13 "uri": null
14 },
15 "categories": [
16 "openzfs",
17 "tunbury.org"
18 ],
19 "source": "https://www.tunbury.org/atom.xml"
20}