Host: Mount Samba share on Host

Storage & Share · Host~7 minView script

Mount an external Samba (SMB / CIFS) share — from a NAS, a Windows box, a TrueNAS SMB export — on the Proxmox host. Pick one or both methods: register it as Proxmox storage (visible in Datacenter > Storage) and/or add a plain /etc/fstab mount at a path you choose, with open uid/gid/file_mode so unprivileged LXCs can bind-mount and write without any changes inside the container.

What this does

ProxMenux offers two mount methods for a Samba share: (1) Proxmox storage via pvesm add cifs, visible in Datacenter > Storage and mounted at /mnt/pve/<id>. The password is stored as plaintext in /etc/pve/priv/storage/<id>.pw, protected by the root-only private directory; this is access control, not encryption. (2) Host fstab mount at a chosen path, persistent through /etc/fstab and mounted with uid=0,gid=0,file_mode=0777,dir_mode=0777 so unprivileged LXC bind mounts can write. Its credentials are in a root-only file under /etc/samba/credentials/, never directly in fstab. Either or both methods can be used.

Opening the tool

From ProxMenux's main menu, open Storage & Share Manager → Add Samba share as Proxmox Storage. You will see this sub-menu with four options (plus Exit):

Samba Host Manager menu — Mount / View / Remove / Test connectivity

How the script runs

The flow has two phases. Phase 1: discover server, validate credentials, pick share, then pick mount method(s) via a checklist. Phase 2: only the methods you marked are executed. Credentials are needed up-front because smbclient needs them to list shares. Until the final confirmation, neither /etc/pve/storage.cfg nor /etc/fstab are touched.

┌─────────────────────────────────────────────┐
│  PHASE 1 — Discover, validate, choose       │
│  (nothing touched yet)                      │
└──────────────────┬──────────────────────────┘
                   ▼
      Server discovery (nmap 139/445 + nmblookup)
                   │
                   ▼
      Authentication (User or Guest)
                   │
                   ▼
      Share selection (smbclient -L)
                   │
                   ▼
      ╔═════════════════════════════════════╗
      ║   MOUNT METHOD PICKER  (checklist)  ║
      ║   [ ] As Proxmox storage  (pvesm)   ║
      ║   [ ] As host fstab mount only      ║
      ║   (mark one or both — re-prompts    ║
      ║    if you press OK without marks)   ║
      ╚════════════════╤════════════════════╝
                       │
        ┌──────────────┴──────────────┐
        ▼                             ▼
   pvesm branch                  fstab branch
   ├─ storage ID                 ├─ mount path
   ├─ content types              ├─ mount options
                                 └─ (User) write
                                     /etc/samba/credentials/...cred
                                     (mode 0600)
   ▼                             ▼
   ┌─────────────────────────────────────────┐
   │  PHASE 2 — Apply (only marked methods)  │
   └──────────────────┬──────────────────────┘
                      ▼
   pvesm add cifs <id> ...    +  mkdir -p <path>
   (auto-mount at            mount -t cifs ...
    /mnt/pve/<id> with        (uid=0,gid=0,
    default options)           file_mode=0777,
                               dir_mode=0777)
                             append /etc/fstab
                             systemctl daemon-reload
                      ▼
              Summary printed

Mount method picker (two options, mark one or both)

After selecting the share and validating credentials, ProxMenux shows a checklist with the two mount methods. You can mark either, or both. If you press OK without marking anything, the dialog re-appears until you choose at least one option or press Cancel to exit the flow.

MethodMount pathVisible in Datacenter > StorageTypical use case
As Proxmox storage (pvesm)/mnt/pve/<storage-id> (managed by Proxmox)YesBackups, ISOs, LXC templates — anything that needs to appear in the Proxmox UI. Live VM disks are technically supported but discouraged on CIFS (locking semantics).
Host fstab only/mnt/<path> with open uid/gid/file_modeNoBind-mount the share into one or more LXCs without registering Proxmox storage. Open local permissions help unprivileged CTs access it, but writing still requires permission from the SMB server for the authenticated user.
BothBoth paths above (two mount points for the same CIFS export)YesYou want UI integration AND a stable host-side path with open permissions for LXC bind-mounts. The pvesm mount uses Proxmox defaults; the fstab mount applies the open uid/gid/file_mode separately.

“Both” creates two CIFS mount points

pvesm mounts at /mnt/pve/<id> with Proxmox defaults. fstab mounts at /mnt/<path> with uid=0,gid=0,file_mode=0777,dir_mode=0777 to permit local access through LXC bind mounts. The SMB server still enforces the mounted user’s permissions. These are two mount points; they do not guarantee two separate TCP connections.

