1

Topic: Partition Label: only capital letters?

With the version of gparted that I had on Ubuntu 9.04,
I could set a label to my external disk: Transcend

Now, in ubuntu 10.04, the same disk appears as
TRANSCEND (all capitals). I've tried to change it
back with gparted, but I always get the label
in capital letters, even if I write it with small caps

This is a problem as I have many scripts using Transcend
and not TRANSCEND (i.e., my backup...)

Is there any way to set the label back to Transcend ?

Thanks

Agus

2

Re: Partition Label: only capital letters?

Different tools read labels in different ways.  Some will upper case the entire label similar to the way DOS used to, even though the actual label is written on the disk as lower case.

You can try the "blkid" and "vol_id" commands (with root privileges) to see what these return.

3

Re: Partition Label: only capital letters?

gedakc wrote:

Different tools read labels in different ways.  Some will upper case the entire label similar to the way DOS used to, even though the actual label is written on the disk as lower case.

You can try the "blkid" and "vol_id" commands (with root privileges) to see what these return.

This is what I get:
alobo@alobo-laptop:~$ sudo blkid
/dev/sda1: UUID="7074DF6774DF2F1A" TYPE="ntfs"
/dev/sda2: UUID="0ce7c849-ecfe-4593-90f4-a9c1ed69aeb4" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda4: UUID="4816-D9F2" TYPE="vfat"
/dev/sda5: UUID="27f7552d-d0bc-470b-a329-dbfacc2d8e3b" TYPE="swap"
/dev/mmcblk0p1: LABEL="CANON_DC2" UUID="1111-A131" TYPE="vfat"
/dev/sdb1: LABEL="EXCHANGE" UUID="606C-87A6" TYPE="vfat"
/dev/sdb2: LABEL="TRANSCEND" UUID="D661-7C91" TYPE="vfat"
alobo@alobo-laptop:~$ sudo vol_id
sudo: vol_id: command not found

but this does not solve the problem. I've tried to set the label to "Transcend" using
gparted menu Partition/Label, but it is always TRANSCEND. This was not the case under ubuntu 9.04

Agus

4 (edited by gedakc 2010-05-12 17:26:14)

Re: Partition Label: only capital letters?

Since the file system you are using is FAT16/32, there are two more tools you can use to read the label.  These are "dosfslabel" and "mlabel".

Currently GParted uses the mlabel command (part of the mtools package) to write labels.  If "blkid" is missing, then GParted uses "vol_id" to read the label.  If both of these are missing then GParted will try to use "mlabel" to read the label.

To see how the kernel views the labels, you can try "ls -l /dev/disk/by-label".

As you have discovered, each one provides different output.  GParted does write the label using the type case that you enter.  How it is displayed on output depends upon which tools are installed on the GNU/Linux distribution.

If you view these labels from another operating system, you might find that the type case display also differs.

I think this problem is limited to FAT16/FAT32 file systems and dates back to early DOS days when all file names were upper case.

5

Re: Partition Label: only capital letters?

This is the output of  ls -l /dev/disk/by-label
alobo@alobo-laptop:~$ ls -l /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 15 2010-05-12 18:36 CANON_DC2 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 2010-05-12 19:47 EXCHANGE -> ../../sdb1
lrwxrwxrwx 1 root root 10 2010-05-12 19:47 TRANSCEND -> ../../sdb2

I'm understanding that GParted writes "Transcend" but the OS now uses a tool that reads "TRANSCEND", perhaps because vol_id does not exist any more in ubuntu 9.10.
But is there any way of getting TRANSCEND mounted as /media/Transcend
as I had it under ubuntu 9.04?

Thanks!

Agus

gedakc wrote:

Since the file system you are using is FAT16/32, there are two more tools you can use to read the label.  These are "dosfslabel" and "mlabel".

Currently GParted uses the mlabel command (part of the mtools package) to write labels.  If "blkid" is missing, then GParted uses "vol_id" to read the label.  If both of these are missing then GParted will try to use "mlabel" to read the label.

To see how the kernel views the labels, you can try "ls -l /dev/disk/by-label".

As you have discovered, each one provides different output.  GParted does write the label using the type case that you enter.  How it is displayed on output depends upon which tools are installed on the GNU/Linux distribution.

