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).
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Dosfstools, which provides mkfs.vfat and friends, also provides fatlabel (called dosfslabel in older versions) to change the label.
Method 2
For my USB drive mlabel did not work, but fatlabelworked!
fatlabel /dev/device
gives you label
fatlabel /dev/device NEW_LABEL
sets new label
Method 3
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.
- Connect the device to the computer if not already connected.
- Open a terminal window.
- 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.- Unmount the device by running
umount /dev/sdb1(substituting/dev/sdb1with 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.- 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.- Run
sudo dosfslabel /dev/sdb1 MyLabel(substituting MyLabel with the desired label and/dev/sdb1with 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.- 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.
Method 4
Have a look at the ubuntu page about renaming usb drives, it’s basically:
mlabel -i <device> ::<label>
Method 5
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 😉
Method 6
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
Method 7
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.
Method 8
An update :
Since now, the FAT32 file system has been superseded by the new exFAT for most flash devices, you my find that fatlabel do not work on many cards. you should the try exfatlabel instead of fatlabel
Method 9
Apologies for coming back to this 7 years later, but this is a top answer on google for the question, and I didn’t have any of the tools suggested in the existing answers on the system I was using.
As a last resort,
if [ "`dd if=/dev/hda1 bs=1 count=7 skip=54 2>/dev/null`" = 'FAT16 ' ] ; then echo -n 'MYNEWLABEL1' | dd of=/dev/hda1 seek=43 count=11 bs=1 conv=notrunc elif [ "`dd if=/dev/hda1 bs=1 count=7 skip=82 2>/dev/null`" = 'FAT32 ' ] ; then echo -n 'MYNEWLABEL1' | dd of=/dev/hda1 seek=71 count=11 bs=1 conv=notrunc fi
ought to work.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0