解決 Linux 掛載 CIFS 莫名無法讀取檔案的問題

在從 Raspberry Pi 上掛載 Windows XP 的分享時,莫名遇到了檔案無法讀取的問題,明明在 Windows 的資料夾權限裡看起來能開的都開了,User 本身也是系統管理員了,可是要讀取檔案時卻莫名給了個 Permission denied !?

上網 Google 了一下,發現了 這一篇,其中提到了

Files owned by root / "The folder contents could not be displayed". If you can view but not change, delete, or add new files to your Samba share, or if you get an error in Nautilus which says, "The folder contents could not be displayed" or more recently "You don't have permission to do that"; try this fix:

Add gid, uid, and nounix options to your fstab line like so:

//netbiosname/sharename /media/sharename cifs credentials=/root/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,nounix,filemode=0777,dirmode=0777 0 0

加上了 gid, uid 和 nounix 參數以後,一切順利

在 man mount.cifs 對 nounix 參數的解釋是

Disable the CIFS Unix Extensions for this mount. This can be useful in order to turn off multiple settings at once. This includes POSIX acls, POSIX locks, POSIX paths, symlink support and retrieving uids/gids/mode from the server. This can also be useful to work around a bug in a server that supports Unix Extensions.

所以有可能是因為 Samba Server 是 Windows XP 的關係,讓一些擴充功能用起來有問題?

感覺不無可能,隨手做個紀錄。

Ikaros

Read more posts by this author.