Label a Linux Partition

by Vivek Gite on January 27, 2009 · 7 comments

Q. How do I label a Linux partition? How do I display current label?

A. You need to use e2label or tune2fs command line to change the label on an ext2/ext3 filesystem. e2label will display or change the filesystem label on the ext2 filesystem located on device.

Display current label

If the optional argument new-label is not present, e2label will simply display the current filesystem label.
$ sudo e2label /dev/sda1
or
# e2label /dev/sda1
Sample output:

/boot

Set a new label

If the optional argument new-label is present, then e2label will set the filesystem label to be new-label. Ext2 filesystem labels can be at most 16 characters long; if new-label is longer than 16 characters, e2label will truncate it and print a warning message. To set a new label, enter:
# e2label /dev/sdb2 usbstroage
It is also possible to set the filesystem label using the -L option of tune2fs, enter:
# tune2fs -L usbstroage /dev/sdb2

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 7 comments… read them below or add one }

1 Jean-Francois January 27, 2009

That’s something that I was looking for sometime already. I re-wrote the article on my own blog, with a link to this article as well.

Reply

2 Edgar February 2, 2009

What if you wish to label a reiserfs disk?

Reply

3 Marco February 3, 2009

for reiserfs use reiserfstune -l LABEL and to display the labels of all mounted filesystems, just mount -l

Reply

4 Edgar February 6, 2009

Many thanks!

Reply

5 Ralph Corderoy February 15, 2009

The article is unclear. Must the filesystem be unmounted when e2label is used to set the label?

Reply

6 Vivek Gite February 15, 2009

@ Ralph Corderoy,

No.

Reply

7 Stevie November 23, 2009

I did this and while I can see the label when I explicitly check for it using the e2label command, it doesn’t show up in /etc/fstab. Ex:
[root@Test ~]# e2label /dev/sda1
BOOT

But then:
[root@Test ~]# cat /etc/fstab
/dev/sda1 / ext3 defaults 1 1
/dev/sda2 swap swap defaults 0 0

I expected to see something like:
LABEL=BOOT /boot ext3 defaults 1 2

Did I do it wrong, or is this only when you create the label when formatting/creating the file type?

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 7 + 15 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: