Why Linux /etc/fstab UUIDs are case sensitive?
I recently added a line for a USB memory stick to /etc/fstab
, to be able to mount it automatically, using UUID to identify the device.
Before I already have several external ext4 drives that have their UUIDs written in lowercase hexadecimal chars [0-9a-f]
like this:
UUID=3eeaaa43-dead-beef-cafe-243bcaaad475 /media/external_2TB ext4 rw,user,noexec,nosuid,nodev,noatime 0 2
I checked the UUID of my USB stick with blkid
, got an uppercase hexadecimal UUID and entered it in /etc/fstab
in the same way as the ext4 lines, in lowercase hexadecimal, like this:
UUID=125c-a3eb /media/usb_8GB vfat defaults,users,umask=0 0 0
mount: special device UUID=125c-a3eb does not exist
Then I got an idea to try it in uppercase (gU3w in Vim) and it worked without problems. To confirm this, I unmounted, and changed the UUID back to lowercase, mount failed, and back to uppercase, and mounted successfully.
As far as I have understood, UUID is a hexadecimal number, not a string, so the case of letters should be irrelevant. But clearly it's not. RFC4122 defines UUID as "case insensitive on input". Is there something I have missed or is this mount
/ umount
behavior a bug?
I'm using Debian GNU/Linux 7.0 Wheezy with a custom kernel version 3.6.8, if that matters.
Solution 1:
NOTE: This is speculation, based on how devices are typically accessed in Unix/Linux and the fact that the filenames are case-sensitive.
Linux uses the UUIDs to create objects in /dev/disk/by-uuid
. Like any "file" on Linux, the name is case sensitive. Hence when referring to disks by UUID, the comparison is done as a file-name comparison on the hex strings rather than a binary comparison on the data represented by said strings.
Solution 2:
in case of vfat we effectively don't see a full blown UUID. It's a Volume ID (serial number) instead. These of course are not subject to the RFC mentioned above.