Accessing ZFS snapshots

Suppose you use ZFS and have pool/foo mounted at /foo.

zfs create -o mountpoint=/foo pool/foo

Suppose you’ve created a snapshot:

zfs snapshot pool/foo@bar

Now they tell you that you can access it inside .zfs/snapshot directory. However, if you go into /foo and type ls -la (option ‘a’ means you want to see files and directories beginning with a dot), you don’t see the .zfs directory. You’ll see ‘.’ and ‘..’ and all others, but not ‘.zfs’. However, an innocent ‘cd .zfs’ or ‘cd /foo/.zfs’ will get you there. A truly hidden directory indeed.

What was it called at esr’s The Art of Unix Programming? The Principle of Least Surprise?


Author: automatthias

You won't believe what a skeptic I am.

4 thoughts on “Accessing ZFS snapshots”


    I was looking for this “hidden” directory all this time !!

  2. The principle of least surprise applies to software interaction as well as user interaction, and in fact in the former case is far more important. For example, the thousands of backup scripts running in the wild should not have to cope with the surprise of a .zfs directory that contains multiple copies of the same data it’s trying to copy in addition to the actual current data, appearing at seemingly-random points throughout the filesystem.

    You see, it’s the creation of millions of duplicated block-level hardlinks in the underlying implementation of a filesystem, and then having them pollute the filesystem at the user-space level that’s actually surprising. Even reserving a top-level filesystem path for this metadata is either a violation of the principle of least surprise or an OS-specific solution, so the only true alternatives to maximum-stealth-exposure are providing a non-filesystem API (probably the worst option possible) or just not letting you access it at all (still only the second worst option, ironically).

    You, on the other hand, can adapt easily, or in failing to do so lose no benefit or functionality from any pre-existing habits or unrelated expectations.

Comments are closed.