15

What methods are there to make the Linux filesystem case-INSENSITIVE ?

I have asp.net applications developed on Windows, but there are always issues with capitalization/spelling on mono when putting it on Linux.

One way is to mount a localhost SMB share to /var/www. Are there any others ?

3
  • 18
    Wouldn't it be easier to fix the application than hack the os to work around the broken app?
    – Aaron Tate
    Mar 23, 2010 at 13:04
  • 2
    Is this web app being served through apache, you could use mod_speling.
    – Zoredache
    Mar 23, 2010 at 15:26
  • 4
    This sounds like a pretty obvious case of "Or you can teach your web developers to be consistent with their file naming, on pain of pain" Mar 5, 2015 at 5:35

6 Answers 6

16

If you're talking about case insensitivity ONLY within apps running under Mono (>=1.1.18 & <6.0.0), you can use the IOMAP feature to tell Mono to ignore case just like Windows does.

$ export MONO_IOMAP=all
$ mono myapp.exe

For ASP.NET applications hosted with mod_mono, you can add the following directive to your Apache configuration file:

MonoSetEnv MONO_IOMAP=all
15

There's a case insensitive ext3 driver, but, frankly, running such a thing in production would scare me a bit, since you're rolling your own custom kernel with patched-in drivers. (Yeah, yeah-- we did that all the time "back in the day", but that was, like, 1997...)

There's a FUSE implementation, ciopfs, that implements case insensitivity as well. That would be a lot less scary to me to use in production than a patched kernel.

You could also use a case-insensitive filesystem, like VFAT, for the /var/www folder hierarchy. I'd use a loopback mount in that case, such that you don't have to mess with your disk partitioning.

3
  • ciopfs is crap, i tried it, it does only map lowercase to lowercase, ignoring any uppercase...
    – Quandary
    May 29, 2010 at 12:11
  • 1
    @Quandary Run awk '/^ciopfs/ {print $2}' /proc/mounts and that will output the name of the directory to use. After you run ciopfs a/ b/ you should not access or modify files under a/.
    – user67717
    Dec 23, 2012 at 18:08
  • @Quandary the lowercase constraint is written right on the project's page and is pretty obvious tbh, did you try to improve it to handle your use case or at least RTFM before use? Dec 3, 2015 at 9:12
11

There are two ways to do this:

Variant 1:
Create a .dsk-file of size X-MB (with dd), then make a JSF-filesystem on that file, with option O (OS2 compatibility - = case insensitive)
Then loop-mount that file into a desired folder.

To create a JFS filesystem, you will need to have jfs-utils installed.
On Ubuntu, you can do this with:

sudo apt-get install jfsutils

Now you need to create an empty file with some size, e.g. 1 GB

dd if=/dev/zero of=/tmp/test-jfs.img bs=1048576 count=150

Now you need to create a jfs-partition in /tmp/test-jfs.img
Note: All data in /tmp/test-jfs.img will be lost !

mkfs.jfs -O /tmp/test-jfs.img 

Then you neet to recursively create a mount directory (/mnt/jfs):

mkdir -p /mnt/jfs

Then you need to loop-mount (not recommended in production) that partition in /mnt/jfs

mount /tmp/test-jfs.img /mnt/jfs -t jfs -o loop

If that was successful, you can now create a partition, e.g. with touch

touch /mnt/jfs/aBc

if you ls, you see that it's there

ls /mnt/jfs

if you ls with

ls /mnt/jfs/AbC 

You've testet successfully, and can now unmount the partition:

umount /mnt/jfs/

And delete the temp file

rm /tmp/test-jfs.img 

Variant 2:
When you install the OS, manually partition the disk, and create another partition with format JFS, which you mount to wherever you want to have it.
When everything is up and running, you can reformat that partition with (warning - this will erase all data on that partition - make sure you selected the proper one, and don't have any data on it, yet):

unmount the mounted partition

umount /web

reformat:

mkfs.jfs -O /dev/hda5

remount the partition

mount /dev/hda5 /web

Now run

blkid

and you get the new partition-uuid.
Now go to /etc/fstab, and replace the old uuid for /dev/hda5 with the new one.

If you're doing this wrong, see also
Welcome to emergency boot mode...

3
  • So you've been dealing with this for seven and a half years?!?! You'd think by now the "developers" you're dealing with would have made it out of primary/elementary school. Oct 6, 2017 at 9:48
  • 5
    @Andrew Henle: No, we actually chose another solution - a case-sensitive windows partition (ext3). Now the issue resurfaced with .NET Core, and this is the solution I came up with. Now I have a case-insensitive Linux-partition without needing fuse/ciops, smb, hfs/hpfs+, a hacked extX-fs, loop mount or any of that crap. This is the proper way. And so far, nobody actually answered the question satisfactorily in the last 7 years, so I thought I would.
    – Quandary
    Oct 6, 2017 at 11:46
  • 2
    Thank you, I got it working. For people looking at this in 2020, be aware the linux kernel 5.2 and e2fsprogs 1.45 added casefold support for ext4. See this: unix.stackexchange.com/questions/558977/… Mar 7, 2020 at 8:19
1

You can create an XFS filesystem with version=ci which:

enables ASCII only case-insensitive filename lookup and version 2 directories. Filenames are case-preserving, that is, the names are stored in directories using the case they were created with.

# truncate --size=1G /tmp/test-xfs.img
# mkfs -t xfs -n version=ci /tmp/test-xfs.img
meta-data=/tmp/test-xfs.img      isize=512    agcount=4, agsize=65536 blks
…
naming   =version 2              bsize=4096   ascii-ci=1, ftype=1
…
# mkdir /tmp/test-xfs
# mount -o loop /tmp/test-xfs.img /tmp/test-xfs
# touch /tmp/test-xfs/aBc
# ls /tmp/test-xfs
aBc
# ls /tmp/test-xfs/abc /tmp/test-xfs/AbC
/tmp/test-xfs/abc  /tmp/test-xfs/AbC
# umount /tmp/test-xfs
# rm /tmp/test-xfs.img
0

@Quandary I tried going the JFS way, making a img with -O option. But for me it still gives errors. For example I get:

System.InvalidOperationException
The view 'Logon' or its master was not found. The following locations were searched:
~/Views/Account/Logon.aspx
~/Views/Account/Logon.ascx
~/Views/Shared/Logon.aspx
~/Views/Shared/Logon.ascx

The aspx file is actually named LogOn.aspx. It did solve a few issues, but I still get errors. Unfortunately I am still on 18.04 so can't try the ext4 way.

1
  • This looks more like a mono-bug than a case-sensitivity issue.
    – Quandary
    May 6, 2020 at 8:22
0

You can make a ZFS dataset case-insensitive by setting the casesensitivity property:

zfs set casesensitivity=insensitive pool/dataset

Plus you get all the usual benefits of ZFS, like error-correction, compression, snapshots, snapshot-based zfs send backups that are several orders of magnitude faster than rsync, etc.

I have yet to use this on an actual server (because I don't run Windows software on servers) but I do use it on home systems for Steam game libraries (I have different datasets for Linux native games and Windows games to run with Proton/WINE - the Windows datasets are case-insensitive because Windows devs are sloppy about upper/lower case in file/dir names).

1
  • Take note that on some older systems like Ubuntu 20.04 you should set it when the file system is created, not afterwards. Apr 3, 2023 at 15:23

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .