DF and Du commands

Source: Internet
Author: User
Tags disk usage

As a DBA for daily inspection work, is essential, Du and DF commands are commonly used, the following simple to say


DF Command Verbose usage


A: Displays all file systems and disk usage scenarios for each partition

I: Show the usage of i-nodes

K: size is denoted by K (default value)

T: Displays all partition disk usage for one file system

X: Displays all partitions that are not part of a file system disk usage

T: Displays the name of the file system to which each partition belongs

Common commands: Df-hi


Detailed operation


Reference

Instruction DF can show the maximum available space and usage for all current file systems, see this example:


# df-h

Filesystem Size used Avail capacity mounted on

/DEV/AD0S1A 1.9G 389M 1.4G 21%/

Devfs 1.0K 1.0K 0B 100%/dev

/dev/ad0s1d 989M 54K 910M 0%/tmp

/dev/ad0s1f 4.8G 3.8G 657M 86%/usr

/dev/ad0s1e 1.9G 149M 1.6G 8%/var

/dev/ad0s1g 26G 890K 24G 0%/volume2

/dev/da0s1d 325G 261G 38G 87%/volume1


We added the parameter-H to use the "human-readable" output, that is, in the file system size using GB, MB and other easy-to-read format.


The first and last fields of the above instruction output are the file system and its hang-in points respectively. We can see that this partition of/DEV/AD0S1A is hung in the root directory. We mentioned in the previous section that ad represents the IDE's hard disk, and S1 represents the first major sector. I also have a SCSI hard disk, its code name is DA, it's large capacity, mainly used to store data. DEVFS is a special file system, which is not a real disk, but a virtual file system used by FreeBSD to manage the hardware of the system.


The next four fields size, used, Avail, and capacity are the partition's capacity, the size used, the remaining size, and the percentage used. When the hard disk is full, you may see that the percentage used is more than 100% because FreeBSD leaves some room for root, allowing Root to be managed by writing to the file system when the file system is full.


In addition, we can use the parameter-I to view the current use of the file system inode. Sometimes although the file system still has space, but if there is not enough inode to store the information of the file, the same will not add new files.


# Df-ih

Filesystem Size used Avail capacity iused ifree%iused mounted on

/DEV/AD0S1A 1.9G 389M 1.4G 21% 20495 262127 7%/

Devfs 1.0K 1.0K 0B 100% 0 0 100%/dev

/dev/ad0s1d 989M 62K 910M 0% 141286 0%/tmp

/dev/ad0s1f 4.8G 3.8G 657M 86% 311439 348015 47%/usr

/dev/ad0s1e 1.9G 149M 1.6G 8% 1758 280864 1%/var

/dev/ad0s1g 26G 890K 24G 0% 3532786 0%/volume2

/dev/da0s1d 325G 261G 38G 87% 707277 43311409 2%/volume1

We can see that the number of inode used in the root directory is 20495, and there are 262127 available inode.


Little Tips

Do you remember what an inode is? The so-called Inode is the basic information (metadata) that is used to store files and directories, including time, file names, users, and groups. When splitting a sector, the system makes a bunch of inode for later use, and the number of inode is related to the total number of files and directories that can be created in the system. If most of the files to be saved are very small, then the same size of the hard disk will have more files, that is to say, more inode to hang files and directories.



Du: Querying the disk usage space for an archive or directory


A: Displays the disk space occupied by all directories and each file under the second directory

B: Size is represented by bytes (default is k bytes)

C: Last plus Total (default value)

S: Show only the sum of each file size (summarize)

X: Only files that belong to the same file system are counted

L: Calculate all file sizes

Common commands: Du-a


Detailed operation


Reference

The instruction du can display the amount of disk space occupied by all the files in each directory, in the subdirectories of the specified directory. For example:


# Du-h/etc

104k/etc/defaults

6.0k/etc/x11

8.0k/etc/bluetooth

4.0k/etc/gnats

52k/etc/isdn

388k/etc/mail

68k/etc/mtree

2.0k/etc/ntp

38k/etc/pam.d

44k/etc/periodic/daily

6.0k/etc/periodic/monthly

42k/etc/periodic/security

16k/etc/periodic/weekly

110k/etc/periodic

6.0k/etc/ppp

318k/etc/rc.d

2.0k/etc/skel

130k/etc/ssh

10k/etc/ssl

1.7m/etc

We use the-H parameter to display the format of the human-readable. In the application, we can use the DU command to see which directory occupies the most space. However, Du's output is usually very long, we can add the-s parameter to omit subdirectories under the specified directory, and only show the sum of that directory:


# DU-SH/ETC

1.7m/etc

When we look at the usage of the catalog, we can sort the output into the sorts directive to see which file uses the most space:


# Du/etc | Sort-nr | More

1746/etc

388/etc/mail

318/etc/rc.d

130/etc/ssh

110/etc/periodic

104/etc/defaults

68/etc/mtree

52/etc/isdn

44/etc/periodic/daily

42/etc/periodic/security

38/etc/pam.d

16/etc/periodic/weekly

10/etc/ssl

8/etc/bluetooth

6/etc/ppp

6/etc/periodic/monthly

6/etc/x11

4/etc/gnats

2/etc/skel

2/etc/ntp

The sort parameter,-nr, indicates that you want to reverse sort by the numeric sort, because we want to sort the size of the directory, so we can not use the size of the human-readable output, otherwise the directory size will have K, M and other words, will cause the sorting is incorrect.


This article is from "Allen Lee Oracle" blog, please make sure to keep this source http://lipengfei666666.blog.51cto.com/6384154/1641490

DF and Du commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.