Disk and directory capacity [from Vbird]

Source: Internet
Author: User

disk-to-directory capacity

Now we know that the overall data of the disk is in the Superblock block, but the capacity of each individual file is recorded in the Inode. How do you call these data under the text interface? Let's talk about these two commands at the bottom:

DF: Lists the overall disk usage of the file system;
Du: Evaluating the disk usage of the file system (commonly used in the estimated capacity of the catalog)

DF
[[email protected] ~]# DF [-ahikhtm] [directory or file name] options and Parameters:-A: List all file systems, including system-specific/proc and other file systems;-K: Displays the file systems in Kbytes capacity;-M: MBytes The capacity displays each file system; H: GBytes, MBytes, Kbytes and other formats that are easier to read;-H: Replace m=1024k with m=1000k;-T: Partition name with the filesystem (example such as EXT3) are also listed;-I: Do not use the hard disk capacity, but the number of inode to display

Example one: List all the filesystem in the system!

[Email protected] ~]# dffilesystem 1k-blocks used Available use% mounted on/dev/hdc2 9920624 3823112 5585444 41%//DEV/HD  C3 4956316 141376 4559108 4%/home/dev/hdc1 101086 11126 84741 12%/boottmpfs 371332 0 371332 0%/dev/shm# under Linux if DF Without any option, the default is to list all of the # in the system (no special memory file system and swap) with 1 Kbytes capacity! # As for that/DEV/SHM is memory-related mounts, don't talk to him first!

Example two: Display capacity results in a readable capacity format

[Email protected] ~]# df-hfilesystem Size used Avail use% mounted on/dev/hdc2 9.5G 3.7G 5.4G 41%//dev/hdc3 4.8G 139M 4. 4G 4%/home/dev/hdc1 99M 11M 83M 12%/boottmpfs 363M 0 363M 0%/dev/shm# Unlike example one, this will be shown in g/m capacity format, it is easier to see!

Example three: List all special file formats and names in the system

[[email protected] ~]# df-atfilesystem Type 1k-blocks used Available use% mounted on/dev/hdc2 ext3 9920624 3823112 558544 4 41%/proc proc 0 0 0-/procsysfs SYSFS 0 0 0-/sysdevpts devpts 0 0 0-/dev/pts/dev/hdc3 ext3 4956316 141376 4559108 4%/home/dev/hdc1 ext3 101086 11126 84741 12%/boottmpfs tmpfs 371332 0 371332 0%/dev/shmnone binfmt_misc 0 0 0-/proc/s Ys/fs/binfmt_miscsunrpc rpc_pipefs 0 0 0-/var/lib/nfs/rpc_pipefs# system There are actually a lot of special file systems in existence. The more special file systems are almost all in memory, such as the/proc mount point. As a result, these special file systems # will not occupy hard disk space Oh! ^_^

Example four: Display the available disk capacity under/etc in an easy-to-read capacity format

[[email protected] ~]# df-h/etcfilesystem Size used Avail use% mounted on/dev/hdc2 9.5G 3.7G 5.4G 41%/# This example is a little more interesting, in D F after adding a directory or a file, df# will automatically parse the directory or the partition of the file, and display the capacity of the partition, # so you can know how much capacity is available under a directory! ^_^

Example five: List the number of inode numbers currently available in each partition

[[email protected] ~]# df-ih Filesystem inodes iused IFree iuse% mounted on/dev/hdc2 2.5M 147K 2.3M 6%//DEV/HDC3 1.3M 46 1.3M 1%/home/dev/hdc1 26K 26K 1%/boottmpfs 91K 1 91K 1%/dev/shm# This example mainly lists the available inode remainder and total capacity. To analyze the relationship with example one, you can clearly see that the number of inode is usually more than block.

Let's start by explaining that the result information of the example output is:

Filesystem: Indicates the file system is in which partition, so list the device name;

