fsck

LPIC-1LINUX

3/18/2026

1 Repairing the system

Use these commands when a file system is corrupted or won't mount.

File System Command Notes

ext2/3/4 e2fsck Usually called via the fsck wrapper. Must be unmounted. -n flag to check only.

xfs xfs_repair Must be unmounted. -n flag to check only.

xfs_db db stands for "Debugger". To view or debug internal metadata.

Btrfs btrfs check

All these commands are soft links to e2fsck command:

ls /sbin/fsck.ext?
/sbin/fsck.ext2 /sbin/fsck.ext3 /sbin/fsck.ext4

2 "Tuning" your FS

File System Command Most Frequent Tasks

ext2/3/4 tune2fs Change Label (-L), UUID (-U), or check intervals (-c).

XFS xfs_admin Change Label (-L) or UUID (-U).

Btrfs btrfstune Toggle advanced features or change the UUID (-u).

btrfs filesystem label Change Label.

Note: machine-id vs. UUID

Think of the machine-id as the DNA sequence of a Linux installation.

  • It is a single, 32-character hexadecimal string.

  • It is generated during installation or the first boot.

  • Its purpose: It provides a unique identifier for the operating system instance itself.

Unlike a MAC address (which belongs to a network card) or a UUID (which belongs to a disk), the machine-id is used by system services (like systemd, dbus, and journald) to identify the specific OS environment.

Crucial for Cloning: If you clone a VM without changing the machine-id, both machines will try to use the same ID for logs and DHCP leases, which can lead to network IP conflicts.

3 Commands to change the label

A Final Warning on changing the label: If you are changing the label for the Root (/) and Boot (/boot) partitions, if your /etc/fstab file is configured to mount your drive using the old label (e.g., LABEL=CentOS7), your machine will fail to boot next time because that label no longer exists! Check your /etc/fstab before making any changes.

a) ext2/3/4

# tune2fs -L "New_label" /dev/sdXX

Verify the change:

# tune2fs -l /dev/sdXX | grep name

b) XFS (the system needs to be unmounted to apply the changes, use a Live ISO for the root and boot FS)

# xfs_admin -L "New_label" /dev/sdXX or /dev/mapper/[Volume_name]

# xfs_admin -lu /dev/sdXX

c) btrfs

# btrfs filesystem label <mountpoint_or_device> <New_label>

4 Review

Question: You are trying to mount an XFS partition, but the kernel reports "structure needs cleaning." You want to check for errors without making any changes. Which command do you use?

  • Answer: xfs_repair -n /dev/sdX (The -n is the key for "no changes").

Question: Which command allows you to manually inspect the inodes of an XFS file system?

  • Answer: xfs_db