Showing Hidden Files as Hidden in Windows from Linux Samba Share of NTFS Drive

11,616

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.

Share:
11,616
bdr9
Author by

bdr9

Updated on September 18, 2022

Comments

  • bdr9
    bdr9 over 1 year

    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?

  • bdr9
    bdr9 about 10 years
    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.
  • Kromey
    Kromey about 10 years
    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.
  • bdr9
    bdr9 about 10 years
    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?
  • Kromey
    Kromey about 10 years
    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.
  • bdr9
    bdr9 about 10 years
    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.
  • Kromey
    Kromey about 10 years
    I was afraid that's what would happen. NTFS is very Windows-centric; short of moving all your data to a drive that is formatted with a different file system, I guess the hide files option is really your only option.
  • bdr9
    bdr9 about 10 years
    Thank you for your help. The hide files option works well enough for me because most of the hidden files I want to hide all have the same name, so I will accept your answer.