I am using rsync between Mac 10.13 (APFS) and Pop_OS (ext4) with a flash drive as transfer medium (FAT). My command is
rsync -av --exclude-from='exclude-files.txt' source-dir destination-dir
I am excluding the following patterns since I assumed they are only relevant to Mac:
*.DS_Store*
*.Spotlight-V100*
*.TemporaryItems*
*.Trashes*
*.fseventsd*
If a Mac file has any extended attributes, they appear on the FAT flash drive and my Linux system as hidden files, eg, ._exclude-files.txt
.
If I run ls -al@
on the flash drive mounted on my Mac, I do not see that ._exclude-files.txt
but I do see the following xattr list:
com.apple.TextEncoding 15
com.apple.metadata._kMDItemUserTags 42
com.apple.lastuseddate#PS 16
When I mount the flash drive on my Linux laptop, I do see ._exclude-files.txt
along with the actual file.
I have tried rsync dry runs with the -X
option with and without --filter='-x! user.*'
(although I admit to not completely understanding the concept of user namespace).
I can probably work around this problem by excluding *._*
, but I would rather understand why this is happening. I am new to Linux/Ubuntu/Pop, but my goal is to make it my main OS.
UPDATE: I wondered if my problem was created by initially copying directories from my Mac to my flash drive and then to my Linux system. So I ran a test where I used rsync
from a Mac directory into an empty directory on the flash drive. At first, ls -al@
on the flash drive directory mounted on my Mac showed the file without any xattr. So I deleted the contents of the original Mac directory and tried to rsync --dry-run
them back again. Once again the verbose output showed ._my-file.txt
even though that file had not shown any xattr.
When I tried this with -X
I got rsync error:
rsync: get_xattr_names(...) failed: Operation not permitted (1)
But the good news was that verbose output only showed my-file.txt being sent, not the mysterious ._my-file.txt.
I figured I could live with that and ran rsync -avX flash_drive_volume original_mac_dir
. Now the original file was back in its original location, but contrary to my expectations, it once again has extended attributes.
It's as if MacOS is determined to set extended attributes one way or the other. I would not care except that I don't want to fill my Linux system with irrelevant files. Maybe I should just add *._*
to my excludes and forget about this?
UPDATE 2: I found this explanation of the ._ files. Mac OS X: Apple Double Format Creates File Name With the Prefix '._'