Introduction
This lesson is about checking whether filesystems are healthy and have enough space.
The main question is:
How do you notice problems early and repair simple filesystem issues safely?
What you should be able to do after this lesson:
- Check free space and inode usage.
- Use
fsckande2fsckcarefully. - Recognize
tune2fs,xfs_repair,xfs_fsr, andxfs_db.
Before you start:
- space problems and corruption problems are related, but they are not the same thing
- first inspect usage safely before you think about repair commands
- filesystem repair commands can be risky on mounted filesystems
First Checks: Space and Inodes
Disk space
df -h
Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 49G 32G 15G 69% /
tmpfs 14G 0 14G 0% /dev
efivarfs 148K 113K 31K 79% /sys/firmware/efi/efivars
run 14G 2.1M 14G 1% /run
tmpfs 14G 68M 14G 1% /tmp
What this shows:
df -hreports usage per mounted filesystemUse%is often the quickest field to check first
Inodes
df -i
Example output:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p2 3276800 581432 2695368 18% /
tmpfs 3550554 15 3550539 1% /dev
run 3550554 1200 3549354 1% /run
tmpfs 1048576 67 1048509 1% /tmp
What this shows:
- inode exhaustion is separate from normal disk space
- a filesystem can have free space but still run out of inodes
Why both matter:
- you can run out of normal space
- or run out of inodes even when some space remains
Directory usage
du -sh /var
du -sh ./*
Example output from du -sh /var/log /var/cache:
538M /var/log
5.4G /var/cache
What this shows:
duhelps identify which paths are actually using the space- this is often the next step after
df
df answers "how full is the filesystem?"
du answers "what is using the space?"
Filesystem Integrity Checks
Generic tool
sudo fsck /dev/sdX1
ext-family tool
sudo e2fsck /dev/sdX1
Very important beginner rule:
- checking an unmounted filesystem is safer
- running repair on a mounted filesystem can be dangerous
This is why a safe workflow usually starts with inspection, not repair.
ext Filesystem Tools
mke2fs
Create ext-family filesystems.
tune2fs
Change or inspect ext filesystem settings.
For LPIC, just know the purpose.
Journaling Awareness
The objective explicitly mentions extra data associated with journaling filesystems.
Simple idea:
- a journaling filesystem tracks metadata changes in a journal
- that helps recovery after crashes or unclean shutdowns
- ext3, ext4, and XFS are common journaling examples
XFS Awareness
Repair
sudo xfs_repair /dev/sdX1
Defragment-style tool
xfs_fsr
Debug tool
xfs_db
You do not need deep XFS internals here. The key point is that XFS has its own maintenance tools.
A Safe Troubleshooting Flow
- Check
df -h. - Check
df -i. - Use
duto find large paths. - If you suspect corruption, plan an unmounted filesystem check.
- Use the right repair tool for the filesystem type.
Practice Step by Step
1) Find out why a filesystem is "full"
- Check overall space:
df -h - Check inodes:
df -i - Find large directories:
du -sh /var/* 2>/dev/null | sort -h
2) Think safely before running a repair
- Identify filesystem type:
lsblk -f - Ask: is it mounted?
- If repair is needed, prefer checking it unmounted from rescue media or maintenance mode.
Cheat Sheet
df -h= human-readable filesystem spacedf -i= inode usagedu -sh= directory sizefsck= generic filesystem checke2fsck= ext-family check/repairmke2fs= create ext filesystemtune2fs= ext filesystem tuningxfs_repair= XFS repairxfs_fsrandxfs_db= XFS maintenance/debug awareness
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
