Intermediate · 30 minutes · Guided lesson

Storage and restore thinking

Distinguish capacity from directory usage and verify a small restore.

By the end of this lesson

  • Distinguish filesystem capacity, inode capacity and directory usage
  • Inspect storage without formatting it
  • Restore a practice archive into a separate directory

Your environment: Bash and the named tools in a Linux lab. Minimal distributions may require extra packages. Setup help

Measure the right thing

df reports filesystem-level space; du walks files beneath a directory and reports their usage. They answer different questions, so their totals need not match. Permission errors, separate mount points and deleted files still held open by a process can all affect your interpretation. Do not immediately delete large directories because a filesystem looks busy.

Inodes track filesystem objects on many Linux filesystems. A workload containing many tiny files can exhaust inodes while byte capacity remains. df -i can reveal this kind of pressure where supported. lsblk identifies block devices and mount relationships, but a container may show a restricted or unusual view.

Recovery is part of the task

A useful backup process specifies what is protected, where copies live, how long they remain, and how restoration is checked. A same-disk archive is convenient for a lab but does not protect against that disk failing. Production storage changes also need an agreed recovery window.

Practice reading before changing. This lesson does not run mkfs, repartition disks or remove system logs. You will create tiny source files, archive them, extract elsewhere and compare. That small loop teaches a habit you can later apply to larger, properly isolated backup systems.

See it in context

Worked example

Inspect the filesystem containing your home directory.

df -h "$HOME"
df -i "$HOME"
du -sh "$HOME/training4linux"

df -h reports capacity for the containing filesystem. du -sh reports usage below the practice tree. Values will vary by machine.

Your turn

Practical lab

Verify a practice backup without touching the original content.

Run commands in your own lab. This website displays instructions; the practice terminal below helps you rehearse the syntax.

1. Prepare your workspace

mkdir -p "$HOME/training4linux/storage/source" "$HOME/training4linux/storage/restore"
cd "$HOME/training4linux/storage"
printf "%s\n" "Training backup" > source/notes.txt

2. Complete the task

  1. Measure the containing filesystem and the source directory.
  2. Archive only source into notes.tar.gz and list its members.
  3. Restore into restore and compare notes.txt with the source.

3. Check your result

  • The member list includes source/notes.txt.
  • The comparison has no differences.
  • You can explain why keeping the archive beside the source is only a lab arrangement.
Need a hint?

Use tar -C for the restore destination, and diff for the content comparison.

Reveal a worked solution

Compare this with your approach after trying the task. More than one valid solution may exist.

df -h .
du -sh source
tar -czf notes.tar.gz source
tar -tzf notes.tar.gz
tar -xzf notes.tar.gz -C restore
diff source/notes.txt restore/source/notes.txt

After the lab: Keep the tiny archive if useful; no system storage configuration was changed.

Common mistakes to avoid

  • Do not use formatting or partitioning commands to investigate a capacity warning.

Check your understanding

Knowledge check

Answer all 3 questions correctly to pass. Retry as often as you need; your best score is kept.

1. Which tool estimates usage below a directory?
2. What can explain free bytes but failed creation of many tiny files?
3. What does a same-disk archive fail to protect against?

Your lesson progress

Not started · Best score: 0% · Attempts: 0

Practical completion is self-reported. Progress is linked to a private cookie in this browser and stored on the site. Clearing that cookie loses access to it. Manage or erase progress.

Keep the reference close

Further reading