NFS Server on Proxmox - Terraform

MCSAntunes

New Member
May 8, 2023
2
0
1
Hello, everyone! First-time poster here.

I'm looking to share my ZFS pool (mounted on /storage on the host) via NFS/SMB so it can be accessed in my multiple VMs.
After some research, I decided on creating an NFS server within a CT.

As I'm learning Terraform I decided to use it to provision this CT and all my future VMs.

After I run terraform init I get a 403 Permission check failed (mount point type bind is only allowed for root@pam) error. You can find the Terraform files and the complete error message at the end of this post.

I've tried to create a CT without the mountpoint option and it worked fine, so I guess the API token was correctly generated. It was generated for the root@pam user.

I'll use this post as well to ask if there are any better ideas on how to share my storage via NFS/SMB and if there are any guides available.

Thank you very much and let me know if there are any other thing that I can provide that can help you help me.

Code:
terraform {
  required_providers {
    proxmox = {
        source = "telmate/proxmox"
    }
  }
}

provider "proxmox" {
    pm_tls_insecure = true
    pm_api_url = "***"
    pm_api_token_id = "***"
    pm_api_token_secret = "***"
}

resource "proxmox_lxc" "file_server" {
    target_node = "pve"
    hostname = "lxc-file-server"
    ostemplate = "local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst"
    unprivileged = true

    ssh_public_keys = file("~/.ssh/id_rsa.pub")

    rootfs {
        storage = "local-lvm"
        size = "8G"
    }

    mountpoint {
        key = "0"
        slot = 0
        storage = "/storage/share"
        volume = "/storage/share"
        mp = "/mnt/container/share"
        size = "2T"
    }

    network {
        name = "eth0"
        bridge = "vmbr0"
        ip = "dhcp"
    }
}

Code:
proxmox_lxc.file_server: Creating...
╷
│ Error: error creating LXC container: 403 Permission check failed (mount point type bind is only allowed for root@pam), error status: {"data":null} (params: {"arch":"amd64","cmode":"tty","console":true,"cores":1,"cpulimit":0,"cpuunits":1024,"features":"","hostname":"lxc-file-server","memory":512,"mp0":"/storage/share,size=2T,backup=0,mp=/mnt/container/share","net0":"ip=dhcp,name=eth0,bridge=vmbr0","onboot":false,"ostemplate":"local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst","password":"qwerty","protection":false,"rootfs":"local-lvm:8","***","start":false,"storage":"local","swap":0,"tags":"","tty":2,"unprivileged":true,"vmid":100})
│
│   with proxmox_lxc.file_server,
│   on main.tf line 16, in resource "proxmox_lxc" "file_server":
│   16: resource "proxmox_lxc" "file_server" {
│
╵
 
if you really want to share a local mountpoint by nfs i'd go for the nfs server installed on localhost too.

apt install nfs-kernel-server
edit /etc/exports and you are in.

but why not just use the zfs as proxmox storage and create a guest (nfs server) using it (storing the virtual disks there)?

I see many posts here in the forum where people use local disks, mounts, passthrou that I dont understand why. PVE is about virtualization so use it's storage abilities. you win so much and overhead is minimal
 
if you really want to share a local mountpoint by nfs i'd go for the nfs server installed on localhost too.
I thought about doing this. But I've read that keeping my Proxmox install as clean as possible is a good practice.

but why not just use the zfs as proxmox storage and create a guest (nfs server) using it (storing the virtual disks there)?
Not sure if I understand what you mean here.
Do you suggest using the ZFS storage as a disk for my CT/VM? Would I be able to access and share the whole storage?

Thanks for the reply.
 
I thought about doing this. But I've read that keeping my Proxmox install as clean as possible is a good practice.


Not sure if I understand what you mean here.
Do you suggest using the ZFS storage as a disk for my CT/VM? Would I be able to access and share the whole storage?

Thanks for the reply.
go to datacenter, define a local storage with your zfs pool, create a vm with a disk on this storage. install nfs in this vm.

any other vm can use this nfs export.
the nfs server is just one of many vms