Debian Series: Automatically Mount SMB on Boot
本文最后更新于 1071 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Abstract
To address the need for automatically mounting SMB shared directories on boot in Debian 12 systems, we verify connectivity to devices like NAS by installing the cifs-utils component, create a mount directory, and then configure the fstab file to achieve persistent mounting. Note that in LXC container scenarios, if a permission error occurs, you need to confirm whether it is a privileged container; otherwise, alternative solutions must be used. Finally, verify the mount status using the mount command to complete the automatic loading of the SMB shared directory upon system startup, which is suitable for server deployment scenarios requiring cross-platform file sharing.
Qwen3-14B · 2026-06-18

Previously, I wrote an article about how macOS achieves mounting shared SMB folders on boot (see:Tips and Tricks Series: macOS Automatically Mounts SMB Shared Network Disks on Boot ), and this article will briefly explain how the Debian 12 system achieves mounting SMB folders on boot.

First, install the required components:

apt-get install cifs-utils
apt install samba-client

After installation, you can use the following command to verify whether you can log in to the corresponding shared device, such as a NAS:

smbclient -L your-ip -U 用户名

Then create the mount directory:

mkdir /mnt/share

Mount the shared directory to the /mnt/share directory created earlier:

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

Note: If the Debian 12 here is an LXC (Linux container), the following error may be reported:

mount error(1): Operation not permitted lxc

This indicates that the LXC is an unprivileged container. Therefore, if you want to use the method in this article, it needs to be a privileged LXC. If it is not a privileged container, there are other ways to achieve this, which I will cover in another article in the future.

You can use thedf -hcommand to check if the mount was successful.

To set it to automatically mount on boot, you need to edit theetc/fstabfile:

vim /etc/fstab

Then add the following configuration to the last line of the file, save, and exit:

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

Finally,rebootand then usedf -hto check if the mount has taken effect.

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