Labelling FAT/FAT32 partitions in Linux

by on Oct.23, 2008, under Linux, System Administration

Mostly a post for my future refererence, as it took some Googling to find this, but it might be useful to others.

I wanted to view/change the “drive label” for a FAT partition. This is done with the mlabel tool from the mtools package, but it has a strange insistence on setting up “drive letter” mappings, in /etc/mtools.conf or ~/.mtoolsrc, so that you can use it as, for example:

mlabel e:

Um, no thanks. I don’t want to map a Windows-like notion of drive letters to a partition which may appear at a different device each time (it’s a USB device; the point of having the label is to not have to know or care what device node it’s been assigned this time – if USB devices are connected in a different order, it might not be /dev/sdf next time).

The option needed is -i which doesn’t appear to be documented in the mlabel manpage, used along with the fake drive letter ::, for example:

# setting:
[dave@ruthenium ~]$ sudo mlabel -i /dev/sdf1 ::DAVEBLACKBERRY
# viewing:
[dave@ruthenium ~]$ sudo mlabel -s -i /dev/sdf1 ::
Volume label is DAVEBLACKBERRY

With that done, I can then add an entry to /etc/fstab which identifies the device by its label:

[dave@ruthenium ~]$ grep BLACKBERRY /etc/fstab
/dev/disk/by-label/DAVEBLACKBERRY /mnt/blackberry vfat defaults,uid=dave,gid=users 0 0

I should have been able to use LABEL=DAVEBLACKBERRY rather than the long /dev/disk/by-label/... notation, but LABEL= didn’t work, and I didn’t have tiem to figure out why :)

3 Comments for this entry

  • Jack Hackett

    Thanks for the ‘post’ Labelling FAT/FAT32 partitions in Linux.
    I used it to identify an External fat32 465Gb Drive.
    The Label worked fine, but as I’m new to Linux & NOT computer lit.,[I am using ubuntu 8.04.], I do not understand “add an entry to /etc/fstab which identifies the device by its label”.
    I tried……
    jack@jack-desktop:~$ grep External_HD /etc/fstab
    jack@jack-desktop:~$ /dev/sdb1/465Gb_HD/External_HD /mnt/External_HD
    bash: /dev/sdb1/465Gb_HD/External_HD: Not a directory

  • bigpresh

    By “add an entry to /etc/fstab” I mean that you should edit the file, and add a line similar to:

    LABEL=yourdisc label    /mnt/External_HD     auto    defaults  0   0

    (Basically, copy the format of the lines already in there, but specify the device as LABEL=labelname rather than /dev/sdb1 for instance.)

    (Also, in the past I seem to recall having problems using LABEL=labelname and had to use /dev/disks/by-label/labelname instead, for some reason.)

    Hope this is useful.

  • wayne

    Hey thanks for this info.
    I do data recovery using linux. I often attach a group of raid drives for recovery and figure out the arrangements and then when I reboot linux puts them in a different order…. Grrrr…
    This will help.
    If you need a recovery you can find me at
    Take Care

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!