Unprivileged Linux container in debian series PVE mounts SMB shared directory
本文最后更新于 980 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Summary
在Proxmox VE环境中,无特权LXC容器因安全机制限制无法直接使用mount命令挂载SMB共享目录,导致权限异常问题。通过将SMB共享目录先挂载至PVE宿主机,再利用宿主机目录映射至容器内部的方式实现间接挂载。该方案需在宿主机安装cifs-utils工具包,创建挂载点并执行mount命令,随后通过容器配置将宿主机目录绑定挂载至容器文件系统。重启容器后可验证SMB目录内容是否正常显示,若需实现开机自动挂载,可将相关配置写入宿主机/etc/fstab文件,该方法与系列文章中介绍的SMB自动挂载方案形成技术关联。
Qwen3-14B · 2026-06-18

Unprivileged LXC

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

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 can only go in a circle: first mount the SMB directory to the pve host, and then use the pve host to map the mounted directory to the unprivileged LXC container.

Note: The following operations are run on the pve host

Mount the shared directory that needs to be mounted to LXC to the PVE host first

Install the cifs-utils package

apt-get install cifs-utils

Create a mount directory

mkdir -p /mnt/share/

Run the mount command

mount -o username=account,password=password//your-ip/shared directory/mnt/share

Mount the PVE host directory into the unprivileged LXC container

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

If you want to mount other directories later, they will be mp1, mp2, and so on.

Restart the LXC container and check

ls /mnt/share

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

Note: If you want pve to automatically load the SMB directory when it starts, you need to edit /etc/fstab and add the following content:

//your-ip/shared directory/mnt/share cifs defaults,username=account,password=password

This can be found in my other article:Debian series automatically mount SMB at startup

📌 Content Structure Hints:
This content belongs to "Blog Knowledge MapThis is part of the document; you can view the full content path here: Blog Knowledge Map .
View related categories · 3 matches
📎 Related Articles
Share this article
All blog content is original; please indicate the source when reprinting! The blog's RSS address is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


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

👋 Welcome to "Invincible Personal Blog"“

This section will focus on long-term exploration in the following areas:

🧱 Building Personal Digital Infrastructure and Blog Systems
☁️ Cloudflare and Network Architecture Practices
🧠 Exploring AI and Knowledge Systems
🛡️ Network security and access optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspective and Worldview