6

Does Linux really allow colons in file names, even on NTFS partitions? Why is that? And is there any option to set it straight, and do not allow colons (and other characters restricted by Windows) in file names when working with a NTFS partition? And do allow it for Ext2, Ext3 and Ext4 partitions?

Linux wrote some files with colons in their names to my main NTFS partition where I have Windows installed. I have since uninstalled Linux, but now I can't open these files in Windows.

3
  • 1
    The why part: because Linux allows any character other than nul and / in file names. : is used in the name of the X socket and little else. I don't know about the NTFS part. – Gilles 'SO- stop being evil' Feb 10 '14 at 0:00
  • 1
    A colon in NT denotes a stream (i.e. "sub-file") -- much like the old MAC HFS forks. (it's a damn good way of hiding things in windows.) – Ricky Feb 10 '14 at 3:17
  • the colon is used by wine in the symlinks under ~/.wine/dosdevices, which is ironic don't you think? since these names would not be allowed on an NTFS partition. You have to disable the streams if you want to use it like on ext4. AFAIK, you can do this in your fstab. Or with your question, (which is the opposite), make sure you DONT disable it. You probably dont want that though if you are using the partition for user or temp directories, since many tools out there use colons like spam assassin(off the top of my head) you can delete those files i think using sysinternals suite – osirisgothra Jul 1 '14 at 15:31
7

In case of NTFS-3G check out the ntfs-3g man page and search for "windows_names".

excerpt

windows_names

This option prevents files, directories and extended attributes to be created with a name not allowed by windows, either because it contains some not allowed character (which are the nine characters ” * / : < > ? \ | and those whose code is less than 0×20) or because the last character is a space or a dot. Existing such files can still be read (and renamed).

2
  • The link above is broken (returns status 404). You can check out the Arch Linux Wiki instead. – Samir Nov 17 '20 at 8:38
  • 1
    @Samir I've updated the link (not to ArchWiki, but to the man page that contains the quoted part) – Ruslan Nov 17 '20 at 10:23
2

even on NTFS partitions? Why is that?

In addition to Win32 filenames, NTFS supports also DOS and POSIX ones by the mechanism of filename namespaces. This way, a file not only can have colons or backslashes in its name, but it may even have multiple names.

You may have seen the DOS filenames e.g. on the command line, like the MICROS~1 below (or the commonly seen PROGRA~1 name for Program Files in the root directory of C:):

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\User>cd c:\Program Files

c:\Program Files>dir /x
 Volume in drive C has no label.
 Volume Serial Number is E4FC-4AD7

 Directory of c:\Program Files

01/16/2020  10:13 PM    <DIR>                       .
01/16/2020  10:13 PM    <DIR>                       ..
05/26/2020  04:39 PM    <DIR>                       7-Zip
07/14/2009  06:20 AM    <DIR>          COMMON~1     Common Files
11/21/2010  10:16 AM    <DIR>          DVDMAK~1     DVD Maker
11/21/2010  10:06 AM    <DIR>          INTERN~1     Internet Explorer
11/21/2010  10:16 AM    <DIR>          MICROS~1     Microsoft Games
01/16/2020  10:14 PM    <DIR>          MINGW-~1     mingw-w64
07/14/2009  08:32 AM    <DIR>                       MSBuild
07/14/2009  08:32 AM    <DIR>          REFERE~1     Reference Assemblies
11/21/2010  10:06 AM    <DIR>          WINDOW~3     Windows Defender
11/21/2010  10:16 AM    <DIR>          WI0FCF~1     Windows Journal
11/21/2010  10:06 AM    <DIR>          WINDOW~1     Windows Mail
11/21/2010  10:06 AM    <DIR>          WI54FB~1     Windows Media Player
07/14/2009  08:32 AM    <DIR>          WINDOW~2     Windows NT
11/21/2010  10:06 AM    <DIR>          WINDOW~4     Windows Photo Viewer
11/21/2010  06:31 AM    <DIR>          WIBFE5~1     Windows Portable Devices
11/21/2010  10:06 AM    <DIR>          WI4223~1     Windows Sidebar
               0 File(s)              0 bytes
              18 Dir(s)   5,582,016,512 bytes free

c:\Program Files>

In the above directory listing, the two namespaces of files are listed next to each other. The entries whose Win32 names which don't conflict with DOS, don't have a DOS name.

Without the windows_names option mentioned in another answer, the Linux NTFS driver ntfs-3g uses the POSIX namespace to name the files it creates.

1
  • Thanks for providing this detailed explanation. – Samir Nov 17 '20 at 8:32

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.