Method A — As Proxmox storage (pvesm)

If As Proxmox storage is marked, ProxMenux runs the original pvesm flow:

  1. Storage ID — default cifs-<server-ip-with-dashes>. Only letters, digits, - and _.
  2. Content types — this ProxMenux checklist offers 6 choices. It omits rootdir compared with the NFS checklist; this is a script-level choice, not a claim that every Proxmox CIFS backend version forbids LXC root filesystems:
Content typeWhat it allows
importDisk image imports (selected by default).
backupVM and CT backup files (vzdump).
isoInstallation ISO images.
vztmplLXC templates.
imagesLive VM disk images — warned inline, see below.
snippetsHook scripts and cloud-init snippets.

Live VM disks on CIFS

Selecting images triggers a ProxMenux warning that CIFS/SMB can cause locking issues with VM disk operations. The script recommends NFS for VM disk images but lets you continue. Backups and ISOs are common CIFS uses. Assess locking, snapshots, migration and workload requirements before using CIFS for images.

Where pvesm stores credentials

The password is not written in /etc/pve/storage.cfg. Proxmox writes plaintext credentials in /etc/pve/priv/storage/<storage-id>.pw, inside the private area of the cluster filesystem, readable only by root (mode 0600); it is protected by access control, not by encryption. After a server password change, use pvesm set <id> --password <new> or remove and re-add through ProxMenux.

Method B — Host fstab mount only

If As host fstab mount only is marked, ProxMenux asks for a host mount path and persistent options, writes a root-only credentials file (User mode), then mounts and writes the entry to /etc/fstab:

  1. Host mount path — default /mnt/<share-name>. Must be an absolute path. If something is already mounted there, or a fstab entry exists, ProxMenux offers to replace it.
  2. Mount options — choose Read/Write (default: rw,uid=0,gid=0,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail,_netdev), Read-only (file_mode=0555,dir_mode=0555), or Custom (enter your own options). The script recommends open uid/gid/file_mode for writes through LXC bind mounts.

Credentials file (User mode)

If you authenticated with a username + password, ProxMenux writes a root-only credentials file at /etc/samba/credentials/<server>_<share>.cred (mode 0600) with username= and password= lines, and references it in the fstab entry via the credentials= mount option. Plain text never lands in /etc/fstab. For Guest mode, the option guest is appended instead and no credentials file is created.

Once you confirm, the script:

  • mkdir -p the mount path.
  • mount -t cifs -o <opts>,credentials=<file> (or guest) //<srv>/<share> <path>.
  • Writes a one-line entry to /etc/fstab: //<srv>/<share> <path> cifs <opts> 0 0.
  • Runs systemctl daemon-reload so systemd picks up the new fstab entry.

Using the fstab mount from an unprivileged LXC

The CIFS options uid=0,gid=0,file_mode=0777,dir_mode=0777 open local permission checks for LXC bind mounts. Server ACLs and negotiated Unix/POSIX semantics can still affect access. No changes are made inside the container: no CT chown, groups or edits to /etc/lxc. The mp line is managed in Proxmox CT configuration. Use the printed pct set command or the LXC Mount Manager.

The fstab mount is NOT a Proxmox storage

The host fstab mount is invisible to the Proxmox web UI — by design. It does not appear in Datacenter > Storage, you cannot select it in the VM / CT creator, and Proxmox backup jobs cannot target it. It is purely a host filesystem path. If you also want UI integration, mark both methods in the picker.

Manual equivalent

Method A (pvesm) maps to:

apt-get install -y cifs-utils smbclient    # one-time: SMB client tools

# with user authentication
pvesm add cifs mycifs \
  --server 10.0.0.50 \
  --share proxmox \
  --username backup_user \
  --password 's3cret' \
  --content backup,iso

# guest access (no credentials)
pvesm add cifs mycifs-guest \
  --server 10.0.0.50 \
  --share public \
  --content iso,vztmpl

pvesm status mycifs                         # verify it's active
ls -la /mnt/pve/mycifs                       # Proxmox auto-mounts here

Method B (fstab, user auth) — credentials file + mount:

# 1. credentials file (root-only)
mkdir -p /etc/samba/credentials && chmod 0700 /etc/samba/credentials
cat > /etc/samba/credentials/nas01_share.cred <<'EOF'
username=admin
password=s3cret
EOF
chmod 0600 /etc/samba/credentials/nas01_share.cred

