e2label: Change ext2/3/4 filesystem labels


e2label: Change ext2/3/4 filesystem labels

Overview

  • e2label is a small utility to set or read the label of ext2, ext3, or ext4 filesystems.
  • It can be run as root and expects a device path and a label in quotes.

Quick start

  • Basic usage:
sudo e2label /dev/sda1 "MyData"
  • If you just want to read the current label, omit the label argument:
sudo e2label /dev/sda1

When to run it

  • Best practice is to unmount the filesystem before changing its label to avoid possible data inconsistencies. If the filesystem is in use, you may still be able to set the label, but it’s safer to unmount first:
unmount /dev/sda1
sudo e2label /dev/sda1 "MyData"

Label considerations

  • Ext filesystems historically support up to 16 characters for the label. If you try a longer label, you’ll get an error.
  • Labels can include spaces when quoted, e.g. “My Data Drive”. Be mindful of shell quoting when scripting.

Common examples

  • Rename the root partition label (example):
sudo e2label /dev/sda1 "RootFS"
  • Update a secondary data partition:
sudo e2label /dev/sdb2 "Backup 2025"

Common pitfalls

  • Don’t forget to mount the filesystem back after labeling:
sudo mount /dev/sda1 /mnt
  • If you get a permission error, run with sudo or as root.
  • If the label contains non-ASCII characters, ensure your shell and filesystem support it; stick to ASCII for compatibility.

Verifying the label

  • To verify, read the label again:
sudo e2label /dev/sda1

Notes and alternatives

  • The e2label utility focuses on ext2/3/4 filesystems. For other filesystem types (XFS, Btrfs, NTFS), use their respective utilities (e2label will not work).
  • If you need to update boot-related labels or UUIDs for bootloaders, handle with care and consult your distro’s documentation.

TL;DR

  • Use: sudo e2label /dev/sdXN “YourLabel” (preferably after unmounting).
  • Keep labels under 16 characters for ext2/3/4.

See Also