e2label - Linux


Overview

e2label is a command-line utility used to display or set the volume label of an ext2, ext3, or ext4 filesystem. Volume labels are used to identify filesystems and make them easier to manage.

Syntax

e2label [-c[d]|f] [-C|-i|-I] [-L label] [-U label] [device]

Options/Flags

  • -c: Check for errors or inconsistencies in the filesystem.
  • -cd: Check and attempt to fix the filesystem.
  • -f: Force the operation, even if the filesystem is mounted.
  • -C: Display the current volume label.
  • -i: Initialize a new volume.
  • -I: Initialize a new volume, even if the filesystem already exists.
  • -L label: Set the volume label to label.
  • -U label: Unset the volume label (set it to empty).

Examples

Display the volume label:

e2label /dev/sda1

Set the volume label:

e2label -L "My Filesystem" /dev/sda1

Unset the volume label:

e2label -U /dev/sda1

Initialize a new volume:

e2label -i /dev/sda1

Common Issues

  • Error: The filesystem is mounted.

This error occurs if you try to modify the volume label of a mounted filesystem. Use the -f flag to force the operation.

  • Error: The filesystem is inconsistent.

This error occurs if the filesystem contains errors or inconsistencies. Use the -cd flag to check and fix the filesystem.

Integration

e2label can be used in conjunction with other Linux commands to perform advanced tasks. For example, you can use it to create a new filesystem and set the volume label in one command:

mkfs.ext4 /dev/sda1 && e2label -L "My Filesystem" /dev/sda1

Related Commands

  • mkfs.ext4: Creates a new ext4 filesystem.
  • tune2fs: Tunes the parameters of an ext2/3/4 filesystem.