You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派Samba配置报错:Failed to add entry for user pi

Troubleshooting "Failed to add entry for user pi" in Samba (Raspberry Pi + Ubuntu)

Alright, let's work through this Samba user creation error you're facing. I’ve dealt with this exact issue a few times, so here are the most effective fixes to try, organized by common root causes:

1. Confirm the system user exists and Samba services are running

First, let’s make sure the pi user is actually present on your Raspberry Pi (it should be by default, but better safe than sorry):

id pi

You’ll see output with the user’s UID, GID, and groups if it exists. If not, create it with sudo adduser pi first.

Next, check that Samba’s core services are active:

sudo systemctl status smbd nmbd

If they’re inactive, start them up:

sudo systemctl start smbd nmbd

And set them to launch on boot to avoid this issue later:

sudo systemctl enable smbd nmbd

2. Check if the user is already in Samba’s database

Sometimes the error happens because the user is already registered in Samba’s user list. Let’s check:

pdbedit -L

If you see pi in the output, delete the existing entry first:

sudo smbpasswd -x pi

Then try adding the user again:

sudo smbpasswd -a pi

3. Fix a corrupted Samba user database

Corruption in Samba’s passdb.tdb file is a frequent culprit here. Let’s back up and rebuild it:

# Back up the old database (just in case)
sudo cp /var/lib/samba/private/passdb.tdb /var/lib/samba/private/passdb.tdb.bak
# Delete the corrupted file
sudo rm /var/lib/samba/private/passdb.tdb
# Re-add your user
sudo smbpasswd -a pi

4. Reset permissions on Samba’s private directory

Incorrect permissions on /var/lib/samba/private can block Samba from writing to its database. Reset them to the correct defaults:

sudo chown root:root /var/lib/samba/private
sudo chmod 700 /var/lib/samba/private

Then attempt to add the user again.

5. Update your system and Samba package

Outdated Samba versions might have bugs that cause this error. Let’s update everything:

sudo apt update && sudo apt full-upgrade -y
# Restart Samba services after the update
sudo systemctl restart smbd nmbd

Now try creating the Samba user once more.

Note for Ubuntu systems

Your hunch is right—this issue can pop up on Ubuntu too, and all the steps above apply directly. The only minor difference is that newer Ubuntu releases might not require nmbd for basic file sharing, but the core fixes for user database issues, permissions, and package updates are identical.

内容的提问来源于stack exchange,提问作者Nikhil George

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 14:57:46