e2label looks harmless until you rename the wrong device and your fstab entries stop matching reality. You will read an ext2, ext3 or ext4 label, change it deliberately, and verify the new value landed on the right filesystem. Allow about ten minutes. You need the e2label command from e2fsprogs; the examples here use e2fsprogs 1.47.0, installed as package version 1.47.0-2.4~exp1ubuntu4.1.
Safety checkpoint: Setting a label changes filesystem metadata. The device argument is not a harmless name lookup. Confirm the path before using the two-argument form, and keep a backup or snapshot if the filesystem holds data you cannot recreate.
e2label takes a device and, optionally, a new label. It has no general-purpose help or version switch in the installed interface. Check which executable your shell will run, then inspect candidate block devices before changing anything:
$ command -v e2label
/usr/sbin/e2label
$ lsblk -o NAME,PATH,FSTYPE,LABEL,SIZE,MOUNTPOINTS
lsblk, such as /dev/sdb1, never a guess based on the disk's position.ext2, ext3 or ext4. Reading a label normally needs no elevated privilege when the device is readable, but access to a block device often does require sudo./dev/sdb and /dev/sdb1 can be entirely different objects, and the disk itself may not hold the filesystem whose label you intend to change.Omit the optional label argument for a read-only query:
$ sudo e2label /dev/sdb1
ARCHIVE_2025
The output is the current volume label, followed by a newline. A blank line means the filesystem has no label, not that the command failed. Capture the old value before changing it if you may need to restore it.
Checkpoint: if the command reports that it cannot open the device or cannot find a valid filesystem superblock, stop. Recheck the path, filesystem type and permissions rather than trying several nearby device names.
Pass the exact label as the second argument; the command changes the filesystem metadata in place:
$ sudo e2label /dev/sdb1 ARCHIVE_2026
$ sudo e2label /dev/sdb1
ARCHIVE_2026
The command does not print a success message when the change works, so its exit status is the useful signal for scripts:
if sudo e2label /dev/sdb1 ARCHIVE_2026; then
printf '%s\n' 'Filesystem label updated'
else
status=$?
printf 'e2label failed with status %s\n' "$status" >&2
exit "$status"
fi
Run the read-back command after a successful write. This catches a wrong device argument and gives you an observable checkpoint before mounts, fstab changes or automation continue.
The installed manual documents a maximum of 16 characters for ext2 volume labels. If a label is longer, e2label truncates it and prints a warning. The same length is a sensible portable limit when the filesystem may later be used as ext2, ext3 or ext4:
$ sudo e2label /dev/sdb1 THIS_LABEL_IS_LONGER_THAN_SIXTEEN
Warning: label too long, truncating.
$ sudo e2label /dev/sdb1
THIS_LABEL_IS_LO
Do not treat exit status 0 as proof the complete string was stored. Always read it back, especially in scripts. A short label made from letters, digits, underscores or hyphens is easier to recognise in lsblk output and avoids accidental whitespace.
For a local ext filesystem, tune2fs gives an independent read of the superblock. It is a verification command here, not a replacement for choosing the correct device:
$ sudo tune2fs -l /dev/sdb1 | grep '^Filesystem volume name:'
Filesystem volume name: ARCHIVE_2026
The spacing in the output is not significant. The value after the field name should match the result from e2label. If the two readings disagree, stop using the device and investigate rather than repeatedly writing labels.
If you changed the label on the wrong filesystem but know the previous value, restore it by passing that value back to the same device:
$ sudo e2label /dev/sdb1 ARCHIVE_2025
$ sudo e2label /dev/sdb1
ARCHIVE_2025
Changing a label does not restore any other metadata and does not undo a wrong mount or partition operation. If you do not know the old value, check your inventory, backups or documentation before choosing a replacement: do not infer it from a mount directory alone.
For a mounted ext filesystem, the local e2label manual says online label manipulation is supported for filesystems that support it, without truncating the label in those cases. The safest operational practice is still to schedule metadata changes, check the exact filesystem type, and avoid changing a busy production volume unless your maintenance procedure permits it. Never unmount a service filesystem casually: stopping services and unmounting can cause an outage.
lsblk and readlink -f before retrying.sudo only after confirming the device. Elevated privilege does not make an uncertain device choice safe.blkid /dev/sdb1 when you need to tell filesystems apart reliably.e2label.tune2fs -l agrees with the requested value.