# 2. mount with open uid/gid/file_mode (for unpriv LXC bind-mounts)
mkdir -p /mnt/data
mount -t cifs //10.0.0.50/share /mnt/data \
  -o "rw,uid=0,gid=0,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail,_netdev,credentials=/etc/samba/credentials/nas01_share.cred"

# 3. persist
echo "//10.0.0.50/share /mnt/data cifs rw,uid=0,gid=0,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail,_netdev,credentials=/etc/samba/credentials/nas01_share.cred 0 0" \
  >> /etc/fstab
systemctl daemon-reload

# 4. bind into an unpriv LXC (no changes inside the CT)
pct set <ctid> -mp0 /mnt/data,mp=/mnt/data,shared=1,backup=0
pct reboot <ctid>

Method B (fstab, guest auth) — no credentials file:

mkdir -p /mnt/public
mount -t cifs //10.0.0.50/public /mnt/public \
  -o "rw,uid=0,gid=0,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail,_netdev,guest"

echo "//10.0.0.50/public /mnt/public cifs rw,uid=0,gid=0,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail,_netdev,guest 0 0" \
  >> /etc/fstab
systemctl daemon-reload

View configured CIFS storages and host mounts

Shows registered CIFS storages (pvesm status | awk '$2 == "cifs"') with server, share, content, username or Guest, path and status. Passwords are never printed. Note: a second section lists host fstab mounts, their options, authentication-file path and active/inactive state. For manual checks use findmnt -t cifs or grep cifs /etc/fstab.

Remove CIFS storage or a host mount

The removal picker offers pvesm storages and host fstab mounts. For pvesm, it runs pvesm remove <storage-id> and Proxmox removes the paired credentials. For fstab, it attempts umount <path>, removes the matching /etc/fstab entry and credentials under /etc/samba/credentials/, and removes an empty mount directory if possible. A failed unmount requires a manual unmount or reboot. The remote Samba server and its files are not modified.

Back up dependencies first

VMs, CTs or backup jobs that reference this storage by ID will fail after removal. Move / drop those references before removing the storage.

Test Samba connectivity

Runs a diagnostic pass over every CIFS storage registered in Proxmox: checks that smbclient is available, pings each server, probes ports 445 and 139, tries a guest listing, and reports Proxmox's own view (pvesm status). "Requires authentication" on guest-list means your server only exposes shares to authenticated users — normal for most NAS setups.

Troubleshooting

"No Samba servers found on the network"

Auto-discover uses nmap -p 139,445. The server may be on a different subnet, firewalled, or only reachable by hostname (mDNS / WINS). Use the Manual option with the IP or hostname instead.

"No accessible shares found"

smbclient -L returned nothing for these credentials. Causes: the user has no permission to list shares (try with admin credentials once, or enter the share name manually), the server has share visibility disabled, or the credentials are wrong. The script lets you type the share name by hand in this case.

Proxmox mount fails with NT_STATUS_ACCESS_DENIED

The credentials pvesm stored are out of sync with the Samba server (password changed, account disabled, domain / workgroup mismatch). Re-enter credentials with pvesm set <id> --username <u> --password <p> or remove and re-add from ProxMenux. If the server is in an AD domain, append --domain <DOMAIN> to the pvesm set call.

"host is down" or storage status goes inactive at night

Some NAS appliances put SMB to sleep aggressively. pvestatd then sees the storage as inactive until the first access wakes the NAS. If this is cosmetic, nothing is broken. If it causes backup failures, disable SMB idle disconnect on the NAS or schedule backups outside the sleep window.

Unprivileged LXC bind-mount can't write to the fstab path

Check findmnt /mnt/<path> for the intended options, such as uid=0,gid=0,file_mode=0777,dir_mode=0777. Missing local write permissions can block mapped LXC UIDs. Reapply the default RW preset or adjust Custom options as needed. Also verify the mounted SMB user can write on the server and whether Unix/POSIX extensions supply server modes; open local modes cannot override server ACLs.

fstab mount does not come up after reboot

The script adds nofail,_netdev so a missing share at boot does not block startup. If the mount never comes up: confirm the network is reachable (ping <server>), check journalctl -u remote-fs.target, verify the credentials file still exists (ls -l /etc/samba/credentials/) and is readable, and try mount -a manually.

Related

  • NFS share as Proxmox storage — sibling page with the same flow pattern (Method A pvesm + Method B fstab) and side-by-side trade-offs.
  • LXC Mount Manager — bind-mount the fstab-only path /mnt/<path> into one or more containers.
  • Samba client in LXC — alternative: mount Samba directly from inside a privileged container (skips the host).