Posts tagged: zfs
All posts with the tag "zfs"
zfs allow -u $USER clone,load-key,create,destroy,mount,mountpoint,receive,send,rollback,compression,snapshot,hold,keylocation,bookmark tank
load-key only needed if using encrypted datasets
Self-hosted Docker registry with proxy pull through
How I use Nextcloud for safe central storage
TL;DR
As the nextcloud docs say… if you want to write to an external volume that
location has to be writeable by the user/group www-data on the host system…
so if that makes sense to you then this TIL probably isn’t a ton of value.. if
not however, read on :)
Case Study
You want to self-host your own cloud and use a smart file system for convenience… Nextcloud and ZFS are pretty common goto answers for each of those problems.
My home NAS is built on ZFS and among other things I have a zpool named
tank and nested in there is a tank/nas dataset with several child zfs
datasets under that.
I want to use nextcloud mainly for auto-uploading photos from my wife’s and my phones for automatic backups.
The issue is that the nextcloud application (I run in Docker) is fixed as the
www-data user and so any volume/folder that you want nextcloud to write to
needs to be permissioned such that www-data owns it… but I don’t want
www-data to own everything in my NAS… so what’s a girl to do?
Solution
Well, one way to go is to just utilize docker volumes, write the data in the
container to /var/www/html and let that be the place your data backsup to.
I still wanted nextcloud to automatically write right to my NAS so I created a
nextcloud-upload directory inside of tank/nas/media/photos (photos cause
that’s all that gets automatically uploaded)
Then I chown -R www-data:www-data /tank/nas/media/photos/nextcloud-upload so
that just that sub-folder is owned by www-data. Now everyone’s happy!
As I was cleaning up my NAS recently I noticed that I ran out of storage even though my disk usage looked pretty low… turns out I was keeping a mega-ton of ZFS snapshots and due to my own ignorance at the time didn’t realize the storage cost of this!
zfs list-o space tank/home will show the disk usage of the dataset and snapshots in tank/home
I started my homelab journey being super naive about ZFS and how to manage the
filesystem… that bit me in the butt when transfering a ton of files out of
folders and into datasets because ZFS is copy on write so I was essentially
duplicating my storage until I got a hair smarter about removing files after
they’re moved (rsync –remove-source-file ftw). But I had a ton of snapshots of
child datasets with a ton of data that I just never will need, so I learned
zfs list -H -o name -t snapshot tank/dataset1/dataset2 will list just the
snapshots for dataset2 and if you pipe that into xargs -n1 zfs destroy then
you have a way to clear out some snapshots you don’t need!