DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Linux Tutorial

Introduction to Linux
Linux Filesystem
Linux Navigation
Linux File Operations
Linux Text Processing
Linux Permissions
Linux Users and Groups
Linux Process Management
Linux systemd Basics
Linux Networking
Linux Disk and Storage
Linux Bash Scripting
Linux Package Management
Linux Environment Variables
Linux Cron Jobs
Linux SSH Keys
Linux Firewall Basics
Linux Log Management
Linux Performance Monitoring and Troubleshooting

Linux Disk and Storage

PreviousPrev
Next

Learn how to inspect disk space, mount filesystems, archive data, compress files, and find large files in Linux.

Why Storage Skills Matter

Disk issues are some of the most common Linux problems. Applications fail when logs fill a partition, backups consume unexpected space, or a new disk is not mounted correctly.

DevOps engineers need to answer questions like:

  • how much free space is left?
  • which directory is using it?
  • what disks are attached?
  • is the filesystem mounted where I expect?

Checking Space with df

df reports filesystem-level disk usage.

df
df -h

-h shows human-readable sizes such as G and M.

Example:

df -h /var

This is useful when a specific path is having storage issues.

Measuring Directory Usage with du

du shows how much space directories and files consume.

du -sh /var/log
du -sh *
du -ah /var/log | sort -h

Common flags:

  • -s summary only
  • -h human-readable
  • -a include files

df tells you how full the filesystem is. du helps you find what is taking the space.

Viewing Block Devices with lsblk

lsblk lists block devices such as disks and partitions.

lsblk
lsblk -f

This shows device names, sizes, mount points, and sometimes filesystem types.

It is especially useful after attaching a new cloud volume.

Mounting and Unmounting

Linux makes filesystems available by mounting them into the directory tree.

Mount a device:

sudo mount /dev/xvdf1 /mnt/data

Unmount it:

sudo umount /mnt/data

The command is umount, not unmount.

Note: A filesystem usually cannot be unmounted if processes are actively using it.

Persistent Mounts with /etc/fstab

To mount a filesystem automatically at boot, add it to /etc/fstab.

Example entry:

UUID=1234-ABCD /data ext4 defaults,nofail 0 2

Fields define the device, mount point, filesystem type, options, and fsck order.

A broken /etc/fstab entry can cause boot problems, so edit carefully and test before rebooting.

Creating Archives with tar

tar is the standard archiving tool on Linux.

Create an archive:

tar -cvf backup.tar project/

Extract an archive:

tar -xvf backup.tar

Common flags:

  • -c create
  • -x extract
  • -v verbose
  • -f file name

Compressing with gzip and gunzip

gzip compresses files.

gzip app.log
gunzip app.log.gz

It is often combined with tar:

tar -czvf backup.tar.gz project/
tar -xzvf backup.tar.gz

Here -z tells tar to use gzip compression.

Working with zip and unzip

Some teams or tools prefer the ZIP format.

zip -r site.zip site/
unzip site.zip

ZIP is especially common when exchanging files across platforms.

Finding Large Files

When a disk fills up, you often need to find the biggest offenders.

A practical approach:

du -ah /var | sort -h | tail -n 20

Another useful pattern:

find /var -type f -size +100M

This finds files larger than 100 MB.

Real-World Scenario

Suppose alerts say /var is 95% full. You might investigate with:

df -h /var
du -sh /var/log/*
find /var/log -type f -size +100M

If one log file grew unexpectedly, you now know where to focus.

Or imagine attaching a new volume to a cloud VM. You could verify it with:

lsblk
sudo mount /dev/xvdf1 /mnt/data
df -h /mnt/data

That confirms the device exists, is mounted, and has usable space.

Test Your Understanding

Let's see how well you understood the concepts! These exercises will help reinforce what you just learned.

Exercise 1: Checking filesystem capacity

Question: Which command from the lesson tells you the free space available on mounted filesystems such as /var?

Exercise

Exercise 1: Checking filesystem capacity

Choose the command that reports mounted filesystem usage and free space.

Exercise 2: Configuring persistent mounts

Question: Which file should you edit to make a filesystem mount persist automatically at boot?

Exercise

Exercise 2: Configuring persistent mounts

Identify the configuration file used for boot-time filesystem mounts.

Exercise 3: Building a compressed backup

Question: Which tar command from the lesson creates a gzip-compressed archive of the project directory?

Exercise

Exercise 3: Building a compressed backup

Choose the tar invocation that both archives and gzip-compresses a directory.

PreviousPrev
Next

Continue Learning

Linux Process Management

Learn how to inspect, prioritize, background, and control processes in Linux using ps, top, kill, jobs, nohup, and related tools.

20 min·Medium

Linux systemd Basics

Learn how systemd units, targets, systemctl, and journalctl work, and create a simple service unit file.

18 min·Medium

Linux Networking

Learn essential Linux networking commands for inspecting addresses, testing connectivity, transferring files, and understanding DNS resolution.

20 min·Medium

Explore Related Topics

Do

Docker Tutorials

Run and manage containers on Linux

Gi

Git Tutorials

Master Git version control on the command line

Try the Tool

Cron Parser

Parse and validate cron expressions with a visual schedule preview.

Regex Tester

Test and debug regular expressions used in Bash scripts and configs.

On This Page

Why Storage Skills MatterChecking Space with `df`Measuring Directory Usage with `du`Viewing Block Devices with `lsblk`Mounting and UnmountingPersistent Mounts with `/etc/fstab`Creating Archives with `tar`Compressing with `gzip` and `gunzip`Working with `zip` and `unzip`Finding Large FilesReal-World ScenarioTest Your UnderstandingExercise 1: Checking filesystem capacityExercise 2: Configuring persistent mountsExercise 3: Building a compressed backup