ZFS snapdir readability (Crosspost)

Jan Behrens jbe-mlist at magnetkern.de
Fri Nov 8 11:34:41 UTC 2019

> > I recently noticed that all ZFS filesystems in FreeBSD allow access to
> > the .zfs directory (snapdir) for all users of the system. [...]

On Thu, 7 Nov 2019 23:06:24 +0100
Peter Eriksson <pen at lysator.liu.se> wrote:

> The “easy” solution is to give each user (or group / project) their own ZFS filesystem. Then the “.zfs” directory would be inside the users own $HOME and you can set $HOME to 0700….
> That is what we are doing. Granted it generates a “few” filesystems (like some 20000 per server (we have around 120k users), and then add hourly snapshots to each as “icing” on the cake). Mounting all those takes a bit of time - but luckily with the latest FreeBSD release things are much faster these days :-)
> There are some other issues with that - like 100% full filesystems causing severe system slowdown during writes… So you really wanna have some monitoring system that warns for that.
> - Peter

This would also allow per-user deletion of snapshots, which may come in
handy in certain scenarios where making data only accessible by root is
not sufficient, such as legal requirements to delete some user's data.

However, it (currently) only works in those cases where the root of
each filesystem is chmod 700, i.e. where an entire filesystem hierarchy
is only readable by a single user. This makes sharing data between users
on those filesystems impossible.

I'd much prefer the proposal made by "Kevin P. Neal" <kpn at neutralgood.org> earlier in this thread, on Thu, 7 Nov 2019 10:19:23 -0500:

"Kevin P. Neal" <kpn at neutralgood.org> wrote:

> On Thu, Nov 07, 2019 at 09:54:11AM -0500, mike tancsa wrote:
> > 
> > Still, it would be a nice feature to have where .zfs could be set to
> > root only read.    In a multi user system, my users (me included) do all
> > sorts of accidental foot shooting things like making files readable for
> Or only readable to the owner of the top directory in the dataset? As
> an option.

In cases where users need to access their own snapshots, filesystems
for each user can be created. In cases where this is not necessary,
i.e. where I just want to make a root-readable backup (or replication
snapshot), a single command such as

zfs set snapdir=restrict_to_fs_owner /usr/home

would suffice. I prefer this a lot over having to create dozens (or
hundreds) of filesystems just to fix an issue with access rights.


More information about the freebsd-fs mailing list