Editing FAT32 Partition Labels using mtools March 1, 2006
Posted by Carthik in administration, applications, guides, ubuntu.trackback
I wanted to rename the fat32 partitions that get automounted when they are plugged in to the USB drive. Two were exactly similar external hard disk drives, and one was an iPod. The exactly similar hard disk drives (one each at home and work) were both getting mounted at /media/sda1 or sda2 etc, and it was impossible to distinguish one from the other easily. Also, I found that it wasn’t that easy to edit the partition labels for FAT32 partitions. So I thought I would summarize how I named my fat32 partitions to have consistent names. This has the benefit that when these drives are automounted, they will be at the location /media/partition-label
, where partition-label is the label that you give the partition.
Step by step instructions to re-label FAT partitions follow:
1) Install mtools:
$sudo apt-get install mtools
2) After the usb drive is automounted after plugging in, find out the device descriptor using:
$mount
and Note down where it says “sda1” or similar
3) copy the mtools.conf
to ~/.mtoolsrc
$cp /etc/mtools.conf ~/.mtoolsrc
4) Edit ~/.mtoolsrc
to add one line at the very end:
drive i: file="/dev/sda2"
–you may have to change sda2 to something else depending on what you got in step 2 above.
5) Change to the “drive” i:
$mcd i:
6) Check what the label for the drive is currently:
$sudo mlabel -s i:
7) Change the label to something pretty:
$sudo mlabel i:my-ipod
8) Check if the label has changed:
$sudo mlabel -s i:
I got the following output —
Volume label is MY-IPOD
You’re all set!! The next time that partition gets automounted, it will be at /media/MY-IPOD
Hello there! This is a great tip and saved me quite a headache in trying to figure this one out on my own.
I’ve been reading your blog for about two months now and I’m constantly impressed with the tips, tricks and general neat stuff you’ve posted here. Cheers from a fellow wordpresser and geek.
Ben (arsgeek)
dude, you rock.
Aw, thanks, folks!
I exist to serve 🙂
Hi, someone has added this howto to the official Ubuntu wiki at https://wiki.ubuntu.com/RenameUSBDrive – if you’re OK with that you can just leave it, but if you’d rather it hadn’t been copied, feel free to delete it.
(Whoever added it to the wiki might have contacted you first, though – it doesn’t say on the page.)
It’s a useful howto, though!
Thanks,
Brian
Brian,
I have no problems with stuff being copied over to the wiki. In fact, I am glad it happened without me having to do it. No problemo.
The tips I write here are mostly from the ubuntu-users list, and so this is not at all a problem.
Thanks for a great how-to !
Two questions tho: Can I remove mtools after doing this? And do I have to keep the .mtoolsrc file?
Oh yes, after you are done using it, you can remove the app,and the .mtoolsrc file.
Can this procedure also rename INTERNAL drives?
I want to rename my disc drives, but Ubuntu won’t allow it the way it allows other things to be renamed.
For example, I’ve got 2 floppy drives that Ubuntu simply calls “Floppy Drive” and “Floppy Drive (2)”; and I also have a hard drive that Ubuntu lables “Filesystem”.
I want to change them to “5.25 Floppy” and “3.5 Floppy” and some other cute name for my hard drive.
The names I’m talking about are the texts under the icons.
None of these names will Ubuntu allow me to change. More precisely, I can get access to the name text, then make the change, then mouse-click out of the name space, but then I get an error message saying I can’t rename that thing, and with no explanation as to why.
I use Dapper Drake all updated.
Hi ubuntonista,
Thanks for your great description! I was just trying to rename my new USB stick realising that it is not possible. So I “googled” for a solution and found your great blog – keep going!
Hi ubuntonista,
I had some massiv problems with the renaming:
USB disk with 3 partitions (1 ext3, 2 x vfat). I tried to rename both vfat. Atfter the reboot all three were not automounted.
Instead both renamed partitions were shown as new entries in the media folder with the empty file “.created_by_pmount” mountable only by root and the labels were shown both in upper cases.
Normal user gets error “~ not able to exucute pmount” (get the error in german ->fehler: konnte pmount nicht ausführen). Root was able to mount partitions and then access for normal user was possible.
How can I redo the changes? Is there a way back to the original config? Or is there a little workaround that make it easier for newbees?
Looks like I have to get more experience first with easier stuff 😉
thanks for your time
H.
huehnerich: You simply have to unplug the USB drive and plug it back again, if you’re rebooting. That’s because Ubuntu assumes all the disks/partitions that are available upon boot, belong to the root user. That’s security measure, maybe.
Talking about lowercase/uppercase: I have only managed to make partition names lowercase using mkdosfs (an alternative for “format” under Windows – you know what it does, don’t you? :D). mlabel seems to only use uppercase in labels…
Great! I didn’t get it to work thou 😦 — BUT it did fix the problem I was having. Some how the FAT was corrupted on my Ipod. — I was able to use mformat to fix it (I didn’t think it worked, I had to unplug the ipod and plug it back in) I then used gkpod to write the files and directory to the ipod, and my ipod started working again!
Even thou I didn’t get the label thing to work – mtools seems to be invaulable when working with FAT32 drives – Thanks for the info –
thanks for the info on FAT32 drives
My Edgy Eft mtools does not like USB harddrive. It is partitioned to two partitions and second is VFAT formatted. But mtools is comlaining about this partition, what ever I try to do with it.
# mdir z:
Total number of sectors not a multiple of sectors per track!
Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
I didn’t try skip_check option if it helps. Is there any other tools available to rename drive name, except hex editor?
@Tobler:
I got the same skip_check option, and when I put it in it worked perfectly. I’m not sure what it means, but my USB drive has been named fine and nothing is wrong.
Thanks! If you use the special “::” drive you can specify the device node on the command line; you don’t have to futz around with ~/.mtoolsrc. I’ve updated the Ubuntu wiki https://help.ubuntu.com/community/RenameUSBDrive to add this info.
Thank you for the tip!
Magic! Actually went to the ubuntu wiki, but kudos to you mate!
thanks. awesome tip.
Thanks for making this info findable. Worked perfectly 🙂
I’ll add the same note most others have…. GREAT WORK! This tutorial was extremely helpful.
Erik Weibust
Thanx a million!
Fantastic, solved my problem with dynamic usb mount points /sdb one day /sde the next. Cheers 🙂
re: Ed Katmur
I still had to add mtools_skip_check=1 even with the :: modifier
gedanken
[…] a quick and useful tactic for dealing with file attributes on FAT32 drives. I got the idea from this post on the Ubuntu blogMy new MP3 player (which I’ll be blogging about when I have more time) uses a FAT32 filesystem. I […]
tnx, it works 😉
btw why is there no option in Gnome GUI to rename, for example: right click on drive icon and “rename drive”?
Thanks, it worked for me.. to a certain extent.
How can I do to mix upper and lower case in the name of my vfat partition?
I’m running on Ubuntu Feisty.
Eric
After digging around, found this:
root# mlabel -i /dev/sdc1 ::
Lets you to not mess with .mtoolsrc.
However it is not mentioned in man page about this for some reason.
Anyway it worked for me, so that might help someone too. 🙂
In my pursuit of using a lower case label, I decided to just find where the label was on the disk, and write a little program to change the appropriate bits manually. First, I changed the part of the boot sector that’s supposed to be for the volume label. But then I learned that this has been deprecated in favor of a file on the disk containing the label. Unfortunately, I couldn’t find said file, but I figured the name must be in there somewhere, so I ‘hexdump -C’ed the device and ‘grep’ed for the current name of the disk. Then I had the program write the new label to the disk at all the places where the old one showed up. Now, this might not be very intelligent, but it worked for me and allowed me to use whatever case I want.
@ post #16
yup i did the same thing:
$sudo mlabel -i /dev/sdb1 ::label-name
no fussing with /.mtoolsrc
Great tip!
Using your guide I have created a read-only autorun.inf on my USB dongle. I do not have to worry about transfering viruses between multiple windows machines.
Yes! I used to solve this by copying the files on a temp disk, reformat the usb key with the -L “label” option an then recopy the files into the usb… Really annoying!
Thank u!
Ciao!
Giorgio
I followed your steps and in ubuntu it has changed but on the ipod its still the old name.
How do i change the name in the Ipod?
u can also use Gparted Partition Editor, its also got a nice GUI which will be very helpful for new Linux users.
[…] LinkedIn […]
I exist to serve 🙂
Talking about lowercase/uppercase: I have only managed to make partition names lowercase using mkdosfs (an alternative for “format” under Windows – you know what it does, don’t you? 😀 ). mlabel seems to only use uppercase in labels…
sevgiler saygılar
Thank you.
It helps to specify /dev/disk/by-id/someId in mtools.conf if You want to use this association later across reboots.
/dev/sd* links are not persistent (for example You add another disk, then Your /dev/sda2 can point to somethink else)
It’s really an interesting fact which I just got to know via this blog. Making this blog and keeping it updated is the best possible thing which customer always ask for. So I would like to thank for this interesting knowledge given by the moderator!
Thanks for this interesting doc!
[…] How do I change the partition label of a drive in openSuse. I am using KDE. I have this howto: Editing FAT32 Partition Labels using mtools But its too long and requires to edit configuration files, when actually for removable media this […]
We have been visiting variousblogs for my dissertation study. Ive discovered your blog being quite beneficial.
very interesting blog
[…] attente de traduction, repompe pure et simple de https://embraceubuntu.com/2006/03/01/editing-fat32-partition-labels-using-mtools/ […]
wholesale e liquid Editing FAT32 Partition Labels using mtools | Ubuntu Blog
This is a natural occurrence and can be easily mistaken for acne.
In addition, a lot of common substances may be utilized to fight dry
skin. You can use it for chapped lips, dry skin,
and anything else you would normally use petroleum jelly for.
Мятный цвет в одежде – модный Look