If you view these labels from another operating system, you might find that the type case display also differs.

I think this problem is limited to FAT16/FAT32 file systems and dates back to early DOS days when all file names were upper case.

6

Re: Partition Label: only capital letters?

alobo wrote:

This is the output of  ls -l /dev/disk/by-label
alobo@alobo-laptop:~$ ls -l /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 15 2010-05-12 18:36 CANON_DC2 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 2010-05-12 19:47 EXCHANGE -> ../../sdb1
lrwxrwxrwx 1 root root 10 2010-05-12 19:47 TRANSCEND -> ../../sdb2

I'm understanding that GParted writes "Transcend" but the OS now uses a tool that reads "TRANSCEND", perhaps because vol_id does not exist any more in ubuntu 9.10.
But is there any way of getting TRANSCEND mounted as /media/Transcend
as I had it under ubuntu 9.04?

Hmm..  good question.  If the kernel now sees the label as upper case, then I think you probably need to match that for the "mount" command to work.

Of course you could try reading the man page for the "mount" command to see if there is an option to ignore case or something like that.

7 (edited by santiago_nasar 2010-06-01 07:39:06)

Re: Partition Label: only capital letters?

alobo wrote:

is there any way of getting TRANSCEND mounted as /media/Transcend
as I had it under ubuntu 9.04?

I might be a bit late in answering this, but if you just want to mount the drive as /media/Transcend, then it doesn't matter what the label is as long as you set up /etc/fstab accordingly. 

For example, this website would explain how to deal with your problem:
http://www.mylinuxway.com/how-rename-yo … ume-label/

In addition to mounting by UUID as they do on that website (according to what you posted, your UUID for that drive is D661-7C91), you can also mount by label, so instead of saying UUID=D661-7C91, you could choose to say LABEL=TRANSCEND.  It's a matter of preference which way you do it.

So you would back up /etc/fstab:

root-prompt#cp /etc/fstab /etc/fstab_saved

then as root open /etc/fstab, remove a line in it that might mention D661-7C91, /dev/sdb2 or TRANSCEND (it probably doesn't exist though), and put in its place a line like the following (if the line never existed then just put the following as its own line in the file):

UUID=D661-7C91 /media/Transcend vfat default 0 0

or

LABEL=TRANSCEND /media/Transcend vfat default 0 0

Instead of by label or UUID you can also mount by device file name, but that's not as reliable.

Then when that's all done you can plug in your drive.  It will probably show up on its own as /media/Transcend, but if it doesn't you can type

mount /media/Transcend

just as a regular user, and it should mount as you want it to.

8 (edited by mwk 2010-12-02 14:05:49)

Re: Partition Label: only capital letters?

This is caused by mlabel converting the user input to all-uppercase.

Try this:

> dd if=/dev/zero of=fat32.img bs=1000000 count=100
> /sbin/mkdosfs -F 32 fat32.img
> mlabel -i fat32.img ::fOoBaR
> hexdump -C fat32.img | grep -i foobar
00000040  00 00 29 cd d0 4c b0 46  4f 4f 42 41 52 20 20 20  |..)..L.FOOBAR   |
00000c40  00 00 29 cd d0 4c b0 46  4f 4f 42 41 52 20 20 20  |..)..L.FOOBAR   |
0017bc20  46 4f 4f 42 41 52 20 20  20 20 20 08 00 00 f2 55  |FOOBAR     ....U|

And then for comparison:

> /sbin/dosfslabel fat32.img fOoBaR
> hexdump -C fat32.img | grep -i foobar
00000040  00 00 29 cd d0 4c b0 66  4f 6f 42 61 52 20 20 20  |..)..L.fOoBaR   |
00000c40  00 00 29 cd d0 4c b0 66  4f 6f 42 61 52 20 20 20  |..)..L.fOoBaR   |
0017bc00  66 4f 6f 42 61 52 20 20  20 20 20 0f 00 e2 52 00  |fOoBaR     ...R.|
0017bc20  46 4f 4f 42 41 52 20 20  20 20 20 08 00 00 f2 55  |FOOBAR     ....U|

