ZFS snapshot on lxc

plokko

Active Member
Jul 27, 2018
18
7
43
37
Is it possible to take zfs snapshot on an unprivileged LXC container?

I created a samba service in an LXC container as it's more lightweight and even if the VM cannot boot i can simply copy the file from the bind mount from the PVE host without the hassle of mounting virtual disks, etc. (minor inconvenience).
The PVE server does run on ZFS and for that reason i'm trying to avoid VMs as i do not like emulating ZFS over ZFS or adding phisical drives dedicated to the samba service (the actual drives are shared between various VMs).

The samba service is working fine, i even added cockpit for managing from UI, but i wanted to add shadow copies for file versioning.
Example config:
Code:
shadow:snapdir = .zfs/snapshot
shadow:sort = desc
shadow:format = %Y-%m-%d-%H%M%S

Can the lxc as an unprivilege container create ZFS snapshots?
If not can the lxc container read a snapshot created by the PVE host?
 
I actually did it from the PVE:
  • I added a new mount point to the lxc
  • I created the share with shadow snapdir as the first post and used the mounted disk as folder
  • i created a new snapshot from PVE with:
    Bash:
    zfs snapshot -r data/subvol-104-disk-0@$(date '+%Y-%m-%d-%H%M%S')
    (the new mountpoint was disk-0 on vm 104 in data pool)
I can now correctly see the snapshot in the menu!
I now should automate it and clean-up old snapshots but it's a great start!
 
Last edited:
ZFS delegation into containers is merged in LXD, based on namespace delegation support. This is similar to the approach that was done in FreeBSD, where you can create datasets and manage your own datasets from within an LX(C) container. With that feature you can do whatever you want with your dataset including snapshotting and rollback. We wil see how long it'll take to be in PVE an if everything works correctly, yet I'm optimistic
 
Last edited:
  • Like
Reactions: bartekchlebek
Is it currently possible to take zfs snapshots from a priviliged container?
 
ZFS delegation into containers is merged in LXD, based on namespace delegation support. This is similar to the approach that was done in FreeBSD, where you can create datasets and manage your own datasets from within an LX(C) container. With that feature you can do whatever you want with your dataset including snapshotting and rollback. We wil see how long it'll take to be in PVE an if everything works correctly, yet I'm optimistic
Do you know how the work is going on this?
 
Hello,
I just found this topic and read a bit about the "ZFS delegation". Apparently, it is already available in LXD.
Is it somehow possible to use it in Proxmox LXC as well?
It would be really fancy if it was possible to manage the ZFS datasets, quotas and the like from within a LXC container. The use case why I would like to do this is because I also have set up a SMB/CIFS filer, and the snapshots and so on work great, but it would be even nicer if it was possible to manage the snapshots from within the LXC, and not from the host.
 
Hello,
I just found this topic and read a bit about the "ZFS delegation". Apparently, it is already available in LXD.
Is it somehow possible to use it in Proxmox LXC as well?
It would be really fancy if it was possible to manage the ZFS datasets, quotas and the like from within a LXC container. The use case why I would like to do this is because I also have set up a SMB/CIFS filer, and the snapshots and so on work great, but it would be even nicer if it was possible to manage the snapshots from within the LXC, and not from the host.
I don't know what the status is in PVE for inline management, but here is my experiment:

https://gist.github.com/copecog/08996b55827329e31c6d21ccbec45081
 
  • Like
Reactions: Mrt12 and LnxBil

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!