Samba Sharing
Network

[Proxmox] Connect CIFS network hard drive to LXC Container

This article will guide you how to connect a network hard drive to Proxmox’s LXC container, using the SMB / CIFS protocol. I am using this method to connect a folder containing movies stored on XPEnology to an LXC running Plex on Proxmox.

The operation will include 2 steps:

  1. Connect the network hard drive to the Proxmox host
  2. Connect mount folder on Proxmox host to LXC

1. Configuration on Proxmox host

You need to understand how to connect to the Samba Server as instructed below before continuing”

Create a new folder to connect to the network hard drive

mdkir /mnt/nasCode language: Nginx (nginx)

Edit fstab

nano /etc/fstabCode language: Nginx (nginx)

Add the following line

//100.98.213.66/usbshare2/Thuan /mnt/nas cifs _netdev,x-systemd.automount,noatime,uid=100000,gid=100000,user=,pass= 0 0Code language: YAML (yaml)

Replace //100.98.213.66/usbshare2/Thuan with the path corresponding to the network hard drive you need to connect. In addition, you need to add and of network hard drive.

Parameter Explain
_netdev Notice to systemd This is a network hard drive.
x-systemd.automount Auto reconnect in case NAS is disconnected
noatime Do not update Access timestamps when folder/file is accessed
uid=100000,gid=100000 Grant access to declared uid/gid

By default, user root Unprivileged LXC containers will have the code uid=100000 and gid=100000 on Proxmox host, so this parameter needs to be declared in fstab so that LXC has access to the network hard drive.

Connect to the network hard drive using the following command

mount -aCode language: Nginx (nginx)

2. Connect mount folder to LXC Container

The network hard drive after connection has been mounted into the folder. /mnt/nas on Proxmox host. I will connect this folder inside LXC Container.

First, you need to shut down the running LXC. You can issue the command directly on the Proxmox host

pct shutdown Code language: Nginx (nginx)

Next, edit the configuration file of the LXC container that needs to access the network drive.

nano /etc/pve/lxc/LXC-id>.confCode language: JavaScript (javascript)

Add the following line and save

lxc.mount.entry: /mnt/nas/ mnt/nas none bind 0 0Code language: YAML (yaml)

Restart LXC

pct start Code language: Nginx (nginx)

Access LXC, you will see the network hard drive has been successfully linked to the path. /mnt/nas

The article is based on the instructions here: https://blog.ricardof.dev/sharing-mount-unprivileged-lxc-proxmoxhas been simplified for ease of understanding.

Hope you are successful.

Comment Policy: We truly value your comments and appreciate the time you take to share your thoughts and feedback with us.

Note: Comments that are identified as spam or purely promotional will be removed.

To enhance your commenting experience, consider creating a Gravatar account. By adding an avatar and using the same Email here, your comments will feature a unique and recognizable avatar, making it easier for other members to identify you.

Please use a valid email address so you can receive notifications when your comments receive replies.

Related posts

[Proxmox] Enable IPv6 for Debian / Ubuntu LXC

Mark Lee

Install Xpenology DSM 7.2 using RR Loader (Redpill Recovery Loader)

Mark Lee

[Hackintosh] Install macOS Sonoma 14.5

Mark Lee

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More