"Data replication and capacity management" perfectly describes my first years in the enterprise tư vấn environment. While I enjoyed becoming a replication SME, I always hated looking into capacity issues. This dislike was in part because capacity issues were almost always ignored until a customer was in full meltdown data loss mode. It was also due đồ sộ the fact that working with compression algorithms and de-duplication can make storage capacity a bit tricky.
As a junior tư vấn engineer, I found myself using the df
and du
commands đồ sộ figure out why I couldn't apply a system patch, or exactly where all of the data crowding was occurring. Today, we will look at these commands, break them down into their use cases, and explain the discrepancy between the two.
df
The "disk free" command is a fantastic command-line tool that gives you a quick 30,000-foot view of your filesystem and all mounted disks. It tells you the total disk size, space used, space available, usage percentage, and what partition the disk is mounted on. I recommend pairing it with the -h
flag đồ sộ make the data human-readable. The figures that you see here are calculated from the mount point or filesystem level:
Also, note that using the -h
flag rounds your data đồ sộ make it easier đồ sộ digest, so your 3G might be close đồ sộ 2.9G or 3.1G. You can't be sure.
du
The "disk usage" command is excellent when applied in the correct context. This command is at its best when you need đồ sộ see the size of a given directory or subdirectory. It runs at the object level and only reports on the specified stats at the time of execution. I lượt thích đồ sộ pair this command with the -sh
flags đồ sộ give a human-readable summary of a specified object (the directory and all subdirectories), as you can see here:
df
vs. du
So what are the use cases for each command and which command's output should you put your trust into? The (very complicated) answer can be best summarized lượt thích this: The df
command provides a sweeping ballpark figure for how much space is being utilized on your filesystem as a whole. The du
command is a much more accurate snapshot of a given directory or subdirectory.
If I had đồ sộ put money on which command was telling the "truth," I would bet on du
. For example, if I get an error trying đồ sộ install a package in /var
that says the directory is full, I can run rẩy the df
command đồ sộ confirm that this is true. Once I can see that /var
is at capacity, I can run rẩy du /var
to see what subdirectory is giving mạ the issue. I could then continue đồ sộ use df
đồ sộ narrow down by subdirectory until I found the culprit.
Understanding the differences in these commands allows us đồ sộ use these tools in tandem đồ sộ quickly identify and solve the majority of capacity issues that we face as sysadmins.
Want đồ sộ try out Red Hat Enterprise Linux? Download it now for không lấy phí.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions đồ sộ the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech