Good Place. Good Things. Good Time.

Linux Disk Space

Linux Disk Space

Introduction to Linux Disk Space

The following article provides an outline for Linux Disk Space. Disk Space is defined as a utility which helps the user with the space left in the system’s disk. Within this utility itself, there are numerous sub-utilities which allows the user to perform specific tasks. A few examples of such tasks are managing the disk space, checking the disk space, freeing up the disk space, etc. In this article, we will take a dig at each of the tasks which are performed separately within the big picture of Disk Space. One needs to make sure that the user who is performing such disk space actions on the system needs to have appropriate read access, devoid of which it will be impossible to even test out the commands.

Syntax of Linux Disk Space

In Linux, there are a lot of options available for Linux Disk space utilities, and to respect the restriction of the article size, we would need to shortlist a few of them, but be sure of the fact that the options we would be discussing here would suffice most of the utilities which are used in today’s world.

Here we would look at the syntax first, and in subsequent blocks of the article, look at the working of Disk space’s utilities.

1. Checking the disk space usage.

Syntax:

df

2. Human readable format for displaying disk space.

Syntax:

df -h

The above option of -h can be replaced by -m if the user wants to get the disk space in MB, or it can be replaced by -k if a user wants to get the disk space in KB.

3. Displaying information about a particular mount location.

Syntax:

df -hT

4. Display the inodes of the file system.

Syntax:

df -i

5. Display the type of the File System.

Syntax:

df -T

6. List only certain file system type.

Syntax:

df -t

7. List after exclusion of certain file system.

Syntax:

df -x

8. Display the complete disk usage even if the available field is 0.

Syntax:

df -a

9. Displaying the help section of the command.

Syntax:

df --help

How does Linux Disk Space Work?

Before we see about Linux disk space, let us familiarize ourselves with some key notations when it comes to space. It is a known fact that 1024 GB = 1TB. Now when you buy a 1 TB drive and mount it, the system will report it as 977 GB. Ok. Where did the rest of 23 GB go? As a matter of fact, it didn’t go anywhere, and neither you should feel that you are cheated. The discrepancy lies in disk manufacturers using true metric measurements, i.e. 1000 instead of 1024.

So mathematically,

1 TB = (1000 /1024) *1000 GB = 976.5 ~ 977 GB

Now coming to the next pointer on how the file gets stored in the disk. The contents in the files are stored in data blocks in the disk. Now, the question which arises is, if a specific block contains contents in a file, how a command would know on what to retrieve. For this, the usage of the inode is what comes to play. An inode is like file pointers which are presently pointing to a specific location or block in the disk space.

Now the inode carries some information of the block, and using this, or in other words by the usage of the file pointers left; the system finds the group of pointers which are not consumed and then sums up the non-used space to show up the free space! One must also be wary of the fact that Disk has some reserved space which is known as Reserved Block count, space which is reserved by the kernel for privileged users’ processes which are not available for everyone to access hence, might show up disk as 100% full, even though there might be some space in the comparison between size and used.

Examples of Linux Disk Space

Given below shows specific examples of different commands in disk space for specific utilities:

Example #1

Checking the disk space usage.

Syntax:

df

Output:

Linux Disk Space 1

Here we see that all the properties are mentioned in a crude form that is not so human-readable. The different file systems are mounted in different locations, as mentioned in the display. One can also get the use% of the different filesystem and, in accordance to that, make a necessary strategy to optimize the disk space.

Example #2

Human readable format for displaying disk space.

Syntax:

df -h

Output:

Formatting in GB:

Formatting in GB

Formatting in KB:

df -k

Output:

Formatting in KB

Formatting in MB:

df -m

Output:

in MB

Example #3

Displaying information about a particular mount location.

Syntax:

df -hT /dev
df -hT /run

Output:

Displaying information about a particular mount location

Example #4

Display the inodes of the file system.

Syntax:

df -i

Output:

Linux Disk Space 8

Example #5

Display the type of the File System.

Syntax:

df -T

Output:

Linux Disk Space 9

Example #6

List only certain file system type.

Syntax:

df -T
df -t btrfs

Output:

Display of File system will all file types:

Linux Disk Space 11

Display of file system for the only btrfs:

Linux Disk Space 12

In the first snap, only the highlighted ones get displayed when the second command is executed.

Example #7

List after exclusion of certain file system.

Syntax:

df -x btrfs

Output

Display of File system will all file types:

Linux Disk Space 13
Display of file system excluding btrfs:

Linux Disk Space 14

The ones highlighted in the first snapshots are removed.

Example #8

Display the complete disk usage even if the available field is 0.

Syntax:

df -a

Output:

Linux Disk Space 16

Example #9

Displaying the help section of the command.

Syntax:

df --help

Output:

Linux Disk Space 17

In this example, we see that most of them seldom used all the other options visible when the command is executed.

Conclusion

With the set of examples and explanation of the way of working for disk space, we can get a sense of the df command’s utility. Another thing to mention is that there is the availability of another command du which more or less performs a similar task as df, and is left to the readers to try and experiment it out so that one can easily appreciate the vastness which Linux brings! Last but not the least, we would recommend the readers to try each of the commands by themselves to understand and get eased to the working of the command.

Recommended Articles

This is a guide to Linux Disk Space. Here we discuss the introduction; how does Linux disk space work? And examples, respectively. You may also have a look at the following articles to learn more –

  1. Linux Xargs
  2. Linux LVM
  3. Linux Size
  4. Linux Kill Signals

The post Linux Disk Space appeared first on EDUCBA.

Read original article here: Linux Disk Space

Read original article here: Linux Disk Space



Disclaimers and Denial of responsibility..!

Denial of responsibility! TheTopMag.com is an automatic aggregator of all media around the world. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – jamesonline999@gmail.com . The content will be deleted within 72 hours.
You might also like
Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.