Debian Series: Mounting SMB Shared Directories in Unprivileged Linux Containers in PVE
本文最后更新于 1071 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Abstract
In the Proxmox VE environment, unprivileged LXC containers cannot directly use the mount command to mount SMB shared directories due to security mechanism restrictions, resulting in permission exception issues. Indirect mounting is achieved by first mounting the SMB shared directory to the PVE host, and then mapping the host directory into the container. This solution requires installing the cifs-utils toolkit on the host, creating a mount point, and executing the mount command, followed by bind-mounting the host directory to the container filesystem via container configuration. After restarting the container, you can verify whether the SMB directory content is displayed normally. If automatic mounting on boot is required, the relevant configuration can be written to the host's /etc/fstab file. This method is technically related to the automatic SMB mounting solution introduced in the series of articles.
Qwen3-14B · 2026-06-18

Unprivileged LXC

What is an unprivileged Linux container (LXC)? Unprivileged containers are considered safer and more secure than privileged containers. When an unprivileged container runs, the container's root UID is mapped to a non-root UID on the host system. This makes it difficult for an attacker to gain root privileges on the underlying host even if they compromise the container. In short, if an attacker manages to compromise your container through a known software vulnerability, they will immediately find themselves unable to obtain any host privileges. Therefore, unprivileged containers are inherently designed to limit the root user privileges of LXC, thereby protecting the security of the host. However, this also causes some inconveniences. For example, when we want to use the mount command to mount an SMB-shared NAS directory in an unprivileged LXC in PVE just like in normal Linux, it will fail with a permission error:

mount error(1): Operation not permitted lxc

So what should we do if we want to mount an external SMB directory in this case? We have to take a detour: first mount the SMB directory to the PVE host, and then use the PVE host to map its mounted directory into the unprivileged LXC container.

Note: The following operations are run on the PVE host

First mount the shared directory that needs to be mounted to the LXC onto the PVE host

Install the cifs-utils package

apt-get install cifs-utils

Create the mount directory

mkdir -p  /mnt/share/

Run the mount command

mount -o username=账号,password=密码 //your-ip/共享目录 /mnt/share

Mount the PVE host directory into the unprivileged LXC container

pct set "CT id" -mp0  /mnt/share/,mp=/mnt/share

If you need to mount other directories later, they will be mp1, mp2, etc., in sequence.

Check after restarting the LXC container

ls /mnt/share

If you see the contents of the SMB directory, it means success.

Note: If you want PVE to automatically load the SMB directory on boot, you need to edit /etc/fstab and add the following content:

//your-ip/共享目录 /mnt/share cifs defaults,username=账号,password=密码

You can refer to my other article for this:Debian Series: Automatically Mount SMB on Boot

View Related Categories · 3 Matches
📌 Content Structure Prompt:
This content is part of the following knowledge map, where you can view the complete content path: Blog Knowledge Map。
📎 Related Articles
Share this article
The blog content is original, please indicate the source when reposting! The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if needed, you can join theTelegram Groupto discuss questions together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗ
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Kaomoji
Emoji
Little Dinosaur
Flower!
Previous
Next
       

👋 Welcome to “Wudi's Personal Blog”

Here, long-term exploration is mainly carried out around the following directions:

🧱 Personal Digital Infrastructure and Blog System Construction
☁️ Cloudflare and Network Architecture Practice
🧠 AI and Knowledge System Exploration
🛡️ Network Security and Access Optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspectives and Worldviews