Episode: 1022 Title: HPR1022: LiTS 010: df - Exploring Disk Filesystem Usage Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1022/hpr1022.mp3 Transcribed: 2025-10-17 17:30:13 --- Welcome to Linux in the Shell Episode 10 DF exploring the disk file system usage command. My name is Dan Waschko. I'll be your host today and as always I'd like to thank Hercopublic Radio for hosting the website for this show and the shows on Hercopublic Radio. If you have not already read the website, make sure you do so at some time after listening to this audio so you can refresh what's discussed here and then also watch the video of the examples of the disk use file system usage command. From now on I will just say DF for short. The DF command is used to report file system usage and it will show you the amount of storage available to your system used and free per partition for each file system currently mounted on the system. Now the values are shown in blocks and the default output is going to be 1 kilobyte block and if you actually run the command it will show all your current file systems that are mounted. For instance I run it on mine and I have a couple of file systems on every file system dev slash run slash dev sda 5 which is my root partition and then dev sda 7 which is my home partition and it shows me some good information on there like how much of the 1 kilobyte blocks that device actually has, how much is used and how much is available then it shows me a percentage and where it's actually mounted. Now when you first run the DF command if you look at the output you'll probably recognize your standard root file system whatever partitions you have mounted any shares also will show your network shares too or any removal the removable devices that you have but there are some things in here you might not recognize like I had just mentioned root file system or root F S H M slash dev slash run and what those are root F S it's a special instance of RAM F S and it's used for page cache and dentery cache. So it's used for memory to be cached then there's the dev which is a pseudo file system which holds the mount points for all the hardware devices identified by the kernel. The slash run is a temp F S that's created by the kernel holding application runtime information that's fair that's on some fairly new systems in the past couple of years you might not see it on a system that I think maybe five or so or more years older you might not see that. S H M or slash S H M is another temp file system partition and it's used for shared memory passing data between programs and then temp F S which is temporary file system which is temporary space allocated from RAM to be used as temporary sub-dorage it's a swappable memory. So when you might see some of those in there mixed in with your file systems so when you run the DF command you'll see a list of that and more than likely what you're going to be interested in is how much space you have on your root partition if you have a separate home partition and any mountable or shares that you have or mountable storage devices and it'll show you that like I said by default it's in kilobytes so you can change that by specifying the dash capital B and then the specifying one of the following letters, capital letters for whatever size that you would like to have them reported in. For instance dash B capital B capital K, it's like BK like Burger King, dash BK will give it to you in the default kilobytes blocks. Now you could also use the short just dash K for this, dash capital B capital M or just dash M for short is the megabyte blocks it'll show you a megabyte blocks and of course dash BG capital BG or just dash G shows you a gigabyte. Then there's also depending on how new your DF is you can show it in terabytes which is dash capital B capital T, petabytes dash capital B capital P, exabytes dash capital B capital E, zedabytes dash capital B capital Z and yonthabytes which is dash B capital Y capital B. Now it's just kilobytes megabytes and gigabits that have the shortcuts to dash K dash M dash G, terabytes petabytes exabytes zedabytes yonthabytes yadabytes do not have that. Now again like some of the other commands I think it was in free, I had talked about the dash H which is in human readable. Some newer versions of DF have the human readable option so if you pass the dash H it will show you the values in the closest three number value it can. So if you have like a 300 gigabyte drive it will show it to you in gigabytes and it might show like if you're only using like 500 megabytes of that partition it will show you the 500 megabytes it's not going to show you like one truncated to one gigabyte being used or show you in kilobytes with the dash H it will show you in the most human readable value possible up to the you know three once it reaches it exceeds three digits it usually moves on to the next higher side so if it was like 900 kilobytes it will show that but if once it reaches a thousand kilobytes then it's just one megabyte same thing and once it reaches one thousand megabytes or one thousand twenty four megabytes it's onto a gigabyte so one thousand kilobytes one thousand twenty four kilobytes will give you to megabyte. Now there's an option in there that instead of using megabyte or in one thousand twenty four blocks instead you know default value is one thousand twenty four bytes you can there are two options that you can calculate them in the powers of one thousand bytes so that's a dash capital B K B all capitals which shows it to you in one thousand kilobytes blocks and then there's dash capital B capital M which shows you in one thousand well megabyte blocks of one thousand byte blocks so that that's what it'll show you there probably never going to use that but just just be careful also if if you if you're trying to display like your file system and exabytes that a bytes or yada bytes there's a possibility that when you run it if you don't have that size of a drive it's going to come back and report to you that the B argument X like or it's going to be easy or Y is too large so just be aware of that now if you ask it to report you to you a 300 gigabyte drive and terabytes it's probably going to show you one terabyte not that you actually have one terabyte but if you were to specify that it kind of says okay you actually have data in there so you specified in terabytes there's data there's something available it shows it to you it's one terabyte like for instance on my if I run df.h on my system right now in dev sda one it's a 20 gig partition and it shows that 3.6 gigs are available 15 gigs are being used so 81% of the drive is being used but if I were to test for terabytes it would show me that there's one terabyte block available one terabytes being used one terabytes available but it still shows me that there's 81% value so you might get some wonky values there and it's probably not practical for you to to use that so just be aware of that now you can restrict the output of df to only displaying a certain file system with the dash t or dash type equals so let's say all your you have a couple of partitions and their ext4 and you just want to see your ext4 partitions then you would just type in df space dash t space ext4 and I'll show you all the file systems that you have mounted and the statistics for those ext4 file systems only now you can exclude the file system the same way but instead of using dash t use dash x and then it will exclude file systems of that type now df has the ability to display i-nodes instead of blocks and you might wonder what an i-node is well i-node stands for index node and it's a data structure that stores all the information about a file system object but it's not the actual name or the data for the object it stores some other information like the permissions the size time stamps and stuff but again not the name or the data of the actual object now you can display the i-node usage of your system with the dash i command so if you do df dash i it'll show you the i-nodes how many are being used how many are available and the percentage of that are being used how much is left or how much is actually being used of the i-nodes and of course you can pass the dash h option so you could do df dash i h and it will show you in human readable format so in size it's kind of for i-nodes like if i did that on my system right now it tells me that i have 1.3 megabytes of i-nodes available 245 kilobyte of i-nodes available used 997 free so i'm using 20% of my root partitions i-node capacity is what it's telling me now there is a total option which is dash total spelled out which after it displays all the file system information we'll total it up where practical at the bottom so if you were to do df total dash dash total and you can pass the dash h for human readable to it it would total up the like for size it would add all your partitions together and report the total there for size until you get the total used and a total available now you you can you can again use some of the other switches to show your xt4 partitions with the type where you can exclude your xt4 partitions with the x and and get that all totaled up so that that could be handy may not be handy by default df will show all mounted file systems even remote file systems now you can ignore remote file systems with the dash l which is the local or dash dash local switch so it will only show you none or only show your local file systems it will not show you anything that you have mounted like an nfs or sshfs it won't show you those and only show you locally mounted file systems which will include removable media but only the local file systems there is a df dash a which shows you all file systems you might say well what was i missing when i just ran df by default well there's a couple of things that that weren't reported like proc and sys and bnft different file systems that really df isn't going to report any usable information on so like proc is a pseudo file system that holds process information in the state of the kernel so it's kind of really not going to show you information from df sys is a synthetic file system and that provides information about the internal status to user space devices buses and loadable modules so it can give you some information there um there's a dev pts which provides interface to the pseudo terminals or pdy devices like x term and console and stuff like that utilize that to to provide you with the terminals and then like gfs fuse daemon is another one that might show up and that's the user space file system used by gnome you might not see that um i'm running i'm not running gnome fs right now so i'm not seeing that when i run df dash a but on another system where it might be running in the background it'll show me the gfs gvfs fuse daemon as a a file system in there df is a handy tool to help you get a good idea of what's going on in your file system how much space you have how much is being used how much is available to you you can look at your eye notes making sure you're not running out of eye nodes um the last option to be aware of is the dash dash no dash sync option and that's default mode for df which it does not perform a sync operation on the file system before reporting values and example to this is you plug in your usb um mass storage device and you do a df command and it reports now more than likely you haven't done anything on that usb mass storage device so the values that you see are going to be fairly accurate but if you start copying files to it um and maybe removing files and you run df df is not going to doesn't do a sync command by default so on a usb type device a mass storage system or like in a flash card or something like that you issue a command to to perform like data copy or data removal it might not happen instantaneously so therefore df is going to report the old values although you might have some new data on there that hasn't been um written completely yet in sync you can change that typing in the dash dash sync option that switch will sync all the drives or devices file systems before it reports the values and depending on what you have mounted and what's going on it might take a little while for things to be reported back so df command handy tool and every system administrators or even users tool kit right there just keep an eye on your system make sure it's healthy and you're not running out of disk space things are starting to go wonky you're having problems if you type a df dash h or df to see make sure you're not running out of a disk space on your you know root partition or on your home partition that are not at a hundred percent keep an eye on that it's a handy tool to have my name is Dan check out the website linuxintheshell.org for the full write-up of this episode in the corresponding example video i thank you very much and we'll see you in another two weeks and make sure you're listening to hacker public radio you have been listening to hacker public radio or hacker public radio those are we are a community podcast network that releases shows every weekday on death before today show like all our shows was contributed by a hbr listener by yourself if you ever consider recording a podcast then visit our website to find out how easy it really is hacker public radio was founded by the digital dog pound and the economical and computer cloud hbr is funded by the binary revolution at binref.com all binref projects are crowd sponsored by linux pages from shared hosting to custom private clouds go to luna pages.com for all your hosting needs unless otherwise stasis today's show is released under a creative comments attribution share a line free does our license