Disk space usage and disk utilization are different in Linux. Disk space usage means how much percent of space we use on the disk. Disk utilization means how busy the disk is when there is some workload on it. Today we will look at more details about this.
How to check disk space usage in Linux?
df command can be used to show disk usage. We can get how much percent space we already used on this disk or disk partition from Use% column. If it is over 80%, we should check which file or directories take up this space. Then we can remove some unwanted files to release the space.
# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 16G 0 16G 0% /dev tmpfs 16G 1.7G 14G 11% /dev/shm tmpfs 16G 834M 15G 6% /run tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/mapper/wbx_vg-root 20G 1.8G 18G 9% / /dev/mapper/wbx_vg-opt 9.8G 217M 9.6G 3% /opt /dev/mapper/wbx_vg-tmp 4.9G 45M 4.9G 1% /tmp /dev/mapper/wbx_vg-u00 43G 20G 24G 46% /u00 /dev/mapper/wbx_vg-var 9.8G 757M 9.1G 8% /var /dev/mapper/wbx_vg-var_crash 33G 39M 33G 1% /var/crash /dev/sdo1 509M 159M 350M 32% /boot
Filesystem The name of the disk partition.
Size The total size of the file system.
used The total amount of space allocated to existing files in the file system.
Available The total amount of space available within the file system.
Percentage used The percentage of the available space that currently allocated to all files on the file system.
Mounted on The directory in which the file system appears.
Df command Options
df -h shows disk space in human-readable format
df -a shows the file system's complete disk usage even if the Available field is 0
df -T shows the disk usage along with each block's filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)
df -i shows used and free inodes
df -t, –type=TYPE : limit listing to file systems of type TYPE
Df and Du
df is a standard Linux command used to display the amount of available disk space for file systems.
du is a standard Linux command used to estimate file space usage—space used under a particular directory or files on a file system. The du command summarizes disk space used for each FILE and/or directory.
How to check disk utilization on Linux?
Iostat command can be used to show disk utilization. We can get how busy our disk is when there is some workload on it from column %util. If it is over 80%, we need to check the workload like iops, io size or storage latency to fix it. More details here about disk utilization.
# iostat -kx 3 /dev/sdo Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sdo 0.06 0.78 1.62 13.27 98.69 177.04 37.04 0.50 33.48 72.83 28.68 4.21 6.27 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sdo 0.00 0.00 0.00 12.00 0.00 82.50 13.75 0.18 15.22 0.00 15.22 4.56 5.47
iostat: Get report and statistic.
iostat -x: Show more details statistics information.
iostat -c: Show only the cpu statistic.
iostat -d: Display only the device report.
iostat -xd: Show extended I/O statistic for device only.
iostat -k: Capture the statistics in kilobytes or megabytes.
iostat -k 2 3: Display cpu and device statistics with delay.
iostat -j ID mmcbkl0 sda6 -x -m 2 2: Display persistent device name statistics.
iostat -p: Display statistics for block devices.