我如何让 cifs 挂载不包含所有由 root 拥有的文件?

我如何让 cifs 挂载不包含所有由 root 拥有的文件?

我研究过这个问题,发现建议使用 uid 参数,但这没有帮助。

在 /etc/fstab 中:

//192.168.0.234/Backups /home/mark/Backups cifs vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark
//192.168.0.234/Documents /home/mark/NetDocuments cifs vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark
//192.168.0.234/Downloads /home/mark/NewDownloads cifs vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark
//192.168.0.234/Media /home/mark/Media cifs vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark
//192.168.0.234/Public /home/mark/Public cifs vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark

根据第一个建议修改了 fstab

//192.168.0.234/Backups /home/mark/Backups cifs vers=3.0,credentials=/root/.smbCredentials uid=1000 gid=1000
//192.168.0.234/Documents /home/mark/NetDocuments cifs vers=3.0,credentials=/root/.smbCredentials uid=1000 gid=1000
//192.168.0.234/Downloads /home/mark/NewDownloads cifs vers=3.0,credentials=/root/.smbCredentials uid=1000 gid=1000
//192.168.0.234/Media /home/mark/Media cifs vers=3.0,credentials=/root/.smbCredentials uid=1000 gid=1000
//192.168.0.234/Public /home/mark/Public cifs vers=3.0,credentials=/root/.smbCredentials uid=1000 gid=1000
mark@mark-Desktop:~/Media$ id -u;id -g
1000
1000

我的用户名是“mark”,我的组名是“mark”

-rw-r--r--  1 mark mark   3812 Nov  6 17:58 .bashrc

我正在运行一个完全打过补丁的 Kubuntu 22.04 实例

mark@mark-Desktop:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

smb 挂载中的所有文件都归 root 所有:

mark@mark-Desktop:~$ cd Media
mark@mark-Desktop:~/Media$ l
total 12216
drwxr-xr-x  2 root root       0 Sep 13 10:00  ./
drwxr-x--- 35 mark mark    4096 Nov 20 18:17  ../
drwxr-xr-x  2 root root       0 Nov  9 18:12  Astro/

查看启动顺序,我在尝试安装驱动器时收到解析错误:

Nov 20 19:01:27 mark-Desktop systemd-remount-fs[442]: mount: /etc/fstab: parse error at line 17 -- ignored
Nov 20 19:01:27 mark-Desktop systemd-remount-fs[442]: mount: /etc/fstab: parse error at line 18 -- ignored
Nov 20 19:01:27 mark-Desktop systemd-remount-fs[442]: mount: /etc/fstab: parse error at line 19 -- ignored
Nov 20 19:01:27 mark-Desktop systemd-remount-fs[442]: mount: /etc/fstab: parse error at line 20 -- ignored
Nov 20 19:01:27 mark-Desktop systemd-remount-fs[442]: mount: /etc/fstab: parse error at line 21 -- ignored

我究竟做错了什么?

答案1

除非您发布的内容fstab中有拼写错误,否则您的语法就是不正确的。

这:

//192.168.0.234/Backups /home/mark/Backups cifs
vers=3.0,credentials=/root/.smbCredentials uid=mark gid=mark

应该是这样的:

//192.168.0.234/Backups /home/mark/Backups cifs
vers=3.0,credentials=/root/.smbCredentials,uid=mark,gid=mark

,条目中的选项列表应以逗号(“ ”)分隔/etc/fstab

答案2

您的用户名是“mark”,但您的 UID 是一个数字(id -u)。

您的组名是“mark”,但您的 GID 是一个数字 ( id -g)。

将用户名和组名替换为您的 中的数字/etc/fstab

相关内容