0

I have a Raspberry Pi which is using samba and ntfs-3g in order to share a USB external hard drive on my home network. On the hard drive, there are some files which are marked with the "Hidden" Windows file attribute. However, when I access the share on a Windows PC, the files do not show as hidden. As a result, I see many hidden files such as desktop.ini, thumbs.db, as well as directories like $RECYCLE.BIN and System Volume Information, even though my Windows setting in Folder Options is set to not show hidden files.

I know that samba is not correctly transferring the Hidden attribute because if I view the Properties of a file that should be hidden, the Hidden check-box is not selected:

Not hidden

These are the current contents of my smb.conf file:

#### GLOBAL CONFIG #####

workgroup = WORKGROUP
netbios name = raspberrypi
server string = %h
wins support = yes
dns proxy = no
security = share
null passwords = yes
guest account = nobody
interfaces = eth0 lo
bind interfaces only = yes

#### PUBLIC SHARE #####

[Mazda6]
comment = Media Drive
path = /media/HDD
browseable = yes
guest ok = yes
writeable = yes
public = yes
available = yes
create mask = 0666
directory mask = 0777

How can I have files that are marked with the Hidden file attribute on the NTFS drive to be shown as Hidden when viewed through the samba share on a Windows PC?

0

I believe -- but have not tested myself -- that you need only add map hidden = yes to the configuration for your share. Note that this may have the unintended/undesired behavior of making "other executable" files (per the Linux file permissions) rendered "hidden" in Windows as well; this is because Samba in effect repurposes that bit to be the "hidden" attribute for Windows, as it resides on top of Linux which has no such attributes.

Failing that, you should be able to use the hide files option to hide the files you specify; for example, you apply this to your share's config:

hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

The downside here, of course, is that you must hard-code the files you want hidden explicitly in your config, and unfortunately there's no way to distinguish between e.g. a desktop.ini that should be hidden, and a desktop.ini that should not be hidden -- both will be hidden with this setting. (NOTE: I'm unsure if this will work with directories; I believe it should, but cannot test it at the moment. There may also be issue with the $ character; again, I think it will work, but I'm not able to test it right now.)

As always, the documentation is your friend.

Update: Per the OP's testing as reported in the comments below, it seems all files on an NTFS partition may show up in Linux with 0777 permissions; since this means the "other execute" bit is set, Samba ends up interpreting every single file as "hidden" with the map hidden setting turned on, rendering that solution untenable without first moving all data to a different file system.

| improve this answer | |
  • I added map hidden = yes to the configuration, and every file is hidden now, even ones without the hidden attribute. Using hide files seems to be working though. If nobody suggests a better alternative I will accept your answer. – bdr9 Apr 29 '14 at 23:34
  • Check the permissions in Linux on your host itself, I've noticed frequently that NTFS file systems in particular are frequently read by the system as having the "other execute" bit set for every single file, which coupled with how Samba maps the Windows hidden file attribute sounds like exactly what you've encountered here. – Kromey Apr 29 '14 at 23:48
  • The .jpg pictures on my drive are showing as having -rwxrwxrwx permissions. I don't know much about Linux permissions though. Does this confirm your theory? – bdr9 Apr 29 '14 at 23:59
  • It seems to, yes -- it's at least consistent with it. Try running the command chmod a-x <filename.jpg> on one of those .jpg files -- just one, though, for now -- and see if that makes it "pop into existence" when viewed from Windows via Samba. When used in conjunction with the map hidden option, of course. – Kromey Apr 30 '14 at 0:02
  • When I run chmod a-x <filename> on a file on the NTFS drive, the permissions do not change, they are still -rwxrwxrwx. As such the files are still hidden when map hidden = yes is included in the configuration. – bdr9 Apr 30 '14 at 2:15
0

Linux has no real equivalence to Windows's "hidden" attribute, hence Samba cannot read it from NTFS properly. However, you can use NTFS-3G with option hide_hid_files, which causes hidden files not to be shown in directory listings, thereby hidden in Windows when shared with Samba.

The disadvantage of this approach is that all hidden files are invisible in Windows even if Folder Options is set to show all files, and (to my testing) inaccessible in Windows even when explicit filename is given. But for your use case, this should be enough.

The best solution would involve writing some code to make Samba read system.ntfs_attrib_be xattr of NTFS-3G, but I'm unware of any such projects.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.