#### How to Rename My Flash Drive on my Fedora 13 Linux #### # By Howard - March 26, 2011 # Problem : I don't like the name automount uses for my flash drive. Symptoms: - A crappy name shows in gnome file browser when flash drive is inserted. - The same crappy name is used as the dynamic mountpoint: /media/crappyname Causes: - flash drive has a crappy label to begin with! - flash drive has no label leaving the system to use the uuid number or some other string of it's choosing. Solution[s]: - If this is a msdos formatted drive -- relabel using dosfslabel -- relabel using mlabel - otherwise I have not done but see ntfslabel and e2fsfslabel recommended. So, instead of you having to read all the research steps (which are still below) Lets Cut To The Chase: #### after MUCH playing around it seems the best thing to do is: #### - with the flash drive in and still showing in gnome file browser (on the command line as root) - delete label with mlabel (if it has been used before this time) - assign desired label with dosfslabel - test it out... # if unsure if mlabel shows anything, check (if no mlabel I guess don't worry about it) ~> mlabel -i /dev/sdb1 -s :: Volume has no label # If needed do this: ~> mlabel -i /dev/sdb1 :: Volume label is FLASH_256 Enter the new volume label : Delete volume label (y/n): y # assign the new label: ~> dosfslabel /dev/sdb1 flash_256 # check it out: ~> dosfslabel /dev/sdb1 flash_256 # eject and re-insert drive and behold: - gnome browser shows new name: flash_256 - mountpint is: /media/flash_256 - mount -l shows the label [flash_256] - everybody's happy:) ##################################################################### # That's about all it boils down to. # If you have additional problems or want more info # all my previous notes are below: ##################################################################### #### Old: The original Problem: #### # I stick the PNY 8gb flash drive in. # It automounts to this: ~> mount ... /dev/sdb1 on /media/_body> <_ht type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) # That's right, a stupid-character name with a newline in it for extra kicks. # (It looks like an 11 character snip out of a frickin file.) # (How annoying to work with on the command line.) # Meanwhile the gnome file browser opens with the stupid-labeled drive open. # Ok - DO NOT EJECT IT FROM THE BROWSER !!! # That will not only umount it... # it will also remove it's device listing eg: /dev/sdb1 # ...instead close the browser and then umount it from the command line: ~> umount "/media/_body> <_ht" # So, the device remains listed , let's check it out: ~> ls /dev/sdb* /dev/sdb /dev/sdb1 # or ~> fdisk -l Disk /dev/sdb: 8036 MB, 8036285952 bytes 255 heads, 63 sectors/track, 977 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 ~> parted -l Model: PNY USB 2.0 FD (scsi) Disk /dev/sdb: 8036MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 22.5kB 8028MB 8028MB primary fat32 ##################################################################### #### One Suggestion: ############################################## # One forum suggestion was this: ( 2010-08-11 http://www.fedoraforum.org/forum/showthread.php?t=249897) ~> dosfslabel /dev/sdb1 NO NAME ~> dosfslabel /dev/sdb1 flash_8g ~> dosfslabel /dev/sdb1 flash_8g # but when replug it the name gnome file browser name is the same. # BUT at the same time dosfslabel does: ~> dosfslabel /dev/sdb1 flash_8g # weird... I think I'm doing that right but it's not gettin it. ##################################################################### #### Another Suggestion (and some success) ####################### # A Ubunto howto shows something different - mtools : ( 2010-08-24 https://help.ubuntu.com/community/RenameUSBDrive) # Ok so my first accomplishment there is to run this and get this info: ~> mlabel -i /dev/sdb1 -s :: Total number of sectors (15679396) not a multiple of sectors per track (63)! Add mtools_skip_check=1 to your .mtoolsrc file to skip this test ~> echo mtools_skip_check=1 >> ~/.mtoolsrc ~> mlabel -i /dev/sdb1 -s :: Volume label is _body> <_ht ~> # So now I attempt to change the label: ~> mlabel -i /dev/sdb1 ::flash_8 ~> dosfslabel /dev/sdb1 There are differences between boot sector and its backup. Differences: (offset:original/backup) 71:46/66, 72:4c/6c, 73:41/61, 74:53/73, 75:48/68, 78:08/67, 79:f8/20 , 80:a5/20, 81:95/20 Not automatically fixing this. FLASH_8 # hmm, I wonder if that's doing the same thing as dosfslabel~. # Well, NO! I replugged and it is different! ~> ls /media FLASH_~1A # ha, well it's better, but I don't understand what's going where, and why ... ~> ls /media/FLASH_~1A _works _OK # Ok but why did the name not stay FLASH_8 # Well I tried this to see what name would print and was suprised to # find that it prompted me for a new volumn label! ~> mlabel -i /dev/sdb1 :: Volume label is FLASH_~1A Enter the new volume label : flash_8gb # It took a couple of tries but this finally stuck: ~> umount /media/FLASH_8GB # I found will only write the label in upper case and I wants 9 characters. # # I tried my small flash drive and it came up with the same name it # always had: "257 mb Memory Device" which, even though I hate # spaces in a name, was better that the 8gb drive's name with the # newline and non-memorable characters. # Wierd thing there though was that even though that name showed # up in the file browser when I right clicked for properties it # showed "3B69-1AFD" as the name which also showed in: ~> ls /media 3B69-1AFD ~> mount /dev/sdb1 on /media/3B69-1AFD type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) # I umounted and renamed that too and it stuck: ~> umount /media/3B69-1AFD ~> mlabel -i /dev/sdb1 :: Volume has no label Enter the new volume label : flash_256mb ~> dosfslabel /dev/sdb1 FLASH_256MB # so that's enough of that for now. # I must say though, that it seems that name with the newline must be the # serial number just as the serial number shows up for the 256mb flash. # When I remove the label the name reverts back: ~> # plug 8g and close file browser ~> umount /media/FLASH_8GB ~> mlabel -i /dev/sdb1 :: Volume label is FLASH_8GB Enter the new volume label : Delete volume label (y/n): y ~> # replug and browser comes up with old name. and so does: ~> ls /media _body>?<_ht ~> mount /dev/sdb1 on /media/_body> <_ht type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) ~> # no problem! I'll just rename it again! First close browser and: ~> umount "/media/_body> > <_ht" ~> mlabel -i /dev/sdb1 :: Volume has no label Enter the new volume label : FLASH_8GB ~> # replug an voilllla ~> ls /media FLASH_8GB ~> mount /dev/sdb1 on /media/FLASH_8GB type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) ############ !!! ENOUGH ALREADY!!! ################################# After some more playing around, some more thoughts: Correct me if I'm wrong, but both of my flash drive have: - a serial # string identifier which is not changeable. - a label string which is changeable. Since their labels were blank in my case, the automount dude used the serial number as the "name string" for the node name on /media and then I guess the gnome browser dude uses that same name. Now, after assigning the custom label name: "FLASH_8GB", at each plug, - a matching mount point: /media/FLASH_8GB is created and - the gnome browser shows the same name: "FLASH_8GB". --- Opinion: --- "I" think that that "name string" is the problem. "I" think that if no label is found the user could be asked to provide one which would be: - written to the device label and - associated to the serial number from then on for that machine. The system would use the serial number for "true" identification. Associations of that number to other devices etc. will never change no matter what the label is. --- to continue: ----> Interestingly, as I saw suggested, I tried an /etc/fstab line like: /dev/sdb1 /media/flash1 vfat user,defaults 0 0 made the directory /media/flash1 and on the next plug - the drive WAS mounted at: /media/flash1, - /media/FLASH_8GB was NOT created - BUT the gnome browser still came up with the "FLASH_8GB" name - AND I could browse /media/flash1 successfully!!! so that gets a little confusing. I also noticed that when I plugged the other drive in (alone) It was mounted to the same /media/flash1 so it's not as distiguishable when using the terminal. With BOTH plugged and the fstab line I have: /media/flash1 /media/FLASH_256MB Without the fstab line I have: /media/FLASH_8GB /media/FLASH_256MB Also the second drive is assigned to /dev/sdh1 ... ...so another quirk with the /etc/fstab route. Of course I can figure it out either way but I think I prefer to just let automount do it's thing... So I think the relabel route is the way to go at this point. ##################################################################### But I went and tried dosfslabel again and this time with success: Here's what I did: As above, my first flash inserted is assigned to /dev/sdb1. First get set up: - plug the drive in - close gnome file browser without ejecting drive - from the command line as root do: umount /dev/sdb1 - the drive should still be listed as /dev/sdb1 Then get the present listing: root ~> dosfslabel /dev/sdb1 There are differences between boot sector and its backup. Differences: (offset:original/backup) 71:46/66, 72:4c/6c, 73:41/61, 74:53/73, 75:48/68, 78:47/67, 79:42/20 , 80:bf/20, 81:b6/20 Not automatically fixing this. FLASH_8GB�� That was is the present label as assigned earlier by mlabel: FLASH_8GB From the looks of that message, it appears that something was not quite "right" about the way mlabel relabeled it. Now assign a new label: root ~> dosfslabel /dev/sdb1 blah There are differences between boot sector and its backup. Differences: (offset:original/backup) 71:46/66, 72:4c/6c, 73:41/61, 74:53/73, 75:48/68, 78:47/67, 79:42/20 , 80:bf/20, 81:b6/20 Not automatically fixing this. root ~> dosfslabel /dev/sdb1 blah I note that dosfslabel assigned the label in lower case and did NOT padd it out to 11 characters! Now re-plug the drive: Gnome file browser opens showing the new drive label as the name! So does the mount point: root ~> ls -l /media lrwxrwxrwx. 1 root root 25 Oct 2 00:39 F13 -> /media/Fedora 13 i386 DVD drwxr-xr-x. 2 root root 4096 Mar 25 10:42 flash1 drwx------. 4 hlenderk hlenderk 32768 Dec 31 1969 blah root ~> ls /media/blah blah blah2 blah3 So THAT seems like a better solution. I don't know why it didn't work for me when I tried earlier... ##################################################################### Ok , this morning I do a little more with mlabel and dosfslabel -------------------- mtools and mlabel mlabel works but it makes the new label to strict specifications: - all uppercase - padded to 11 charactes - truncated to 11 characters Here are some lines I have tried. The -i option is for "image" and explained some in "man mtools" although the man pages are real tough to decypher. You must be root do use this tool: ~> mlabel -i /dev/sdb1 -s :: # show existing label ~> mlabel -i /dev/sdb1 ::newlab # create new label (with string supplied) (against ::dcolons ) ~> mlabel -i /dev/sdb1 :: # create new label label is: NONE # (prompt for string) Enter new label: newlab ~> mlabel -i /dev/sdb1 -s :: # note the modifications Volume label is NEWLAB¶_Q to the string! ~> mlabel -i /dev/sdb1 :: Volume label is NEWLAB¶_Q Enter the new volume label : Delete volume label (y/n): y ------------ dosfslabel I have had mixed success with this changing the label. Don't know why. ~> dosfslabel /dev/sdb1 #print the existing label NO NAME ~> dosfslabel /dev/sdb1 012345678901 # create a new label (failed) dosfslabel: labels can be no longer than 11 characters ~> dosfslabel /dev/sdb1 flash_256 # create new label ~> dosfslabel /dev/sdb1 # see how label looks ? flash_256 # Now check this out: ~> mlabel -i /dev/sdb1 -s :: Volume has no label ~> mount -l # here's how mount sees it: /dev/sdb1 on /media/flash1 type vfat (rw) [flash_256] This time when I replug the drive it automounts to /media/flash_256 Before it did not. It reverted to the last mlabel name. Now mlabel says: ~> mlabel -i /dev/sdb1 -s :: Volume has no label wierd... but wait , watch this: ~> mlabel -i /dev/sdb1 ::mlab ~> mlabel -i /dev/sdb1 -s :: Volume label is MLAB # Wow, it didn't padd it! ~> dosfslabel /dev/sdb1 dfslab # try this rename ~> dosfslabel /dev/sdb1 dfslab ~> mlabel -i /dev/sdb1 -s :: # holy crap now it sees thenew word Volume label is dfslab # is it the length? ~> mlabel -i /dev/sdb1 ::longer1 ~> dosfslabel /dev/sdb1 LONGER ~> mlabel -i /dev/sdb1 -s :: Volume label is LONGER~1A # hmm now back to it's padding. ~> dosfslabel /dev/sdb1 longer_yet! ~> dosfslabel /dev/sdb1 longer_yet! ~> mlabel -i /dev/sdb1 -s :: # there we go , broken again Volume label is LONGER~1A ~> mlabel -i /dev/sdb1 :: # seems that a good blanking Volume label is LONGER~1A # is what it needs! Enter the new volume label : Delete volume label (y/n): y ~> dosfslabel /dev/sdb1 flash_256 ~> mlabel -i /dev/sdb1 -s :: Volume label is flash_256 #### so after even MORE playing around it seems the best thing to do is: #### - with the flash drive in and still showing in gnome file browser - delete label with mlabel (if it has been used before this time) - assign desired label with dosfslabel - test it out... ~> mlabel -i /dev/sdb1 -s :: Volume has no label # If needed do this: ~> mlabel -i /dev/sdb1 :: Volume label is FLASH_256 Enter the new volume label : Delete volume label (y/n): y # assign the new label: ~> dosfslabel /dev/sdb1 flash_256 # check it out: ~> dosfslabel /dev/sdb1 flash_256 # eject and re-insert drive and behold: - gnome browser shows new name: flash_256 - mountpint is: /media/flash_256 - mount -l shows the label [flash_256] - everybody's happy:) ##### there enough of that! ##### ------------ mount root media> umount /dev/sdb1 root media> mount -t vfat /dev/sdb1 /media/flash1 # a plain jane mount But I'm still looking into using udevadm to see about writing a rule for the flash drive. ===================================================================== Presently my flash has a blank label and automount creates this dynamic mountpoint: /media/3B69-1AFD ~> mount -l | grep sdb1 #note - no [label] at end of this string /dev/sdb1 on /media/3B69-1AFD type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) ~> mlabel -i /dev/sdb1 -s :: #print the label string Volume has no label ~> dosfslabel /dev/sdb1 #print the label string NO NAME ~> dosfslabel /dev/sdb1 012345678901 # assign new label (fails) dosfslabel: labels can be no longer than 11 characters ~> dosfslabel /dev/sdb1 01234567890 #assign new label ~> dosfslabel /dev/sdb1 #print the label string - OK 01234567890 ~> mlabel -i /dev/sdb1 -s :: #print the label string - ??? Volume has no label ~> #when I eject and reinsert, automount uses the new label string /media/01234567890 #and it shows in file browser ~> mlabel -i /dev/sdb1 ::newlab #assign a new name using mlabel ~> mlabel -i /dev/sdb1 -s :: #mlabel shows it Volume label is NEWLAB~1A ~> dosfslabel /dev/sdb1 #dosfslabel shows it NEWLABX� ~> dosfslabel /dev/sdb1 01234567890 #attempt new label using dosfslabel ~> dosfslabel /dev/sdb1 #doslabel shows it 01234567890 ~> mlabel -i /dev/sdb1 -s :: #mlabel show the one it assigned Volume label is NEWLAB~1A ~> #and when I eject and reinsert, automount uses mlabels ~> /media/NEWLAB~1A ~> #now check this out mlabel -i /dev/sdb1 :: Volume label is Y~1_A Enter the new volume label : Delete volume label (y/n): y ~> mlabel -i /dev/sdb1 -s :: Volume has no label ~> dosfslabel /dev/sdb1 NO NAME ~> mlabel -i /dev/sdb1 ::sh ~> mlabel -i /dev/sdb1 -s :: Volume label is SH ~> dosfslabel /dev/sdb1 SH ~> mlabel -i /dev/sdb1 ::1 ~> mlabel -i /dev/sdb1 -s :: Volume label is 1 ~> dosfslabel /dev/sdb1 1 ~> dosfslabel /dev/sdb1 lowcase ~> dosfslabel /dev/sdb1 lowcase ~> mlabel -i /dev/sdb1 -s :: Volume label is lowcase ~> #so there you go! automount creates /media/lowcase ~> #Now hold on, 1 more set ~> mlabel -i /dev/sdb1 :: Volume label is lowcase Enter the new volume label : Delete volume label (y/n): y ~> ~> dosfslabel /dev/sdb1 short ~> dosfslabel /dev/sdb1 short ~> mlabel -i /dev/sdb1 -s :: Volume has no label ~> # automount creates /media/short !!! # So, it seems like there are 2 different labels used? # # Also, I can NOT seem to be able to blank the label using dosfslabel # Got an escape sequence hint for that? #--------------------------- # here is a new twist # mlabels' labels show up as symlink in /dev/disk/by-label: root ~> mlabel -i /dev/sdb1 ::test root ~> ls -l /dev/disk/by-label total 0 lrwxrwxrwx. 1 root root 10 Mar 24 00:43 FACTORY_IMAGE -> ../../sdc3 lrwxrwxrwx. 1 root root 10 Mar 24 18:32 HP -> ../../sdc1 lrwxrwxrwx. 1 root root 10 Mar 24 18:25 HP-Pavilion -> ../../sdh1 lrwxrwxrwx. 1 root root 10 Mar 28 11:12 TEST -> ../../sdb1 root ~> dosfslabel /dev/sdb1 next root ~> ls /dev/disk/by-label FACTORY_IMAGE HP HP-Pavilion next # ha, I replug and next is used in browser and mount: root ~> mount -l | grep sdb1 /dev/sdb1 on /media/next type vfat (rw,nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077,utf8=1,flush) [next] #now I try a trick: root ~> mlabel -i /dev/sdb1 ::longer root ~> ls /dev/disk/by-label FACTORY_IMAGE HP HP-Pavilion LONGER\x7e1A root ~> dosfslabel /dev/sdb1 next root ~> dosfslabel /dev/sdb1 next root ~> mlabel -i /dev/sdb1 -s :: Volume label is LONGER~1A root ~> ls /dev/disk/by-label FACTORY_IMAGE HP HP-Pavilion LONGER\x7e1A # HA! root by-label> rm LONGER\\x7e1A* rm: remove symbolic link `LONGER\\x7e1A'? Y root by-label> ls FACTORY_IMAGE HP HP-Pavilion root by-label> dosfslabel /dev/sdb1 test1 root by-label> dosfslabel /dev/sdb1 test1 root by-label> mlabel -i /dev/sdb1 -s :: Volume label is LONGER~1A root by-label> ls FACTORY_IMAGE HP HP-Pavilion LONGER\x7e1A root by-label> # AAAAHAHAHAHAHA magically reappears now remove drive # # I fiddle more and find that it is QUITE dynamic. # I can remove the link , assign a new word with dosfslabel. # and it and the comes right as the old word as soon as I check. # The link must get updated by the kernel at each event to the node? #