day macha
rsync, mkstemp, fat32, No such file or directory

When you rsync to a fat32 device you encounter problems. Problems because fat32 is an awful, awful filesystem. If you can simply not use fat32, do so. If you’re forced to use it (Hello) then here’s how to get around it.

On to the error messages. The first one you may encounter is:

rsync: mkstemp “YOUR_DEST_DIR/.FILENAME” failed: No such file or directory (2)

This mean rsync is trying to create a temporary file (that’s what mkstemp does), but fails to do so on your fat32 device. If you decide to get around this by giving rsync a new parameter —temp-dir=/tmp you encounter yet another error:

rsync: rename “FILE_IN_TEMP_DIR” -> “DEST_DIR”: No such file or directory (2)

A little searching[1] tells you that these error messages only come up when rsync tries to copy files from an all uppercase directory onto the DEST_DIR. Basically, rsync preserves file or directory names written in lower, upper or mixed case. And fat32 devices do not.

To force your fat32 device to preserve upper, lower or mixed case file and folder names mount it with the shortname option set to win95 or winnt (see man mount; win95 worked for me). Do something like this:

mount /dev/sda1 /media/storage -t vfat shortname=win95

Then your only problem is that fat32 devices poorly timestamp their files, and rsync depends on good timestamping. To make rsync ignore timestamps and go by file-size only give rsync the option:

—size-only

Now you’ve pandered to fat32’s awfulness, everything should work fine.

[1] http://ubuntuforums.org/showthread.php?t=203549

Blog comments powered by Disqus