Skip to content

Snapshots are sometimes created on unmounted datasets and then never deleted #61

@jmdavis

Description

@jmdavis

TLDR: I have a dataset which is not mounted (and can't be mounted) which gets snapshots which are never deleted, but I also have other datasets which aren't mounted and can't be mounted which don't get snapshots. The fact that some of them don't get snapshots is not a problem, but the fact that I have one which does - and then those snapshots are never deleted - is a big problem.

I think that the problem only occurs with datasets which aren't mounted and which both have parents and children which are mounted.

It also looks like this might be a Linux-specific problem, since I'm seeing it on two different Linux systems but not when I tried it on FreeBSD.

More details:

On a couple of my systems, I have (reduced to the relevant datasets):

NAME                                                      CANMOUNT  MOUNTED  MOUNTPOINT
zroot                                                     on        no       none
zroot/ROOT                                                off       no       none
zroot/ROOT/2025-07-26_update                              noauto    no       /
zroot/ROOT/default                                        noauto    yes      /
zroot/home                                                on        yes      /home
zroot/home/jmdavis                                        on        yes      /home/jmdavis
zroot/home/jmdavis/.local                                 on        yes      /home/jmdavis/.local
zroot/home/jmdavis/.local/share                           off       no       /home/jmdavis/.local/share
zroot/home/jmdavis/.local/share/virtualenvs               on        yes      /home/jmdavis/.local/share/virtualenvs
zroot/var                                                 off       no       /var
zroot/var/tmp                                             on        yes      /var/tmp

As shown, zroot/ROOT isn't mounted, can't be mounted, and doesn't have a mountpoint. It's not getting snapshots from zfs-auto-snapshot.

zroot/ROOT/2025-07-26_update can be mounted, but since it isn't my current boot environment, it isn't mounted. It's not getting snapshots from zfs-auto-snapshot.

In both cases, it's possible that zero size snapshots are being created and then deleted (I don't know enough about how zfstools' zfs-auto-snapshot works to say), but as I understand it, the fact that I don't see any snapshots there is the expected behavior.

zroot/ROOT/default is my current boot environment, so it's mounted and getting snapshots from zfs-auto-snapshot. So, both of those boot environments are getting (or not getting) snapshots as expected, and their parent is not getting snapshots - as expected.

The problem is zroot/home/jmdavis/.local/share. It's not only unmounted, but its canmount property is set to off, so it's never mounted. It's just there for the hierarchy. zroot/home/jmdavis/.local/share/virtualenvs is then mounted.

So, as I understand it, what should be happening is that zroot/home/jmdavis/.local/share/virtualenvs should be getting snapshots, whereas zroot/home/jmdavis/.local/share should not be. However, they're both getting snapshots. That in and of itself isn't the end of the world even if it's undesirable. However, the real problem is that none of the snapshots for zroot/home/jmdavis/.local/share are ever deleted. Months and months of snapshots just pile up unless I delete them myself.

So, for some reason, this particular dataset is getting snapshots even though it's not mounted, and presumably, because it's not supposed to be getting snapshots, the logic to delete snapshots then skips it.

I tried to fix this by explicitly setting com.sun:auto-snapshot to false on zroot/home/jmdavis/.local/share and setting it to true on zroot/home/jmdavis/.local/share/virtualenvs (instead of just inheriting it as true from the parent datasets), but that doesn't fix the problem. They both continue to get snapshots.

If I set it to false on zroot/home/jmdavis/.local/share and let zroot/home/jmdavis/.local/share/virtualenvs inherit it, then neither gets snapshots (but of course, I want snapshots on zroot/home/jmdavis/.local/share/virtualenvs, so that isn't a solution). So, zfs-auto-snapshot seems to pay proper attention to com.sun:auto-snapshot=false on the parent dataset so long as the child dataset doesn't set it to true.

My best guess at the moment is that the problem is that datasets which aren't mounted, but their parent is mounted, and their children are mounted, aren't handle properly, but I don't know.

For testing, if I create zroot/home/jmdavis/.local/foo/bar or (with foo not being mounted, and bar being mounted), then it also has the same problem. foo gets snapshots when it shouldn't. The same happens if I put the datasets in .config instead of .local, so it's not something special about my .local directory.

I also tried creating zroot/var/tmp/foo/bar (with foo not being mounted, and bar being mounted), and the same thing happened, so it's not something special about my home directly. However, it did not happen when I tried it with zroot/var/foo/bar. But zroot/var is canmount=off, so that's probably why. It's just the datasets with canmount=off whose parent and children have canmount=true which seem to have the problem.

I also tried setting com.sun:auto-snapshot to false on a parent dataset which was mounted and to true on its child dataset, and that worked correctly. The parent didn't get snapshots, but the child did. So, that logic seems to work in general - just not when the parent dataset isn't mounted and both its parent and child are.

I have this same problem on two different systems, both of which are running Debian 12. However, if I create zroot/home/jmdavis/.local/foo/bar or zroot/home/jmdavis/.config/foo/bar on one of my FreeBSD systems (and make it so that foo isn't mounted), then I don't see this problem. So, it at least appears that this issue is somehow Linux-specific, though I have no clue how that would be, since the zfs commands should be the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions