Calculation of file space occupation

Source: Internet
Author: User
Article Title: Calculation of file space occupation. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

First, we need to first understand the size of the I/o block (a cluster in Chinese) of your file system. The size of the I/O BLOCK in this file system is 4096 Bytes.

It is the smallest read/write and allocation unit of the file system. You cannot be smaller than this size for each read/write operation. Even if your file has only one byte. In addition, the storage of files on the hard disk is also in this unit. That is to say, if the file size is smaller than this value, the space occupied by the file on the disk is 4096 bytes.

The specific algorithm for space occupation is: (1 (file size/4096) × 4096. Based on this, you can calculate the space usage of the files in the example you listed: for example, the file length of file.txt is 34890 (ls-l), 34890 divided by 4096, which is about 8.5, the first method is 9, that is, the file occupies 9 blocks on the disk, and each BLOCk is 4 K. Therefore, the space occupied by these two files is 36 K.

This rule is also suitable for directories, but there will be no directories with 0, even empty directories.

Related Article

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.