The e2label
command is used to set or change the volume label for the second extended file system (ext2, ext3, and ext4) on a Linux system. The volume label is a name assigned to a file system that can be used to easily identify it. It is useful when mounting file systems, especially when there are multiple file systems present on a system.
Overview
The syntax for the e2label
command is as follows:
e2label device [new-label]
Where device
is the block device representing the file system (e.g., /dev/sda1
) and new-label
is the new label to be assigned to the file system.
To set a volume label for a file system, you must have root privileges. For example, to set a label for the file system on /dev/sda1
, you would run the following command:
sudo e2label /dev/sda1 mylabel
This command assigns the label “mylabel” to the file system on /dev/sda1
. If you omit the new-label
argument, the current label is displayed.
It is also possible to change the label of an existing file system by running the e2label
command with the new label as the second argument:
sudo e2label /dev/sda1 newlabel
Options
The following table lists the available options for the e2label
command:
Option | Description |
---|---|
-h |
Display help information and exit. |
-V |
Display version information and exit. |
Troubleshooting Tips
- If you receive an error message stating that the file system is in use, unmount it first before running the
e2label
command. - If you are unable to set the label, make sure that the file system is formatted as ext2, ext3, or ext4.
Notes
- The maximum length of a volume label is 16 characters.
- The
e2label
command only works with the second extended file system (ext2, ext3, and ext4). It cannot be used with other file systems such as NTFS or FAT32.