Why DevOps Engineers Should Master Linux Disk Management

Linux disk skills for DevOps: find space with df and du, grow LVM online, safe fstab mounts, XFS limits, fstrim and Docker cleanup.

Aug 2, 2025 - 13:59
Nov 16, 2026 - 00:29
 0  34
TOPICDevOps BasicsPractical guide
Why DevOps Engineers Should Master Linux Disk Management

DevOps engineers should master Linux disk management because full disks are one of the most common causes of failed builds, crashed databases and stuck containers. Knowing how to find what is using space, grow an LVM volume and its filesystem online, mount disks safely with UUIDs, and clean container storage lets you fix these problems in minutes instead of hours.

This guide is part of our Linux and RHEL 10 cluster. It focuses on the disk tasks that come up in DevOps work: CI runners, container hosts, database servers and cloud instances. Every command option here was checked against the Linux man pages and Docker documentation in November 2026.

Key takeaways

  • Start every disk investigation with three commands: lsblk -f for devices and filesystems, df -hT for space per filesystem, and df -i for inodes.
  • Use du -xh --max-depth=1 to find which directory is using space without crossing into other filesystems.
  • LVM lets you grow a volume and its filesystem in one step with lvextend -r, while the system keeps running.
  • XFS, widely used on RHEL servers, can be grown while mounted but cannot be shrunk in general. Plan sizes with that in mind.
  • Reference disks in /etc/fstab by UUID or LABEL, use nofail for non-essential disks, and check the file with findmnt --verify before rebooting.
  • On container hosts, docker system prune removes stopped containers, unused networks, dangling images and unused build cache, but keeps volumes unless you add --volumes.

Why disk skills matter in DevOps work

Disk problems are rarely interesting, and that is why they hurt. A CI runner fills up with build caches and old images, and every job starts failing with "no space left on device". A database server's log volume grows until the database stops accepting writes. A Kubernetes node runs low on disk, and the kubelet starts evicting pods. A new cloud instance boots with a data volume attached but not mounted, and the application writes to the root disk instead.

None of these need deep storage expertise. They need someone who can find the cause quickly, fix it without downtime where possible, and prevent it from happening again. That is the level this guide aims at. Storage design for large databases or SAN arrays is a specialist area; day-to-day disk management on Linux servers and cloud instances is part of a DevOps engineer's normal job.

Disk management also shows up in automation. Provisioning code formats and mounts volumes, configuration management writes /etc/fstab, and monitoring needs sensible thresholds. If you do not understand what the commands do by hand, it is hard to write automation that does them safely.

Cloud platforms change the details but not the skills. Enlarging a cloud block volume is a few clicks or one line of infrastructure code, yet the operating system does not see the new space until you grow the partition, the physical volume or the filesystem yourself. Engineers who understand each layer can finish that job in one maintenance-free step instead of opening a ticket and waiting.

Reading the current state

Devices and filesystems: lsblk

lsblk lists block devices in a tree, showing disks, their partitions and anything layered on top, such as LVM volumes. The -f option adds filesystem details: type, version, label, UUID, available space, percentage used and mount points. It is the fastest way to see whether a new disk is attached, whether it has a filesystem, and where it is mounted.

lsblk
lsblk -f
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS

The man page notes that the default columns of -f may change between versions, so scripts should name their columns with -o.

Space per filesystem: df

df reports space per mounted filesystem. Use -h for readable sizes and -T to show the filesystem type. Then run df -i, which reports inode usage instead of blocks. A filesystem can run out of inodes while still showing free space, typically when something creates millions of tiny files, such as a cache directory or a mail spool. The error is the same "no space left on device", so checking inodes saves a lot of confusion.

df -hT
df -i

Space per directory: du

Once you know which filesystem is full, du shows where the space went. Combine -h for readable sizes, -x to stay on one filesystem, and --max-depth=1 to summarise one level at a time. Then drill into the largest directory and repeat.

