posted by Christian Paratschek on Thu 10th Feb 2005 20:14 UTC

"VFat, Page 2/3"
Obviously, rsync will not like it when some filenames are suddenly written in small letters just because they coincidentally fit into the MS-DOS filename schema. These files will be transmitted on every synchronization attempt, even when they were not changed at all because rsync cares about upper and lowercase letters. Responsible for this problem is the standard mount parameter "shortname=lower".

The solution to this problem is to add the mount parameter "shortname=mixed". Now short MS-DOS-type filenames are displayed exactly the way they got created on the vfat partition. International (e.g. non-english) users may want to set their according codepage ("codepage=850" for German users as an example). This is important to keep correct special characters in the filenames of said shortname files. In practice, keeping the standard, "codepage=437" should be fine because the majority of the filenames are long ones anyway and these are stored in unicode. With the standard mount parameter "iocharset=iso8859-1" these are transformed into 8-bit filenames. If you use a unicode system (e.g. Fedora Core) you have to set "iocharset=utf8" explicitely.

File system permissions depend on the umask of the mount-user root and his user- and group-ID. To gain write access to the vfat partition also as normal user, set "umask=002" to give rights to read, write and execute to members of the group. All the other users do not have write access to the partition (can't be bad to treat a multi-user system accordingly!) Now add the parameter "gid=100" so all the files stored on the vfat partition belong to the group "users" (at least on my Debian system). Additionally, we'll add the parameter "uid=1000" to make sure that files copied from our source to the vfat partition don't get "root" but the actual user as owner. (On my system, 1000 is the user-ID of the main user "t" who is member of the group "users"). On my Fedora Core 3 system, I used "uid=500" and "gid=500" which is my user and group-ID)

	> mount /dev/sda1 /myvfat -t vfat -o shortname=mixed,codepage=850,umask=002,uid=1000,gid=100
	> mount | grep sda1
	/dev/sda1 in /myvfat type vfat (rw,shortname=mixed,codepage=850,umask=002,uid=1000,gid=100)
	> grep sda1 /proc/mounts
	/dev/sda1 /myvfat vfat rw,nodiratime,uid=1000,gid=100,fmask=0002,dmask=0002,codepage=cp850,shortname=mixed 0 0
	
	> cd /myvfat
	> ls -la
	-rwxrwxr-x     1 t    users    0 Dec 31 16:05 ABCDEFGH
	-rwxrwxr-x     1 t    users    0 Dec 31 16:05 ABCDEFGHI

If you want to add these options to your /etc/fstab, you may want to add the parameters "noauto" and "user", so that the file system does not get mounted automatically at system start and can be mounted by a normal user. The parameter "user" implies, for security reasons, also "noexec", "nosuid", and " nodev". This, however, should not be a problem in our example, because we assumed to deal with an external hard drive for pure data storage. If you want to execute programs on the vfat partition, add the parameter "exec". As an optimisation you can turn off the updating of the last file access mit the parameters "noatime" and "nodiratime", if you don't need this information. Personally, I do use this information, for example to find (with "find -atime -21") the audio files that I listened to during the last three weeks.

The resulting /etc/fstab-entry looks like this:

	/dev/sda1 /myvfat vfat shortname=mixed,codepage=850,umask=002,uid=1000,gid=100,noauto,user 0 0

	> mount /myvfat
	> mount | grep sda1
	/dev/sda1 on /myvfat type vfat (rw,noexec,nosuid,nodev,shortname=mixed,codepage=850,umask=002,uid=1000,gid=100)
	> grep sda1 /proc/mounts
	/dev/sda1 /myvfat vfat rw,nodiratime,nosuid,nodev,noexec,uid=1000,gid=100,fmask=0002,dmask=0002,codepage=cp850,
shortname=mixed 0 0

Further information can be found in the man-pages of the "mount"-command, especially in the sections "Mount options for fat" and "Mount options for vfat"

2.2. Adjusting the system time

A very sneaky problem occurs for everyone who uses a system time like "Europe/Berlin". Contrary to vfat, Unix file systems do take leap seconds in the past and daylight savings time into account. The time of the last file change of a file created in January would be deferred by one hour in June. As a consequence, rsync would transmit all files on every clock change.

An example:

	# On vfat during daylight savings time the date gets supplemented with the current time zone, thus being forged by one hour.
	> TZ=Europe/Berlin ls -l --time-style=full-iso /myvfat/testfile 
	-rwxrwxrwx [...] 2003-11-26 02:53:02.000000000 +0200 

	# On ext3 the date is displayed correctly also during daylight savings time.
	> TZ=Europe/Berlin ls -l --time-style=full-iso /myext3/testfile 
	-rw-rw-rw- [...] 2003-11-26 02:53:02.000000000 +0100 

As I did not find any mount parameter to change the time zone, I adjusted the system time to a zone that does not have daylight savings time (e.g. UTC) and set the local time zone "Europe/Berlin" for all users. As a consequence, however, all syslogd time stamps also use UTC instead of the local time zone.

Debian users can adjust this via "base-config". "Configure timezone" to "None of the above" and "UTC" gets the job done. Afterwards it should look like this:

	> cat /etc/timezone
	Etc/UTC

	> ls -l /etc/localtime
	[...] /etc/localtime -> /usr/share/zoneinfo/Etc/UTC

	# ~/.bash_profile
	export TZ=Europe/Berlin
Table of contents
  1. "VFat, Page 1/3"
  2. "VFat, Page 2/3"
  3. "VFat, Page 3/3"
e p (0)    26 Comment(s)