FAT labels are generally highly confusing. Some observations:

  • The label is stored in two places: Once in the boot sector and again in a special file in the root directory.

  • When both instances are present and different, Windows XP displays the label according to the special file in the root directory. When the label is changed, Windows XP only updates the instance in the special file. Therefore both instances can and will get out of sync if Windows is used; the instance in the boot sector is de facto useless.

  • If the label contains lowercase characters, Windows XP displays them all-uppercase. When the label is changed and the input contains lowercase letters, Windows XP saves them all-uppercase.

  • What mlabel does is almost the same as what Windows XP does. The only difference I noticed is that mlabel also updates the instance in the boot sector if the label is changed.

  • What dosfslabel (from package dosfstools, version 3.0.10) does is totally different. When the label is changed, dosfslabel updates both instances (like mlabel), but when asked for the current label, dosfslabel displays the one from the boot sector (which noone else uses)! Furthermore, dosfslabel accepts lowercase letters and also displays them lowercase.

For gparted users, this means that a lowercase label can be entered on filesystem creation (because then mkdosfs from package dosfstools is used, which accepts lowercase letters), but on an already existing filesystem, no lowercase letters can be entered (because then mlabel is used, which doesn't accept lowercase letters).

9

Re: Partition Label: only capital letters?

Thank you for the detailed post mwk.  It would seem that none of the tools is completely consistent in the way these labels are handled.

Longer term I am planning to replace mlabel with dosfslabel for handling volume labelling on FAT16/32 file systems.  This will remove one dependency, namely the mtools package.

There is an open bug report on this item:
Bug 576616 - Cannot set label of fat32 partition with dosfstools

What are your thoughts in this matter?  Should GParted continue to use mlabel, or does dosfslabel make more sense?

10

Re: Partition Label: only capital letters?

Hi gedakc,

what GParted should use is exactly the question I've asked myself. I have edited my post above once - originally I wrote that GParted should just use dosfslabel, but I think I've changed my mind.

dosfslabel (at least as it currently, as of version 3.0.10, behaves) is totally incompatible with Windows. dosfslabel does, since version 3.0.7, update the label in both locations if it is present in both locations (Debian Bug 559985), but if it is not present at all, it is still setting the label only in the boot sector. Windows, on the other hand, totally ignores the one in the boot sector! Above I've written that Windows prefers the one from the root directory if both are present and different (and that's true), but it's even worse: Windows never uses the one in the boot sector, even if it's the only one.

I think that GParted (and other free software tools) should try to be Windows-compatible. The FAT family of file systems is, after all, only useful for interaction with DOS/Windows (there's no point in using it otherwise, since other OSes have better filesystems) and maybe devices like cameras, mp3 players etc. (but these are much more likely to do what Windows does than anything else).

For compatibility, FAT-handling utilities should behave like this:

  • On filesystem creation, create the label at least in the root directory and optionally also in the boot sector. mkdosfs from dosfstools-3.0.10 does not fulfill this (it creates the label in the boot sector only).

  • When updating the label, update it at least in the root directory, and optionally also in the boot sector. dosfslabel from dosfstools-3.0.10 does only partially fulfill this (it updates the label in both locations if both are present, but does not create one in the root directory if it was missing there).

  • When printing the label, print at least the one from the root directory. Optionally warn if the one in the boot sector is different or missing. dosfslabel from dosfstools-3.0.10 does not fulfill this at all (it always prints the one from the boot sector only).

  • Whether to allow lowercase letters is a rather difficult question. On the one hand, I have not seen that a lowercase label would create any practical problems (Windows does not break because of lowercase letters, it just displays them uppercase). On the other hand, lowercase letters aren't portable, so it would be safer not to use them.

Funny topic wink

11

Re: Partition Label: only capital letters?

Thanks mwk for your thoughts on which way to go.  It would seem that the answer is not completely obvious because there is no perfect choice at the moment.

Perhaps I should wait to see if dosfslabel changes to be more compatible with Windows before changing GParted to use dosfslabel.

12

Re: Partition Label: only capital letters?

Quoting myself:

mwk wrote:

[...] Windows does not break because of lowercase letters, it just displays them uppercase). [...]

Lowercase labels do break MS-DOS.

13

Re: Partition Label: only capital letters?

Thanks mwk for this extra information.  For FAT file systems it seems as if staying with upper case letters is the best all round for compatibility.