5

I saw that kernel 5.2 got handling of ext4 case-insensitivity per directory by flipping a +F bit in inode.

This EXT4 case-insensitive file-name lookup feature works on a per-directory basis when an empty directory is enabled by flipping the +F inode attribute.

https://www.phoronix.com/scan.php?page=news_item&px=EXT4-Case-Insensitive-Linux-5.2

But how to do that? Does any chmod handle that? My distributions doesn't look like it.

So how do I use this feature?

0

1 Answer 1

9

First you need recent enough software:

With this installed, the documentation from man ext4 does reflect the existence of this feature:

casefold

This ext4 feature provides file system level character encoding support for directories with the casefold (+F) flag enabled. This feature is name-preserving on the disk, but it allows applications to lookup for a file in the file system using an encoding equivalent version of the file name.

The casefold feature must first be enabled as a filesystem-wide ext4 option. Sadly, I couldn't manage to enable it on an already formatted filesystem. So using a sparse file created with dd if=/dev/zero of=/tmp/image.raw bs=1 count=1 seek=$((2**32-1)) to test on a newly created filesystem.

# tune2fs -O casefold /tmp/image.raw 
tune2fs 1.45.3 (14-Jul-2019)
Setting filesystem feature 'casefold' not supported.
#

UPDATE: Since this commit it's possible to use tune2fs to enable casefold on an unmounted filesystem. When this answer was written this feature was not yet available:

# tune2fs -O casefold /tmp/image.raw
tune2fs 1.47.0 (5-Feb-2023)
#

So when formatting, this will enable the feature:

# mkfs.ext4 -O casefold /tmp/image.raw 

or to specify an other encoding rather than default (utf8). It appears that currently there is only utf8-12.1, of which utf8 is an alias anyway:

# mkfs.ext4 -E encoding=utf8-12.1 /tmp/image.raw 

You can verify what was done with tune2fs:

# tune2fs -l /tmp/image.raw |egrep 'features|encoding'
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg casefold sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Character encoding:       utf8-12.1

Now to use the feature:

# mount -o loop /tmp/image.raw /mnt
# mkdir /mnt/caseinsensitivedir
# chattr +F /mnt/caseinsensitivedir
# touch /mnt/caseinsensitivedir/camelCaseFile
# ls /mnt/caseinsensitivedir/
camelCaseFile
# ls /mnt/caseinsensitivedir/camelcasefile
/mnt/caseinsensitivedir/camelcasefile
# mv /mnt/caseinsensitivedir/camelcasefile /mnt/caseinsensitivedir/Camelcasefile
mv: '/mnt/caseinsensitivedir/camelcasefile' and '/mnt/caseinsensitivedir/Camelcasefile' are the same file

You must log in to answer this question.

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