Linux Change Disk Label Name on EXT2 / EXT3 / EXT4 File Systems

How can I modify partition labels on a Linux operating systems? How to change disk name on the ext4 file system on a Ubuntu Linux using command line?

You need to use the e2label command to set a text label to your disk drive partitions and then refer to them in the /etc/fstab file. The e2label command must be run as root user. Normal users can not modify partition label for security reasons. [donotprint]
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
Requirementse2label command
Time1m
[/donotprint]

ADVERTISEMENTS

Syntax

Use the following syntax to display or change the filesystem label on the ext2, ext3, or ext4 filesystem located on device.

e2label /dev/device
e2label /dev/device new-label-name-here

Label limitations

Ext2 filesystem labels can be at most 16 characters long; if new-label-name-here is longer than 16 characters, e2label will truncate it and print a warning message on screen.

View the label of partition

To see the label of partition called /dev/sda5, type:

e2label /dev/sda5

Sample outputs:

Fig.01:  View the label of partition

Fig.01: View the label of partition

Modify partition labels / Change disk name

To add or change the label of partition /dev/sda1 to “Webserver”, enter:
$ sudo e2label /dev/sda1 Webserver
OR
# e2label /dev/sda1 Webserver
To verify new changes, type:

# e2label /dev/sda1 
Webserver

Mount file system by label at Linux server boot time

The /dev/sda1 partition can be mounted by label at server boot time at /wwwdata location. Edit the /etc/fstab file, enter:
$ sudo vi /etc/fstab
Set or update it as follows:

LABEL=Webserver /wwwdata              ext4    defaults        1 2

Save and close the file. You can also use the mount command as follows:

mount -L label_name_here /path/to/mount/point
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • c0m0 Mar 8, 2015 @ 1:47

    you can use “tune2fs -L labelname /dev/your_block_device”

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.