48

I know I can set the volume name when I format the partition with the -n option of mkfs.vfat. But how to just change the name without formatting?

I especially want to be able to use lower and uppercase letters. In worst case, I can use a windows tool, but windows by default transforms all letters to uppercase (but works fine with lowercase letters in volumes created with mkfs.vfat).

54

Dosfstools, which provides mkfs.vfat and friends, also provides fatlabel (called dosfslabel in older versions) to change the label.

  • I will try this in some days. Do you know if it can save lower-case letters? – Den Jul 30 '12 at 5:51
  • It didn't work whit lower case letters. And after use, I got errors on the file system.... – Den Sep 20 '12 at 2:48
  • dosfslabel changed from supporting lower-case labels as of version 3.0.12 to rejecting them in 3.0.16 – D McKeon Jan 9 '14 at 20:11
  • 1
    @DMcKeon: it seems to work in 3.0.27, with a warning. – Craig McQueen Feb 29 '16 at 3:51
  • blivet (at least, blivet3-data-3.1.3-3.el7) rejects lower-case labels for EFI partitions. dosfslabel (aka fatlabel, from dosfstools-3.0.20-10.el7) accepts them with a warning. So, blivet's being preemptively annoying. – stolenmoment Oct 9 at 20:56
20

For my USB drive mlabel did not work, but fatlabelworked!

fatlabel /dev/device

gives you label

fatlabel /dev/device NEW_LABEL

sets new label

  • Because we label a file system and usually it is on a partition here is my command: sudo fatlabel /dev/sdXN NewLabel (/dev/sdf1, for example) – Mikolasan Oct 29 at 17:50
4

Have a look at the ubuntu page about renaming usb drives, it's basically:

mlabel -i <device> ::<label>
  • Thanks! Change the name works, but it is transvormed to upercase: # mlabel -i /dev/sdc1 ::redsd # mlabel -i /dev/sdc1 -s :: Volume label is REDSD – Den Jul 27 '12 at 3:31
  • 1
    @Den FAT disk labels are uppercase only – Matteo Jul 27 '12 at 15:35
  • 1
    @Matteo I have here a HD whit FAT32 which have lower and upper case letters in the name: mlabel -vi /dev/sdb1 -s :: Volume label is miniTR – Den Jul 30 '12 at 5:50
  • 1
    @Den yes FAT32 supports it. It is most likely a FAT16 formatted drive. – Matteo Jul 30 '12 at 7:11
  • @Matteo Thanks for confirming I'm not completely silly ;-) The device I try to rename is a 15.9 GB FAT32 formated SD card. – Den Aug 17 '12 at 1:39
4

The solution is to use mkdosfs (mkfs.vfat) : it lets the user specify the volume label using the -n flag, and lowercase letters are kept lowercase, but this tool recreates the filesystem, so all data will be lost.

The non-destructive solution below is a combination of the mlabel and dosfslabel command-line tools.

  1. Connect the device to the computer if not already connected.
  2. Open a terminal window.
  3. Run blkid | grep ' TYPE="vfat"' and </proc/mounts grep ' vfat ' to figure out the name of the device (e.g. /dev/sdb1). Look around in /media etc. to confirm you have picked the right device. If unsure, unplug it, run the commands again, see it disappear, plug it back, and run the commands again.
  4. Unmount the device by running umount /dev/sdb1 (substituting /dev/sdb1 with the name of the device found above). If it was mounted, and the unmount failed, then close some windows, kill some programs (e.g. fuser -m /dev/sdb1), and try unmounting again.
  5. Run sudo env MTOOLS_SKIP_CHECK=1 mlabel -i /dev/sdb1 ::x (substituting /dev/sdb1 with the name of the device found above). If the system can't find mlabel, then install it by running sudo apt-get install mtools , and try again.
  6. Run sudo dosfslabel /dev/sdb1 MyLabel (substituting MyLabel with the desired label and /dev/sdb1 with the name of the device found above). Ignore any warnings about boot sector differences. If the system can't find dosfslabel, then install it by running sudo apt-get install dosfstools , and try again.
  7. Run blkid | grep ' TYPE="vfat"', and examine its output to verify that the label has been changed properly. Optionally, unplug the device, and then plug it back in. The system will recognize it, and mount it under /media/MyLabel, without converting lowercase letters in the volume label to uppercase.

Please note that there is an 11 character limit on the length of a VFAT volume label. If you specify a longer label, it will be truncated. There is another restriction: the label can contain only (some) ASCII characters: accented letters etc. won't work.

  • Thanks for your long answer! Can you explain what the command in 5. is doing exactly? It sets the label to 'x'? – Den Feb 23 '16 at 13:19
2

So far the only way I found to change FAT volume name whit lower cases is to edit it whit a hex-editor (copy the first few sectors whit dd to a temp file, edit it and copy it back). It works well so far (even whit FAT16) and neither fsck nor CHKDSK from Win7 complained. But no guarantee of course ;-)

2

The above commands didn't worked for me on Rasberry Pi / Rasbian Jessie 8. I decided to go with gparted.

Go to the Menu: Partition / Label. Write your desired name and then click on the green pipe (apply).

After the procedure you can see the details hided under the "multiple" + sign. There is a command total other:

 mlabel ::"LABEL_NAME" -i/dev/sda1
0

For a GUI alternative, gparted has a Label File System menu item for many file systems, including VFAT. It becomes available after unmounting the file system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.