Persistent storage on ZFS for LXC

Ansy

Active Member
Dec 20, 2018
46
7
28
52
Hello, friends!

I need your professional recommendation or best practice advice.

Well, I've fresh Proxmox installation fully on ZFS mirror of two HDDs. Some VMs and CTs created, etc... all works well.

Then, I want to make a CT for backups (restic/borgbackup/rsync), general file storage (Samba/NFS/WebDAV/FTP/SFTP), mediaserver (DLNA, Emby/Kodi/...) -- so, after some tests I choose a template TurnKey MediaServer. Installed, it works well too.

I see, default storage directory is /srv/storage (and /home) of CT's main local-zfs volume of some size (8GB now). But if I'll destroy this CT (accidentially or by other reason) I'll loose all content of my saved data! Thus, I need some method to attach external volume/storage to my CT -- external to CT, but internal to Proxmox host.

So, what is the best way to do it? Another ZFS pool? NFS/Samba share on Proxmox host? Some directory of existent local-zfs storage or local storage (ZFS too)?

How should I attach it to MediaServer CT safe and fast way, but with great chances to get my stored data back if got any damage to CT?

Thanks in advance for any thoughts/links.
 
Last edited:
Hi,
it's not really necessary to create a new storage for the data (it doesn't hurt either, but there's no real reason if you don't plan to use it for things PVE needs to know about). What you are likely looking for are bind mounts. With a bind mount the container has access to the data below that mount point, but it doesn't belong to the container. In particular PVE won't remove the data when you delete the container. A new ZFS dataset is more clearly separated, but simply using a directory in your existing ZFS will do as well.
 
Yes... but NOT :(
I've created this one in storage.cfg
Code:
dir: Media
        path /rpool/storage
        content backup,rootdir,images,iso,vztmpl,snippets
        maxfiles 3
        shared 1

attached to VM 210.cfg
Code:
mp0: Media:210/vm-210-disk-0.raw,mp=/hdd,mountoptions=noatime,size=100G
rootfs: local-zfs:subvol-210-disk-0,mountoptions=noatime,size=8G

Well, I see /hdd directory in VM filesystem, I can write to it -- but I see no files, only image vm-210-disk-0.raw on Proxmox host node. But I need to see my files, as is. And later, if I delete binded volume from VM config, I loose all content -- it's not that I need too.

I need fast and transparent way to connect some storage directory from Proxmox host to LXC container filesystem to access files on it from VM and from elsewhere. Is there any way other than network share (SMB/CIFS, NFS) to get this task done?
 
Yes... but NOT :(
I've created this one in storage.cfg
Code:
dir: Media
        path /rpool/storage
        content backup,rootdir,images,iso,vztmpl,snippets
        maxfiles 3
        shared 1

attached to VM 210.cfg
Code:
mp0: Media:210/vm-210-disk-0.raw,mp=/hdd,mountoptions=noatime,size=100G
rootfs: local-zfs:subvol-210-disk-0,mountoptions=noatime,size=8G

Well, I see /hdd directory in VM filesystem, I can write to it -- but I see no files, only image vm-210-disk-0.raw on Proxmox host node. But I need to see my files, as is. And later, if I delete binded volume from VM config, I loose all content -- it's not that I need too.

I need fast and transparent way to connect some storage directory from Proxmox host to LXC container filesystem to access files on it from VM and from elsewhere. Is there any way other than network share (SMB/CIFS, NFS) to get this task done?

I'm guessing you used the GUI option Add>Mount Point. This creates a new volume and is not what you want here. Such a volume is "owned" by the container, so it will be deleted when you delete the container. This is different from a bind mount. For a bind mount you just need a locally mounted directory on the PVE host. Let's say you want to use /rpool/storage/shared and mount it as /shared inside the container Then you can set up a bind mount for your container by doing:
Code:
pct set 210 -mp0 /rpool/storage/shared,mp=/shared
 
For a bind mount you just need a locally mounted directory on the PVE host. Let's say you want to use /rpool/storage/shared and mount it as /shared inside the container Then you can set up a bind mount for your container by doing:
Code:
pct set 210 -mp0 /rpool/storage/shared,mp=/shared
Thanks, it's all I need!
Not all.. It would be wonderful to set it up in Web GUI also :)
 

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!