1k-blocks: The bottom of the figure is 1KB yo! can use-h or-m to change capacity;

Used: As the name implies, is the use of hard disk space!

Available: That is the amount of disk space left;

Use%: That's the disk usage rate! If the use rate of up to 90%, it is best to pay attention to, lest the capacity is not enough to cause system problems Oh! (for example, the/var/spool/mail is the most likely to be blown off the disk that placed the message)

Mounted on: The directory where the disk is mounted! (Mount point!) )

Since DF is mostly reading data for an entire file system, the read range is primarily information within the superblock, so this command shows the results very quickly! In the results shown you need to pay special attention to the remaining capacity of that root directory! Because all of our data is derived from the root directory, your Linux may be a big problem when the remaining capacity of the root directory is 0 o'clock.

It is also important to note that if you use the-a parameter, the system will appear/proc this mount point, but the inside of the things are 0, do not tense! /proc is the system data that the Linux system needs to load, and it is mounted in "memory", so of course it doesn't occupy any hard disk space!

As for that/dev/shm/directory, it is actually using the memory virtual out of disk space! Because it is a disk that is emulated through memory, the access speed is very fast when you create any data file under this directory! (Working in memory) However, because he is a memory emulation, so the size of the file system on each host is different, and the creation of the next time it started to disappear! Because it's in memory!


du
[[email protected] ~]# du [-ahskm] file or directory name options and parameters:-A: Lists all files and directory capacity, because the default is only the number of files under the directory. -H: Displayed in a more readable capacity format (g/m);-S: Lists the total, not the capacity of each directory, and-s: excludes the totals under subdirectories, which is a bit different from the-S. -K: List capacity display in Kbytes;-M: Displays the capacity in MBytes;

Example one: List all file sizes in the current directory

[[email protected] ~]# du8./test4 <== Each directory will be listed 8./test2 .... Middle omitted .... /.GCONFD <== includes directory 220 for hidden files. <== this directory (.) Total # occupied # Direct input du does not have any options, then du parses the hard disk space occupied by the files and directories of the "current directory" #. However, when actually displayed, only the directory capacity (excluding files) is displayed, # so. There are many files in the directory that are not listed, so the total number of directories is not equal. of capacity Oh! # In addition, the output value data is a capacity unit of 1K size.

Example two: same example one, but also lists the file's capacity

[Email protected] ~]# du-a12./install.log.syslog <== has a list of files 8./.bash_logout8./test48./test2. Middle omitted .... /.gconfd220.

Example three: Check the capacity of each directory under the root directory

[Email protected] ~]# du-sm/*7/bin6/boot ..... Middle omitted .... 0/proc ..... Middle omitted .... 1/TMP3859/USR <== System at the beginning of the biggest is him! 77/var# This is a very often used function ~ Use the wildcard * to represent each directory, # If you want to check a directory, which sub-directory occupies the maximum capacity, you can use this method to find out # It is worth noting that if you just installed Linux, then the overall system capacity is the largest should be/usr # While/proc has a list of capacity, the capacity is in memory and does not occupy hard disk space.

Unlike DF, du's command actually searches the file system for all of the file data, so the third example command runs for a short period of time! In addition, by default, the output of the capacity is designed in kilobytes, and if you want to know how many megabytes the directory occupies, then use the-m parameter! And, if you just want to know how much capacity the directory occupies, use-S is OK!

As for the-s option part, because du defaults to the size of all files listed, it is assumed that when you use du under/etc, all file sizes, including the sub-directory capacity under/etc, will also be calculated once. Then the final capacity (/etc) will be added once, so many friends will misunderstand the results of DU analysis is not quite right. So, if you want to list all of the data under a directory, perhaps also add-s option, reduce the total of the secondary directory Oh!

Transfer from http://vbird.dic.ksu.edu.tw/linux_basic/0230filesystem_2.php

Disk and directory capacity [from Vbird]

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.