- 10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories
- How to Find the Size of a Directory in Linux
- How to Find the Directory Size in Human Readable Format
- How to Find Total Size of a Directory in Linux
- How to Exclude Files with du Command
- How to Find Directory Usage By Modification Time
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- 9 Tools to Monitor Linux Disk Partitions and Usage in Linux
- Command Line Utilities To Print Linux Disk Partition Table
- 1. fdisk (fixed disk) Command
- 2. sfdisk (scriptable fdisk) Command
- 3. cfdisk (curses fdisk) Command
- 4. Parted Command
- 5. lsblk (list block) Command
- 6. blkid (block id) Command
- 7. hwinfo (hardware info) Command
- Command Line Utilities To Monitor Disk Space Usage in Linux
- 8. df (disk filesystem) Command
- 9. pydf (python df) Command
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- 7 of the Best Free Linux Disk Usage Analyzers
- This article has been replaced by Essential Utilities: Reclaiming Disk Space
- Top 15 tools to monitor disk IO performance with examples
- 1. iostat — Report Disk IO Statistics
- 2. vmstat — Report virtual memory statistics
- 3. iotop — Monitor disk IO Speed
- 4. nmon — Monitor System Stats
- 5. atop — Advanced System & Process Monitor
- 6. collectl — Collects data that describes the current system status
- 7. sar — Monitor Disk IO Performance
- 8. blktrace — generate traces of the Disk I/O
- 9. perf-tools: iolatency
- 10. perf-tools: iosnoop — monitor disk IO by process
- 11. BPF Tools
- 11.1 BPF Pre-requisite
- 11.2 biolatency
- 11.3 biosnoop
- 11.4 biotop
- 11.5 bitesize
- 11.6 ext4slower
- Conclusion
- References
- Related Posts
10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories
The Linux “du” (Disk Usage) is a standard Unix/Linux command, used to check the information of disk usage of files and directories on a machine.
The du command has many parameter options that can be used to get the results in many formats. The du command also displays the files and directory sizes in a recursive manner.
Check Disk Usage of Files and Folders In Linux
This article explains 10 useful “du” commands with their examples, which might help you to find out the sizes of files and directories in Linux. The information provided in this article is taken from the man pages of du command.
Read Also:
How to Find the Size of a Directory in Linux
1. To find out the disk usage summary of a /home/tecmint directory tree and each of its subdirectories. Enter the command as:
The output of the above command displays the number of disk blocks in the /home/tecmint directory along with its sub-directories.
How to Find the Directory Size in Human Readable Format
2. Using the “-h” option with the “du” command provides results in “Human Readable Format“. This means you can see sizes in Bytes, Kilobytes, Megabytes, Gigabytes, etc.
How to Find Total Size of a Directory in Linux
3. To get the summary of a grand total disk usage size of a directory uses the option “-s” as follows.
4. Using the “-a” flag with the “du” command displays the disk usage of all the files and directories.
5. Using the “-a” flag along with “-h” displays disk usage of all files and folders in a human-readable format. The below output is easier to understand as it shows the files in Kilobytes, Megabytes, etc.
6. Find out the disk usage of a directory tree with its subtree in Kilobyte blocks. Use the “-k” (displays size in 1024 bytes units).
7. To get the summary of disk usage of directory tree along with its subtrees in Megabytes (MB) only. Use the option “-mh” as follows. The “-m” flag counts the blocks in MB units and “-h” stands for human-readable format.
8. The “-c” flag provides a grand total usage disk space at the last line. If your directory is taken 674MB space, then the last last two lines of the output would be.
How to Exclude Files with du Command
9. The below command calculates and displays the disk usage of all files and directories, but excludes the files that match the given pattern. The below command excludes the “.txt” files while calculating the total size of a directory. So, this way you can exclude any file formats by using the flag “-–exclude“. See the output there is no txt files entry.
How to Find Directory Usage By Modification Time
10. Display the disk usage based on a modification of time, use the flag “–time” as shown below.
Read Also :
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
9 Tools to Monitor Linux Disk Partitions and Usage in Linux
In this article, we will review a number of Linux command line utilities that you can use to check disk partitions in Linux.
Monitoring storage device(s) space usage is one of the most important tasks of a SysAdmin, this helps to ensure adequate free space remains on the storage devices for efficient running of your Linux system.
Command Line Utilities To Print Linux Disk Partition Table
The following is a list of command line utilities for printing storage device partition table and space usage.
1. fdisk (fixed disk) Command
fdisk is a powerful and popular command line tool used for creating and manipulating disk partition tables.
It supports GPT, MBR, Sun, SGI and BSD partition tables. You can run fdisk commands through its user-friendly, text based and menu driven interface to display, create, resize, delete, modify, copy and move partitions on storage disks.
The fdisk command below will print the partition table of all mounted block devices:
For more usage and examples about fdisk command read 10 ‘fdisk’ Command Examples to Manage Partitions
2. sfdisk (scriptable fdisk) Command
sfdisk works more like fdisk, it prints or manipulates a storage disk partition table. However, sfdisk offers extra features not available in fdisk. You can use it just as fdisk, it also supports GPT, MBR, Sun and SGI partition tables.
One difference between the two is that sfdisk does not create the standard system partitions for SGI and SUN disk labels like fdisk does.
For more usage, go through sfdisk man pages.
3. cfdisk (curses fdisk) Command
cfdisk is simple program used for printing and managing disk partitions. It offers basic partitioning functionality with a user-friendly interface. It operates similar to the more powerful commands: fdisk and sfdisk allowing users to view, add, delete, and modify hard-disk partitions.
Use the right and left arrow keys to move the highlighter over the menu tabs.
4. Parted Command
parted is also a well-known command line tool for displaying and manipulating disk partitions. It understands multiple partition table formats, including MBR and GPT.
Parted can be used for creating space for new partitions, reorganizing disk usage, and copying data to new hard disks and beyond.
5. lsblk (list block) Command
lsblk prints information including name, type, mountpoint concerning all available or particular mounted block device(s) excluding RAM disks.
6. blkid (block id) Command
blkid a utility that locates or displays block device attributes (NAME=value pair) such as device or partition name, label, its filesystem type among others.
7. hwinfo (hardware info) Command
hwinfo generally prints detailed information about system hardware. But you can run the hwinfo command below, where you employ the — option to list all hardware items of the specified type (in this case block devices such as disks and their partitions).
To restrict the information to a summary, use —short option as in the command below:
Make sure hwinfo tool installed on your system to get the above results..
Command Line Utilities To Monitor Disk Space Usage in Linux
The following is a list of command line utilities for monitoring Linux disk space usage.
8. df (disk filesystem) Command
df prints a summary of file system disk space usage on the terminal. In the command below, -hT switch enables reporting of the disk size, used space, available space and used space percentages in human-readable format.
9. pydf (python df) Command
pydf is an exceptional Python command line utility and a great replacement of df in Linux. It uses distinct colors to highlight disk partitions with specific attributes.
Make sure pydf utility installed on the system, if not install it using Install Pydf Tool to Monitor Linux Disk Usage.
What if a disk/partition is running out of space in Linux?
Once you realize that any of your storage disk(s) is running out of space or is full, you should:
- First, make a backup of all your important files on the system using any of the Linux system backup tools.
- Next, check which files or directories are occupying the biggest amount of space on the disk(s) using the du command.
- Then delete from the storage disk(s), any files that are no longer important or that you will not use in the future with the help of rm command or you can fslint tool to find and delete unwanted files in Linux.
- If your root partition is getting full, you can resize root partition using LVM, it should be pretty straight.
Note: In case you delete any important file, you can recover the deleted file in Linux.
In this article, we have talked about a number of useful command line utilities for displaying storage disk partition table and monitoring space usage.
If there is any important command line utility for the same purpose, that we have left out? Let us know via the comment section below. You can possibly ask a question or provide us feedback as well.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
7 of the Best Free Linux Disk Usage Analyzers
This article has been replaced by Essential Utilities: Reclaiming Disk Space
A disk usage analyzer is a utility which helps users to visualize the disk space being used by each folder and files on a hard disk or other storage media. This type of application often generates a graphical chart to help the visualization process.
Disk usage analyzers are popular with system administrators as one of their essential tools to prevent important directories and partitions from running out of space. Having a hard disk with insufficient free space can often have a detrimental effect on the system’s performance. It can even stop users from logging on to the system, or, in extreme circumstances, cause the system to hang.
However, disk usage analyzers are not just useful tools for system administrators. Whilst modern hard disks are terabytes in size, there are many folk who seem to forever run out of hard drive space. Often the culprit is a large video and/or audio collection, bloated software applications, or games. Sometimes the hard disk is also full of data that that users have no particular interest in. For example, left unchecked, log files and package archives can consume large chunks of hard disk space.
File systems can have millions of files. Keeping track of them can be an almost impossible task without some utility. Here steps in the disk usage analyzer. Linux has a good selection of this type of software for rooting out space eaters.
To provide an insight into the quality of software that is available, we have compiled a list of the 7 of the most useful disk usage analyzers. Hopefully, there will be something of interest here for anyone who wants to recapture their disk space.
Now, let’s explore the 7 disk usage analyzers at hand. For each title we have compiled its own portal page, a full description with an in-depth analysis of its features, screenshots, together with links to relevant resources and reviews.
Источник
Top 15 tools to monitor disk IO performance with examples
Table of Contents
Related searches: Linux Disk Usage. Top Storage monitoring tools. How to monitor Disk IO performance with examples. How to check disk read write usage on Linux. Check and monitor disk IO statistics and disk stats in Linux using iostat, vmstat and other tools. How to monitor disk IO by process ID for specific process in Linux. Storage monitoring tools. Get disk read write operation details in Linux with examples.
In my earlier article I gave you an overview of different disk types (HDD, SSD, Optical Disks) and disk interface types (SATA, IDE, SAS, SCSI..) in details with pros and cons. Now in this article I will show you various tools along with examples to monitor disk IO performance in Linux environment.
1. iostat — Report Disk IO Statistics
isotat is part of sysstat rpm. You can install sysstat using yum or any other tool depending upon your environment.
iostat summarises per-disk I/O statistics, providing metrics for IOPS, throughput, I/O request times, and utilization. It can be executed by any user, and is typically the first command used to monitor disk io performance and investigate disk IO statistics and issues at the command line.
iostat provides many options for customizing the output. A useful combination is -dxz 1 , to show disk utilization only ( -d ), extended columns ( -x ), skipping devices with zero metrics ( -z ), and per-second output.
These columns summarize the workload applied. You can check iostat man page to understand the meaning of each column.
2. vmstat — Report virtual memory statistics
vmstat is another monitoring tool which is part of procps-ng rpm. It is most likely possible that procps-ng is installed by default on your Linux node or else you can also install it manually using yum
vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity. Here we will use vmstat to monitor disk IO performance in Linux using -d for 1 second with 1 second interval.
To get summary disk IO statistics about disk activity
Follow man page of vmstat to get the complete list of supported arguments using which you can monitor your system resource.
3. iotop — Monitor disk IO Speed
iotop specialises in getting disk stats and is part of iotop rpm. You can install iotop using yum or any other tool depending upon your environment.
iotop watches disk I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system.
With —only iotop will only show processes or threads actually doing I/O, instead of showing all processes or threads so you can check and monitor disk IO performance.
4. nmon — Monitor System Stats
nmon is not available in the default repository of RHEL/CentOS. You can install if from the EPEL repository. To install the entire EPEL repo on RHEL/CentOS 7
and to install EPEL repo on CentOS/RHEL 8
Next you can install nmon using yum command
Alternatively you can also install nmon tool manually
nmon can display the CPU, memory, network, disks (mini graphs or numbers), file systems, NFS, top processes, resources (Linux version & processors) and on Power micro-partition information.
Execute nmon from the terminal
To only display disk usage statistics press D
To display disk usage statistics with graph press d
5. atop — Advanced System & Process Monitor
You can again install atop using yum (assuming you had installed EPEL repo) or alternatively you can manually install atop to check and monitor disk IO performance in Linux.
The program atop is an interactive monitor to view the load on a Linux system. You can use atop to monitor disk IO by process. It shows the occupation of the most critical hardware resources (from a performance point of view) on system level, i.e. cpu, memory, disk and network.
Now press shift + d for disk activity
Then press c for full command name..
6. collectl — Collects data that describes the current system status
collectl is not available in the internal repo of CentOS/RHEL, so either you can install EPEL repo itself and then use yum to install collectl or manually install it.
collectl will collect data that describes the current system status. We can use collectl to check and monitor disk IO performance in Linux. The following command reports CPU and disk IO statistics. Here c and d represent CPU and Disk.
Follow man page of collectl to see all the supported options.
7. sar — Monitor Disk IO Performance
sar is another famous and widely used too and is part of sysstat rpm. You can install sysstat using yum or any other tool depending upon your environment.
sar is a powerful tool which can be used to monitor all the system resources. But to stick to this article’s topic, we will use -d to monitor disk IO performance for 1 second with an interval of 1 second.
You can check this article to understand about all these columns and other options supported with sar and ksar .
8. blktrace — generate traces of the Disk I/O
blktrace is part of blktrace rpm which should be available in your default repository. You can install it using yum command or other tools based on your environment.
blktrace is a specialized utility for tracing block I/O events
Multiple event lines are printed for each I/O. You can also monitor disk IO by process. The columns are:
- Device major, minor number
- CPU ID
- Sequence number
- Action time, in seconds
- Process ID
- Action identifier (see blkparse(1)): Q == queued, G == get request, P == plug, M == merge, D == issued, C == completed, etc.
- RWBS description (see the “rwbs” section earlier in this chapter): W == write, S == synchronous, etc.
- Address + size [device]
At the end of execution you will get a summary of disk statswith throughput details of read and write operations.
Perf tools are performance analysis tools based on Linux perf_events (aka perf) and ftrace .
9. perf-tools: iolatency
iolatency — summarize block device I/O latency as a histogram and is part of perf-tools , you can download iolatency script from below location
Provide executable permission to the downloaded script
Next execute the script with -Q option which enables queued time. The -Q option includes the block I/O queued time, by tracing based on block_rq_insert instead of block_rq_issue :
Here the disk latency is between 16 — 32 milliseconds.
You can get some more examples on iolatency on the official github page
10. perf-tools: iosnoop — monitor disk IO by process
iosnoop is another tool from perf-tools . You can download iosnoop script from the below path
Provide executable permission to the downloaded script
It will trace disk I/O with details including latency. Here using -p I have provided the PID of cp command for which ionoop will show the latency value to monitor disk IO by process ID.
For more examples and list of supported options you can check the official github page
11. BPF Tools
Traditional Performance tools provide some insight for storage I/O, including IOPS rates, average latency and queue lengths, and I/O by process.
BPF tracing tools can provide additional insight for disk stats and can be used for disk IO performance in Linux.
Credits: BPF Performance Tools
11.1 BPF Pre-requisite
You must install below rpms to be able to use BPF
Here bcc can be installed from the system repository. Make sure bcc rpm version matches the loaded kernel version. So you can install both rpms together
Next install bpftools and bpftrace to be able to monitor disk IO performance
This will download the repo file and place at /etc/yum.repos.d/bpftools.repo . Now you can install bpftrace and bpftools using yum
11.2 biolatency
biolatency is a BCC and bpftrace tool to show disk IO statistics with latency as a histogram. The term device latency refers to the time from issuing a request to the device, to when it completes, including time spent queued in the operating system. We can use biolatency to check disk stats and monitor disk IO performance.
The -D option in biolatency shows histograms for disks stats separately, helping you see how each type performs.
This output shows disk IO statistics for /dev/sda , an internal disk, with I/O latency often between 128 and 4095 microseconds
11.3 biosnoop
biosnoop is a BCC and bpftrace tool that prints a one-line summary for each disk IO statistics.
It prints a line of output for each disk IO statistics, with details including latency (time from device issue to completion).
This allows you to examine disk IO performance in more detail:
The biosnoop columns are:
- TIME(s): I/O completion time in seconds
- COMM: Process name, if cached
- PID: Process ID, if cached
- DISK: Storage device name
- T: Type: R == reads, W == writes
- SECTOR: Address on disk in units of 512-byte sectors
- BYTES: Size of the I/O
- LAT(ms): Duration of the I/O from device issue to device completion
11.4 biotop
biotop is a BCC tool that is similar to top but to get disk stats and disk IO statistics in Linux.
- -C: Don’t clear the screen
- -r ROWS: Number of rows to print
Top of the list are kworker threads initiating writes: this is background write flushing, and the real process that dirtied the pages is not known at this point
11.5 bitesize
bitesize is a BCC and bpftrace tool to show the size of disk IO statistics.
This output shows the disk stats that both the kworker thread and jbd2 are calling I/O mostly in the 0 to 1 Kbyte range.
11.6 ext4slower
ext4slower traces the ext4 file system and checks disk IO performance for ext4 file system, and then only prints those disk stats that exceed a threshold.
Similar tools exist in bcc for other file systems: btrfsslower , xfsslower , and zfsslower . There is also fileslower , which works at the VFS layer and traces everything (although at some higher overhead).
Here I have a dd command running on another terminal to simulate artificial disk IO statistics
Conclusion
In this tutorial we learned about various Linux tools which can be used to check disk usage by different processes and monitor disk IO Performance. Disk read write plays very important role in how application data is processed between RAM and Disk so it is very important that you have disk with good I/O speed and RPM. I would recommend reading about different available disk types and disk interface types
This would give you an idea on choosing the type of drive which suits your requirement. In production environment we mostly prefer HDD over SSD due to cost and many other factors but for laptops and desktops mostly SSD are used. But now a days even in production environment is starting to move to SSD to support cloud environment.
Lastly I hope the steps from the article to monitor disk IO performance, disk stats and disk IO statistics in Linux was helpful. So, let me know your suggestions and feedback using the comment section.
References
I have used below external references for this tutorial guide
BPF Performance Tools
Related Posts
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
Источник