赞
踩
Why does every directory have a size 4096 bytes (4 K)?](https://askubuntu.com/questions/186813/why-does-every-directory-have-a-size-4096-bytes-4-k)
To understand this, you’d better have some basic knowledge of the following (file system):
A directory is just a special file which contains an array of filenames and inode numbers. When the directory was created, the file system allocated 1 inode to the directory with a “filename” (dir name in fact). The inode points to a single data block (minimum overhead), which is 4096 bytes. That’s why you see 4096 / 4.0K when using ls.
Example:
root@ubuntu:~# tune2fs -l /dev/ubuntu/root tune2fs 1.42 (29-Nov-2011) Filesystem volume name: <none> Last mounted on: / Filesystem UUID: 2fca4cbb-22f1-4328-ab13-cacedb360930 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 967680 Block count: 3931136 Reserved block count: 0 Free blocks: 2537341 Free inodes: 517736 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 416 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8064 Inode blocks per group: 504 RAID stride: 35637 Flex block group size: 16 Filesystem created: Thu Mar 15 14:31:04 2012 Last mount time: Sat Oct 20 20:28:04 2012 Last write time: Sat Oct 20 20:23:32 2012 Mount count: 1 Maximum mount count: -1 Last checked: Sat Oct 20 20:22:57 2012 Check interval: 0 (<none>) Lifetime writes: 54 GB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 First orphan inode: 272350 Default directory hash: half_md4 Directory Hash Seed: d582ad79-75a0-4964-9a48-33ddba04df5c Journal backup: inode blocks
Linux中一切皆文件,文件夹创建过程中会为分配一个inode,文件系统inode会指向磁盘的一个块,块大小由文件系统决定,从以上信息可知文件系统的块的大小为4k。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。