[TUTORIAL] lxc mount zfs pool

hifloh

New Member
Apr 12, 2024
6
1
3
I want to share the results of me trying to mount multiple zvols in an lxc container to share them using smb/nfs/sftp
The command outputs are trimmed to only include the relevant parts.

Goal:
Gounting ZFS-Pool into lxc Container.

Prerequisites
  • Proxmox VE 8.2.2
  • Container 102 (to mount to)
  • A Zpool
    Code:
    $ zfs list
    NAME        MOUNTPOINT
    tank        /tank
    tank/zvolA  /tank/zvolA
    tank/zvolB  /tank/zvolB


While researching I found 2 ways to do it.
  1. Mount point
    Mount points are the Proxmox way of mounting local folders inside a container and should always be preferred. Sadly mount points do not support recursive mounts so we have to add a line for each zvol.
    Code:
    $ cat /etc/pve/lxc/102.conf
    mp0: /tank,mp=/mnt/tank
    mp1: /tank/zvolA,mp=/mnt/tank/zvolA
    mp2: /tank/zvolB,mp=/mnt/tank/zvolB
    when often creating new zvols this is a verry tedious solution.
  2. lxc.mount.entry
    for mounting all zvols using a single line we can use lxc.mount.entry
    Code:
    $ cat /etc/pve/lxc/102.conf
    mp0: /mnt,mp=mnt/tank
    lxc.mount.entry: /tank mnt/tank none rbind 0 0
    This has the same effect as the previous variant with the added benefit of no configfile edits for new zvols.
    The first line is only needed at the first start. There are some steps the mount point does that lxc.mount.entry don't.
    In the container the second line gets mounted.
 

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!