Df

From DikapediaV2
Jump to: navigation, search


df - DISK FREE; Report file system disk space.


Df shows the available sizes on your disk partition. Tells you what percentage of the disk is occupied. Shows you what's mounted.


How To Use Df



Basic Uses


df
df -ah

$ df -h                                             
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.7G     0  3.7G   0% /dev
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           3.7G  213M  3.5G   6% /run
tmpfs           3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/nvme0n1p2   10G  7.0G  3.1G  70% /
/dev/nvme2n1p2  4.8G  329M  4.3G   8% /home/ardika
/dev/nvme1n1p1  188G  5.0G  175G   3% /var/log/important_app_logs
/dev/nvme2n1p1  4.8G  205M  4.4G   5% /home/ec2-user
tmpfs           753M     0  753M   0% /run/user/1000

-h, --human-readable; print sizes in human readable format (e.g., 1K 234M 2G)
-a, --all; include pseudo, duplicate, inaccessible file systems.


Inodes


-i, --inodes; list inode information instead of block usage

$ df -i
Filesystem       Inodes  IUsed    IFree IUse% Mounted on
devtmpfs         957312    322   956990    1% /dev
tmpfs            963252      1   963251    1% /dev/shm
tmpfs            963252    467   962785    1% /run
tmpfs            963252     16   963236    1% /sys/fs/cgroup
/dev/nvme0n1p2  5241792 134933  5106859    3% /
/dev/nvme2n1p2   327680  13184   314496    5% /home/ardika
/dev/nvme1n1p1 12517376     16 12517360    1% /var/log/important_app_logs
/dev/nvme2n1p1   327680   6024   321656    2% /home/ec2-user
tmpfs            963252      1   963251    1% /run/user/1000

In the above example, the root partition (/dev/nvme0n1p2) has 5,241,792 total inodes, but only 134,933 are used. Which means you can create another 5,106,859 on that file system.


In the case where 100% of your inodes are used, only a few options:

  • You can try to identify a large number of files that you can delete or move to another file system.
  • you can possibly archive a group of files into a tar archive.
  • you can back up the files on your current file system, reformat it with more inodes, and copy the files back.


Why df -h seem to show less than the actual size of the volume


the system actually takes up a small amount of disk space. You would see that the storage device showing the 2.8T storage device in "lsblk" is showing as 2.7T under "df -h."

This is because some of the storage is hidden in the different units of measurement used to report disk capacity. How this space is reported and used varies by filesystem and by tools, as well. I've found a great article breaking down essentially what happens to the "missing" storage, and why it is "missing" (This is an article from Red Hat, but is also relevant to most of, if not all Linux operating systems); [1]

- https://www.redhat.com/sysadmin/disk-space