ext4 counts bytes: Arabic file names get about 127 letters
copying my F: drive to a NAS running ext4, one file failed. robocopy error 123, exit code 9. a Notion to-do note with a 152-character Arabic name.
152 characters is fine on NTFS, which allows 255. ext4 allows 255 bytes. in UTF-8 an Arabic letter is 2 bytes, and that name came to 276.
where the ceiling actually is
on ext4:
for n in (127, 128):
open("ب" * n, "w") # 127 letters = 254 bytes: ok
# 128 letters = 256 bytes: ENAMETOOLONG
127 Arabic letters, if the name is nothing but Arabic. spaces, digits and Latin are 1 byte each, so a real name lands somewhere between. diacritics are 2 bytes each too, so a fully voweled name runs out much sooner.
the fix for one file
copied it by hand under its first 60 characters plus ~, renamed it the same way on the Windows side so the two stay in sync, and wrote the mapping into a _renamed-files.txt at the root of the share.
the other trap: robocopy logs
robocopy’s log file, written with plain /LOG, uses the ANSI code page, so non-ASCII names come out garbled. /UNILOG writes it as Unicode instead. diffing the log name by name against the destination can’t be trusted for Arabic folders. compare file counts and byte totals instead, from live listings on both sides: find and du on the NAS, Get-ChildItem on Windows.
if you’re about to move an Arabic-heavy drive to Linux, find the long names first. from WSL:
find /mnt/f -printf '%f\t%p\n' | LC_ALL=C awk -F'\t' 'length($1) > 255 { print length($1), $2 }'
LC_ALL=C is what makes gawk count bytes. in a UTF-8 locale its length() counts characters, and the same command finds nothing. (mawk counts bytes either way.)