jump to navigation

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

Comments»

1. arsgeek - March 1, 2006

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)

2. havoc - March 1, 2006

dude, you rock.

3. ubuntonista - March 2, 2006

Aw, thanks, folks!
I exist to serve 🙂

4. Brian (Madpilot) - March 4, 2006

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

5. ubuntonista - March 4, 2006

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.

6. LKRaider - March 9, 2006

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?

7. ubuntonista - March 10, 2006

Oh yes, after you are done using it, you can remove the app,and the .mtoolsrc file.

8. Luke Turner - October 28, 2006

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.

9. vetdoc172 - November 13, 2006

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!

10. huehnerich - December 1, 2006

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.

11. RQ - December 8, 2006

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…

12. LeRoy - December 18, 2006

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 –

13. kevin - December 18, 2006

thanks for the info on FAT32 drives

14. Tobler - January 17, 2007

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?

15. Louis - January 29, 2007

@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.

16. Ed Catmur - February 19, 2007

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.

17. Keith - May 21, 2007

Thank you for the tip!

18. Ben - May 22, 2007

Magic! Actually went to the ubuntu wiki, but kudos to you mate!

19. john white - May 27, 2007

thanks. awesome tip.

20. Dion - May 30, 2007

Thanks for making this info findable. Worked perfectly 🙂

21. Erik Weibust - August 1, 2007

I’ll add the same note most others have…. GREAT WORK! This tutorial was extremely helpful.

Erik Weibust

22. Zwopper - August 3, 2007

Thanx a million!

23. strat - August 16, 2007

Fantastic, solved my problem with dynamic usb mount points /sdb one day /sde the next. Cheers 🙂

24. gedanken - September 30, 2007

re: Ed Katmur

I still had to add mtools_skip_check=1 even with the :: modifier

gedanken

25. Editing FAT32 file attributes - LinLog - October 26, 2007

[…] 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 […]

26. 4ndY - December 1, 2007

tnx, it works 😉

btw why is there no option in Gnome GUI to rename, for example: right click on drive icon and “rename drive”?

27. EricBKR - December 17, 2007

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

28. Oleksiy - June 4, 2008

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. 🙂

29. prof ylno - July 5, 2008

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.

30. DeNNiS - July 23, 2008

@ post #16

yup i did the same thing:

$sudo mlabel -i /dev/sdb1 ::label-name

no fussing with /.mtoolsrc

31. canis - March 4, 2009

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.

32. giorgiob - April 9, 2009

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

33. DanyaelX - May 12, 2009

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?

34. tux - December 9, 2009

u can also use Gparted Partition Editor, its also got a nice GUI which will be very helpful for new Linux users.

35. Melabeli UFD Flash Disk - May 4, 2010

[…] LinkedIn […]

36. porno sikiş - September 27, 2010

I exist to serve 🙂

37. sex sikiş - September 28, 2010

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…

38. porno - December 2, 2010

sevgiler saygılar

39. Ryan Hoopes - December 25, 2010

Thank you.

40. Rasto - January 28, 2011

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)

41. Used Dell Laptops - May 13, 2011

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!

42. Patrick - June 7, 2011

Thanks for this interesting doc!

43. Change partition label - June 19, 2011

[…] 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 […]

44. AKO - January 5, 2012

We have been visiting variousblogs for my dissertation study. Ive discovered your blog being quite beneficial.

45. thejobboarder - February 7, 2012

very interesting blog

46. Editing FAT32 Partition Labels in Linux using mtools « Le Veilleur - March 15, 2012

[…] attente de traduction, repompe pure et simple de https://embraceubuntu.com/2006/03/01/editing-fat32-partition-labels-using-mtools/ […]

47. Home - July 13, 2014

wholesale e liquid Editing FAT32 Partition Labels using mtools | Ubuntu Blog

48. best way to get rid of pimple scars - August 9, 2014

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.

49. DonaldPr - October 9, 2014

Мятный цвет в одежде – модный Look


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: