UNIX: space occupied by a file in file system and disk

Source: Internet
Author: User

References:

Harley hahns: Guide to Unix and Linux, chap 24


-- The first key concept: the amount of "disk space" used by a file is not the same as the amount of data in the file.


-- "Second, understand that there are two smallest space units in file system and disk (or other storage medium):" Block "in file system and" Allocation unit "in disk ";

The minimum space unit relationship: the size of "Allocation unit" depends on the filesystem and the storage device. For example, in the reference author's computer, the smallest block occupied by filesystem is 1 K bytes, and disk allocation units is 8 K bytes. Therefore, if a file contains data of 1 B, 1 block (1 K) is occupied in the filesystem, and 8 K disk space is occupied in the disk.


**************************************** **************************************

So the following question: how to detemine size of block? How to determine size of allocation unit?

-- Size of allocation units:

* Create a small file first

* Use the LS-l file to check the actual data contained in the file (in bytes), which is displayed before the time.

* Use Du-H file to view how much "disk space" the file takes up

The disk space found here is the minimum unit occupied by your disk. on my computer, it is 4 kb.


-- Size of block in filesystem:

The idea is to use the dumpe2fs command under the Administrator permission to view the nature of a block in filesystem: superblock and check its block size to determine the size of a block in filesystem.

* Use the DF command to find out the name of the special file that represents the filesystem, such as/dev/hda1.

* Use Su to obtain superuser Permissions

* When Using dumpe2fs for superuser permissions, use the grep command to collect "block size" information: dumpe2fs/dev/hda1 | grep "block size"

The block size is the minimum space occupied by a block in your file system. On my computer, it is 1024.

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.