100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Bash

Disk Usage and Management (df, du, mount)

Learn how to inspect filesystem capacity, measure directory sizes, and understand how block devices get attached to the Linux directory tree via mounting.

Networking, Disks & LogsIntermediate10 min readJul 9, 2026
Analogies

Disk Usage and Management (df, du, mount)

A Linux system rarely has a single flat storage volume. Instead it typically composes several block devices, partitions, logical volumes, and even network shares into one unified directory tree. Understanding how much space is used, where it is being consumed, and how a given path maps to a physical or virtual device is a daily operational skill. Three tools dominate this work: df reports filesystem-level free space, du reports how much space a directory or file actually occupies, and mount (together with /etc/fstab) controls how storage devices are attached into the tree. These tools query different layers of the kernel's storage subsystem, which is why df and du can disagree even when inspecting the same path.

🏏

Cricket analogy: A Linux filesystem tree assembled from many devices is like an international XI squad drawn from different boards, and just as a scorer (df) and a fielding coach's tally (du) might report slightly different numbers for the same innings, they're measuring different things.

Filesystem-Level Reporting with df

df (disk free) reads superblock statistics for each mounted filesystem and reports total size, used space, available space, and use percentage. Because it operates on filesystem metadata rather than walking directory trees, df is essentially instant regardless of how many files exist. The -h flag renders sizes in human-readable units (K, M, G), and -T adds the filesystem type column, which is invaluable when diagnosing whether a mount is ext4, xfs, tmpfs, overlay, or a network filesystem like nfs. df -i switches the report to inode usage instead of block usage — a filesystem can report plenty of free bytes yet still refuse to create new files if its inode table is exhausted, a classic and confusing failure mode on filesystems hosting millions of small files (mail spools, session caches).

🏏

Cricket analogy: df reading superblock stats instantly is like a scoreboard operator glancing at the summary total rather than replaying every ball, and df -i checking inode exhaustion is like discovering a stadium has plenty of empty seats (bytes) but has run out of ticket numbers (inodes) to issue.

bash
# Human-readable summary of every mounted filesystem
df -h

# Add filesystem type column
df -hT

# Check a specific mount point
df -h /var

# Inode usage (files exhausted != bytes exhausted)
df -ih

# Exclude tmpfs/devtmpfs pseudo-filesystems from the report
df -h --exclude-type=tmpfs --exclude-type=devtmpfs

Directory-Level Reporting with du

du (disk usage) walks a directory tree and sums the allocated block size of every file it finds, recursively. Unlike df, du can be slow on directories containing millions of files because it must stat each one. The most common invocation is du -sh <dir> to get a single human-readable total for a directory, and du -h --max-depth=1 <dir> to see a one-level breakdown of which subdirectories are consuming the most space — the go-to command when a disk is filling up and you need to find the culprit. du reports apparent allocated space (rounded up to filesystem block size and accounting for sparse files), which is why du and 'ls -l' sizes for the same file can differ, and why summing du across many small files yields more overhead than the sum of their logical byte sizes would suggest.

🏏

Cricket analogy: du walking every file to sum space, unlike df's instant read, is like a groundsman physically measuring every blade of grass on the outfield rather than reading a summary sign, and du -h --max-depth=1 is like checking each stand's usage one level at a time to find which section is overcrowded.

bash
# Total size of a directory, human-readable
du -sh /var/log

# One level deep breakdown, sorted by size (largest last)
du -h --max-depth=1 /var | sort -h

# Find the 10 largest directories under /home
du -h --max-depth=2 /home 2>/dev/null | sort -rh | head -n 10

# Apparent size (logical bytes) instead of allocated blocks
du -sh --apparent-size /var/lib/docker

df and du can legitimately disagree. A file that has been deleted but is still held open by a running process no longer appears when du walks the tree, yet the space it occupies is not released until the last file descriptor closes — so df still reports it as used. Find such 'phantom' space consumers with lsof +L1 or lsof | grep deleted, then restart or signal the offending process to release the space.

Mounting and /etc/fstab

Mounting is the act of attaching a filesystem (from a block device, partition, LVM logical volume, ISO image, or network share) to a directory in the existing tree, making its contents accessible at that path. The mount command performs this attachment for the current session; lsblk and blkid help identify available block devices and their filesystem types and UUIDs before mounting. For persistence across reboots, entries are added to /etc/fstab, which the boot process reads to mount filesystems automatically. Each fstab line specifies the device (preferably by UUID rather than a device name like /dev/sda1, since device enumeration order can change between boots), the mount point, filesystem type, mount options, dump flag, and fsck pass order.

🏏

Cricket analogy: Mounting a filesystem to a directory is like assigning a guest player to bat at a specific position in the order, while lsblk/blkid identifying devices beforehand is like checking a player's registration ID rather than their jersey number, since squad numbers (device names) can be reassigned between matches.

bash
# List block devices and their filesystem types
lsblk -f

# Get the UUID of a partition
blkid /dev/sdb1

# Mount a device manually to a mount point
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data

# Mount using type and options explicitly
sudo mount -t ext4 -o defaults,noatime /dev/sdb1 /mnt/data

# View currently mounted filesystems
mount | column -t
findmnt /mnt/data

# Unmount safely
sudo umount /mnt/data

# Example /etc/fstab line (UUID-based, persists across reboots)
# UUID=3a1e4f2b-... /mnt/data ext4 defaults,noatime 0 2

# Test fstab entries without rebooting
sudo mount -a

Never edit /etc/fstab and reboot blindly without testing. A malformed entry (wrong UUID, missing mount point, typo in filesystem type) can drop the system into an emergency shell during boot, especially if the entry lacks the 'nofail' option for removable or network storage. Always validate with sudo mount -a first, and consider adding nofail to entries for non-critical filesystems so a missing device does not block boot entirely.

Freeing Space Safely

When df reports a filesystem nearing capacity, a disciplined workflow finds the offender before deleting anything. Start broad with du --max-depth=1 at the root of the filesystem in question, then drill into the largest subdirectory repeatedly until you reach specific files. Common space hogs include unrotated log files in /var/log, orphaned Docker images and volumes, old kernel packages retained by apt, and core dump files. journalctl --vacuum-size and apt-get clean / apt-get autoremove are common remediation commands, alongside truncating (not deleting, if a process holds the file open) oversized logs with : > /path/to/logfile.log or truncate -s 0.

🏏

Cricket analogy: Drilling into du --max-depth=1 repeatedly to find a disk hog is like a coach reviewing team performance broadly, then drilling into the worst-performing department — batting, bowling, fielding — round by round, until pinpointing exactly which player's stats need attention, before deleting anything, verify it first.

  • df reports filesystem-level free space instantly by reading superblock metadata; du reports actual space consumed by walking a directory tree, which is slower on large trees.
  • df -i shows inode usage — a filesystem can be 'full' on inodes while still showing free bytes, a common issue with many small files.
  • du -h --max-depth=1 <dir> | sort -h is the standard first command for locating what is consuming disk space.
  • df and du can disagree when a deleted file is still held open by a running process; find these with lsof +L1 or lsof | grep deleted.
  • Persistent mounts belong in /etc/fstab, referenced by UUID (via blkid) rather than device name, and should be tested with mount -a before rebooting.
  • Add the nofail fstab option for non-critical or removable filesystems to avoid boot failures if the device is absent.

Practice what you learned

Was this page helpful?

Topics covered

#Bash#LinuxShellScriptingStudyNotes#DevOps#DiskUsageAndManagementDfDuMount#Disk#Usage#Management#Mount#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse