Linux Learning Summary (vii)-Disk Management du DF fdisk

Source: Internet
Author: User
Tags disk usage

I think for a long time do not know how to start, then direct point, the main talk about three commands, DF du fdisk

One command DF

DF, disk free, can be used to view the current system mount or to view the overall disk usage
DF with no parameters, default in KB units

df -i -----查看inodes 使用情况,To clearly understand inodes suggestions see the following link to the article http://www.ruanyifeng.com/blog/2011/12/inode.html
For example Df-i |grep-v tmp

Note: Pipeline filtering is used here, and-V is the meaning of the complement set
df -h --------------根据实际情况自动调整单位的直观显示
For example DF-H |grep-v tmp

-k-m are displayed in KB and MB units, respectively

Two command du

Used to view the size of a directory or file occupied by the space

格式为 du [-abkmsh] [文件或目录名]

To understand the meaning of each parameter in turn
Du without any parameters default-K is displayed in KB units, listing only directories and subdirectories, not listing files

-A lists all files

-b-m Display in B,MB units
-H Auto Adjust unit display
-S list sum
du -sh 比较好用
such as Du-sh/etc

The difference between three df and Du

The DF command obtains the total number of blocks and the remaining blocks by looking at the file system disk block allocation graph. The file system allocates some of its disk blocks to record some of its own data, such as inode nodes, disk distribution maps, indirect blocks, super blocks, and so on. This data is not visible to most user-level programs, often referred to as meta data. The du command is a user-level program that does not take meta data into account, while the DF command looks at the file system's disk allocation diagram and considers meta data. The DF command obtains real file system data, while the DU command only looks at parts of the file system. By default, DF displays all of the system's mount conditions. The du command is used to display the disk space occupied by subdirectories or files in a directory, and the current directory is displayed by default. Using this book to make an analogy, du is equivalent to counting the amount of paper used to calculate the space, DF equivalent to calculate the area of the paper to get capacity size. Specifically, you can look at the next article http://blog.51cto.com/schenjiannan/1258183

Four FDISK disk partitions

Fdisk is a very powerful disk management tool that uses

fdisk -l 设备名称

Do not specify a device name to list all disk devices and partition tables in the system

If specified.

For example, a new HDD SDB

执行 fdisk /dev/sdb

Will prompt you to enter m to get partition help

You just have to read d delete a partition n create a new partition P print partition table Q do not save exit W write to partition table and exit.
Partition rule: The primary partition + expansion partition of not more than four, specific knowledge of MBR. Theoretically, extended partitions can be divided into several logical partitions, which can be said to be entities with extended partitions. The partition number at the end of the primary partition is 1-4, not enough four are empty, the logical partition number starts from 5, the logical partition number is automatically adjusted to continuous, such as SDB5, SDB6,SDB7 three logical partition, if you delete sdb5, automatically move up to SDB5.SDB6, It means that sdb6 becomes sdb5.sdb7 into SDB6.

Please see, my SDB hdd 10G, I divided three primary partitions sdb1, SDB2,SDB3, each 2G then I divide the rest to the extended partition SDB4, then I divide the extended partition all to SDB5 this logical partition, look at the blocks block this column, it is easy to verify the results.
Specific operation: press N partition, according to the prompt to expand the partition or E logical partition, down is the area code, followed by the partition size, let you specify the starting sector, the default is the line, enter. Down let you specify the end sector, direct input + partition size, such as I sub-2G, input +2g, if the wrong, ctrl+u back to lose, repeat the above to do, if the rest of the complete division, as I put 4G all left to expand the partition, you only need two times to enter, you do not need to specify the size. Finally p print Partition table see if there is a mistake, confirm the words, W Save exit can, practice a few times on the cooked, the workplace must be cautious.

Linux Learning Summary (vii)-Disk Management du DF fdisk

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.