sudo du -xh --max-depth=1 / | sort -h
sudo du -xh --max-depth=1 /var | sort -h
sudo du -sh /var/log/*

The -x option matters on servers with several mounts. Without it, scanning / also scans every mounted data volume and network share, which is slow and gives a misleading total.

The standard tools at a glance

TaskCommandNotes
List disks, partitions, LVM and filesystemslsblk -fUse -o with explicit columns in scripts
Free space and type per filesystemdf -hTCheck inodes with df -i
Find large directoriesdu -xh --max-depth=1-x stays on one filesystem
Create a logical volumelvcreate -L 20G -n data vg01Needs a volume group with free space
Grow a volume and its filesystemlvextend -r -L +10G vg01/data-r resizes the filesystem through fsadm
Grow XFS manuallyxfs_growfs /mountpointFilesystem must be mounted
Check fstab before rebootfindmnt --verifyParses and checks entries in /etc/fstab
Discard unused blocks on SSD or thin storagefstrim -avAbout weekly is enough for most systems
Clean container storagedocker system pruneVolumes kept unless --volumes

LVM: why DevOps teams use it

The Logical Volume Manager puts a layer between physical disks and filesystems. Physical volumes (disks or partitions) are pooled into a volume group, and logical volumes are carved out of that pool. Filesystems live on logical volumes. The benefit is flexibility: you can add a disk to the pool and grow a volume without moving data, take snapshots before risky changes, and size volumes for what you need now rather than guessing for years ahead.

# Prepare a new disk and add it to a volume group
sudo pvcreate /dev/sdb
sudo vgcreate vg01 /dev/sdb

# Create a 20 GiB logical volume and an XFS filesystem
sudo lvcreate -L 20G -n data vg01
sudo mkfs.xfs /dev/vg01/data

Growing a volume while the system runs

The most common LVM task in production is "this volume is nearly full, make it bigger without downtime". With free space in the volume group, lvextend grows the logical volume and the -r option resizes the filesystem on it in the same command, using fsadm. You can give an absolute increase with -L or a share of free extents with -l.

sudo lvextend -r -L +10G vg01/data
sudo lvextend -r -l +100%FREE vg01/data

If the volume group has no free space, add a disk first with pvcreate and vgextend. On cloud instances, the more common route is to enlarge the cloud volume, then grow the partition or physical volume to use the new space, then extend the logical volume.

Snapshots before risky changes

An LVM snapshot is a copy-on-write view of a volume at a point in time. Creating one before an upgrade gives you something to compare against or restore from. The lvcreate man page shows a snapshot sized as a share of the origin, and suggests that 20 percent of the origin is often enough, depending on how much data will change.

sudo lvcreate -s -l 20%ORIGIN -n data_snap vg01/data

Snapshots are not backups. They live on the same disks as the original, and a snapshot that fills up becomes unusable. Remove them once the change is confirmed, and keep real backups elsewhere. Our post on how LVM improves storage flexibility covers more LVM operations, and how LVM and partitioning work together explains the layering.

Filesystem choices that affect operations

XFS is widely used on RHEL servers. It can be grown while mounted, and the xfs_growfs man page states that the filesystem must be mounted to be grown. Shrinking is a different story: only a limited form of shrinking is implemented, so in practice you should treat XFS volumes as grow-only. If you might need a smaller volume later, create a new one and copy the data. That is a strong reason to start volumes at a sensible size and grow them as needed, which LVM makes easy.

ext4 is the other common choice on Linux servers. The right choice is usually whatever your distribution and team already support well. Mixing filesystems across a fleet without a reason makes runbooks more complicated.

Mounting safely with /etc/fstab

A bad /etc/fstab entry can stop a server from booting, which on a cloud instance may mean attaching the disk to another instance just to fix one line. A few habits prevent most of these incidents.

First, identify devices by UUID or LABEL rather than by name. The fstab man page recommends this because device names are often a coincidence of hardware detection order; /dev/sdb today may be /dev/sdc after a disk is added. Get the UUID from lsblk -f.

Second, use the nofail option for disks the system can boot without, such as data or scratch volumes. With nofail, a missing device is not reported as an error. Third, set the last field, fs_passno, correctly: 1 for the root filesystem, 2 for others that should be checked, and 0 for filesystems that should not be checked at boot.

# /etc/fstab entry for a data volume
UUID=3f6c1c1e-0000-4000-8000-000000000000  /data  xfs  defaults,nofail  0 0

# Check the file, then test mounting everything listed
sudo findmnt --verify
sudo mount -a

findmnt --verify parses /etc/fstab and checks that entries are usable. Running it, followed by mount -a, before any reboot catches typos while you still have a working shell.

Container hosts and CI runners

Docker and other container runtimes store images, writable container layers, volumes and build cache on the host. On a busy CI runner that builds many images, this storage grows fast. docker system prune removes stopped containers, networks not used by any container, dangling images and unused build cache. Add -a to remove all unused images, not only dangling ones. Volumes are kept by default so that data is not lost; --volumes also prunes anonymous volumes no container uses.

docker system prune
docker system prune -a

Run prune commands on a schedule on build machines, and think before running them with -a on a production host, where removing images forces the next deployment to pull them again. Better still, put container storage on its own volume so that a full image cache cannot fill the root filesystem. Our post on speeding up Docker builds in CI/CD covers cache strategies that also reduce disk pressure.

SSDs, thin storage and fstrim

On SSDs and thinly provisioned storage, telling the device which blocks are unused helps performance and lets thin pools reclaim space. fstrim discards unused blocks on a mounted filesystem. With -a it trims all mounted filesystems on devices that support discard, and -v reports how many bytes were passed down for discard. The man page says that trimming about once a week is enough for most desktop and server systems and that running it too often may shorten the life of poor-quality SSDs. Many distributions schedule this for you; check before adding your own job.

sudo fstrim -av

Monitoring and prevention

The best disk incident is the one that never pages anyone. Monitor both space and inodes on every filesystem that matters, and alert on rate of change as well as percentage used. A volume at 80 percent that has been stable for a year needs no action; a volume at 60 percent that grew 20 points this week does. Our guide to monitoring disk usage with df, du and smartctl covers checks and hardware health.

Prevent the usual growth sources. Configure log rotation and retention for application logs. Set retention on build caches and artifact directories. Keep databases, logs and container storage on separate volumes so that one cannot starve the others. Size cloud volumes with headroom and automate growth through your infrastructure code rather than by hand.

Finally, write a runbook for "disk full" and practise it. It should list the commands above in order, the directories that usually grow on each type of host, which files are safe to delete, and how to grow each volume. A runbook turns a stressful page into a routine task.

A practice lab

Create a virtual machine with two extra virtual disks. Turn one into an LVM volume group, create a logical volume, format it with XFS, and mount it through /etc/fstab by UUID with nofail. Fill it with test data, grow it with lvextend -r while a process is writing to it, and confirm with df -h. Then add the second disk to the volume group and grow again. Take a snapshot, change some files, and compare. Finally, break the fstab entry on purpose and use findmnt --verify to find the mistake before rebooting. Our step-by-step post on partitioning and formatting a new disk helps with the first steps.

If you want guided practice with storage, LVM, systemd and troubleshooting, see our Linux administration training, available in our Kharadi, Pune classroom and live online across India.

Frequently asked questions

How do I find what is filling a Linux disk?

Run df -hT to find the full filesystem, then du -xh --max-depth=1 on its mount point, sorted with sort -h, and drill into the largest directory. Also run df -i, because running out of inodes gives the same "no space left on device" error.

Can I grow an LVM volume without unmounting it?

Yes. With free space in the volume group, lvextend -r -L +10G vg/lv grows the logical volume and resizes the filesystem on it in one command. XFS must be mounted to be grown.

Can an XFS filesystem be shrunk?

Only in a very limited way. The xfs_growfs man page says only shrinking the last allocation group is implemented, so treat XFS as grow-only and create a new, smaller volume if you need to reduce size.

Why should fstab use UUIDs instead of /dev/sdX names?

Device names depend on hardware detection order and can change when disks are added or removed. The fstab man page recommends LABEL or UUID because they stay with the filesystem.

What does the nofail mount option do?

It tells the system not to report an error if the device does not exist. Use it for data or scratch disks so that a missing volume does not stop the server from booting.

Does docker system prune delete volumes?

Not by default. It removes stopped containers, unused networks, dangling images and unused build cache. Add --volumes to also remove anonymous volumes that no container uses, and -a to remove all unused images.

How often should I run fstrim?

The fstrim man page says about once a week is sufficient for most desktop and server systems, and that running it too often may affect the lifetime of poor-quality SSDs.

References

Interested in learning more?Get a callback from our training advisors.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.