windows - Why is NTFS case sensitive?
2013-09
I personally thought that NTFS was case insensitive, since you can type cmd, CMD, cMd or even CmD and still get the command prompt. However, why is it that during a CHKDSK x: /f /r
, sometimes it fixes capitalization in some files? If it didn't care about the case, it shouldn't matter about that, and CHKDSK shouldn't be checking if it's actually CMD or cmd. Am I right? Where does it actually matter in the file system?
The case sensitivity of a file system is a separate issue from that of an operating system. Latest Windows releases are based on the NT kernel, which inherits a lot of properties of the non-NT Windows 95 and even MS-DOS. Along with the NT kernel the file system, NTFS, was designed to be case sensitive -- to be POSIX compliant.
Although the Win32 subsystem does not support file names that only differ by case sensitivity, it is possible to create those files with lower level system calls.
It actually isn't NTFS that you are inquiring about.
NTFS is the filesystem. Your question is really about the case-sensitivity of the Windows command shell. They're completely different. Windows Explorer is a graphical command shell. By entring cmd
(in Start | Run for example) you're telling the Windows command shell to execute the command cmd
(which itself is actually another command shell, but command line based rather than graphical).
Similarly, CHKDSK is not doing any kind of check on whether you used CMD or cmd. All CHKDSK knows about are the parameters you pass to it, which in this case are x:, /f and /r.
As for CHKDSK "fixing capitalization", I'm not really sure what you mean there.
I suspect the question asker's claim that chkdsk.exe is "fixing capitalization in some files" is actually prompted by the message from CHKDSK that occurs under some circumstances:
correcting errors in the uppercase file
Basically, this results from a Windows XP version of chkdsk.exe running against an NTFS volume that has been formatted in a later version of Windows, as described in Error message when you run Chkdsk.exe on a Windows XP-based or on a Windows Server 2003-based computer: “Correcting errors in the uppercase file”. The upshot is that this is really not an error, and has nothing to do with case sensitivity.
Here's the deal, I have a huge mess of files on an external drive that is formatted as NTFS. I wish to copy all of these files onto my MacBook Pro.
NTFS, like sane filesystems, is case sensitive. HFS is not.
There is, somewhere in the mess of tens of thousands of files and directories, one or more 'duplicates' in the eyes of HFS. Theses are preventing me from copying the entire directory of data onto my mac.
(MacOSX rather unhelpfully throws a general error explaining the problem, but not the exact file. It also doesn't give you an option to skip)
What is the best approach to solve this? Does anyone know a tool that can find files and directories that have the same case-insensitive name?
--Edit--
So I did a cp -i
and left it running overnight with the intention of waking up and seeing it stuck on a duplicate, but when I woke up it had finished! However, the resulting directory had 13,906 items while the original has 13,914, so it sounds like cp
either doesn't recognise files that are the same given case insensitivity, or it ignores them even with -i
.
I don't know if this is the best approach, but the following command does what you want and lists you all files and directory entries for which duplicate case insensitive names exist:
find /path/to/check -type f -o -type d | tr A-Z a-z | sort | uniq -d
What it does is, find all files and directories in /path/to/check, makes the output lowercase, sorts those entries (required since uniq only compares adjacent lines) and filters to only show duplicate lines i.e. duplicate file or directory entries.
Example: If I wanted to check my Bootcamp Volume on OS X for duplicates I would open Terminal.app and execute
find /Volumes/BOOTCAMP/ -type f -o -type d | tr A-Z a-z | sort | uniq -d
I haven't used it, but iPartition claims to be able to nondestructively convert between HFS+ (case-insensitive) and HFSX (case-sensitive).
can I turn it [case sensitive HFSX] on without formatting my entire drive
You may create a case sensitive disk image on Mac OS X which can be mounted as a normal hard drive volume.
# cf. http://codesnippets.joyent.com/posts/show/8617
IMAGE="${HOME}/Desktop/Case Sensitive Test.dmg"
VOLNAME="Case Sensitive Test"
hdiutil create "${IMAGE}" -size 10m -fs HFSX -volname "${VOLNAME}" -layout NONE
hdiutil attach "${IMAGE}"
cd "/Volumes/${VOLNAME}"
touch foo.txt Foo.txt
open .
ls -l [Ff]oo.txt
stat -f "inode: %i -- name: %N" [Ff]oo.txt
cd ~
hdiutil detach "/Volumes/${VOLNAME}"
I use Double Commander, which is a Total Commander alternative for Mac OS X. It has the same look and feel as TC and the same Search function. Easy Find is good and convenient, but I found this quicker most of the time. I just looked up all my *.iso files quickly on my NTFS partition.
From Mac OS 10.3 on the command
newfs_hfs -s
will create a case-sensitive new file system.