Monday, April 28, 2025

Check free space in UNIX - df command tutorial

To check free disk space on our UNIX system we will use UNIX df command.

Standard report after df command will be simmilar to this (note, this is my old IBM R32 laptop with OpenBSD on it):

#df 

Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a      1389148    296708   1022984    22%    /
/dev/wd0k     13470908   3247728   9549636    25%    /home
/dev/wd0d      2202748       616   2091996     0%    /tmp
/dev/wd0f      3038428    703640   2182868    24%    /usr
/dev/wd0g      1764380    325380   1350784    19%    /usr/X11R6
/dev/wd0h      6578268   1820580   4428776    29%    /usr/local
/dev/wd0j      2799836         4   2659844     0%    /usr/obj
/dev/wd0i      2799836         4   2659844     0%    /usr/src
/dev/wd0e      3348924    102312   3079168     3%    /var 

If you need more readable report, use df with -h option (Human Readable Output):

#df -h

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a      678M    146M    499M    23%    /
/dev/wd0k      6.4G    1.5G    4.6G    25%    /home
/dev/wd0d      1.0G    308K   1022M     0%    /tmp
/dev/wd0f      1.4G    344M    1.0G    24%    /usr
/dev/wd0g      862M    159M    660M    19%    /usr/X11R6
/dev/wd0h      3.1G    889M    2.1G    29%    /usr/local
/dev/wd0j      1.3G    2.0K    1.3G     0%    /usr/obj
/dev/wd0i      1.3G    2.0K    1.3G     0%    /usr/src
/dev/wd0e      1.6G   50.0M    1.5G     3%    /var 

If, for some reason, you need report where blocks are not 512 bytes, but one kilobyte, use df with -k option:

#df -k

Filesystem  1K-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a      694574    149968    509878    23%    /
/dev/wd0k     6735454   1623868   4774814    25%    /home
/dev/wd0d     1101374       308   1045998     0%    /tmp
/dev/wd0f     1519214    351820   1091434    24%    /usr
/dev/wd0g      882190    162690    675392    19%    /usr/X11R6
/dev/wd0h     3289134    910290   2214388    29%    /usr/local
/dev/wd0j     1399918         2   1329922     0%    /usr/obj
/dev/wd0i     1399918         2   1329922     0%    /usr/src
/dev/wd0e     1674462     51156   1539584     3%    /var

How to limit report to just one partition ? It's easy, just use df with, say, /home. Also, we will use -h option again:

#df -h /home

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0k      6.4G    1.5G    4.6G    25%    /home

You can check inode by #df -i:

Filesystem  512-blocks      Used     Avail Capacity iused   ifree  %iused  Mounted on
/dev/wd0a      1389148    249532   1070160    19%    2936   85638     3%   /
/dev/wd0k     13470908   3247744   9549620    25%   17535  865919     2%   /home
/dev/wd0d      2202748       100   2092512     0%      10  155892     0%   /tmp
/dev/wd0f      3038428    703640   2182868    24%   13683  194187     7%   /usr
/dev/wd0g      1764380    325380   1350784    19%    9017  120901     7%   /usr/X11R6
/dev/wd0h      6578268   1820580   4428776    29%   53722  388004    12%   /usr/local
/dev/wd0j      2799836         4   2659844     0%       1  181885     0%   /usr/obj
/dev/wd0i      2799836         4   2659844     0%       1  181885     0%   /usr/src
/dev/wd0e      3348924    102336   3079144     3%    3671  230183     2%   /var 

 

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...