linux 往文件写4k大小,[svc]为何linux ext4文件系统目录默认大小是4k?

linux ext4普通盘为什么目录大小是4k?

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):

inode (contains file attributes, metadata of file, pointer structure)

file (can be considered a table with 2 columns, filename and its inode, inode points to the raw data blocks on the block device)

directory (just a special file, container for other filenames. It contains an array of filenames and inode numbers for each filename. Also it describes the relationship between parent and children.)

symbolic link VS hard link

dentry (directory entries)

...

On typical ext4 file system (I reckon most likely this is what you are using), the default inode size is 256 bytes, block size is 4096 bytes.

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.

要理解这个,你首先要懂:(注: 这里我用c7.4,默认xfs:/etc/fstab,我又挂了一个格式化成ext4做的实验)

inode:

file

directory

symblic: 软链接

ff4681930933dbb31619bb9893d7632a.png

我猜目录名字占了第一个inode-index.

2900af71e84f270d838bdf1ee7013386.png

inode-index和inodetable单独开辟了一个block

7198e33811f69004d411f2491b61b8cd.png

目录是特殊的文件,目录内容包含: 文件名+inode号, 当目录被创建后,文件系统会给这个目录分配1个inode+特殊文件(即以目录为名). inode指向一个block. 所有你才会看到目录大小为4k.

这就能理解目录里的文件,文件名字保存在了所在目录的block里.

查看和修改ext4的inode和block

ext4 默认inode大小是256bytes, block大小是4096bytes

[root@moban ~]# dumpe2fs /dev/sdb |grep "Inode size"

Inode size: 256

[root@moban ~]# dumpe2fs /dev/sdb |grep "Block size"

Block size: 4096

- 格式化时候指定inode和block大小

[root@moban ~]# mkfs.ext4 -I 2048 -b 2048 /dev/sdb

查看目录的inode内容

71666505af7f550b345f30ea9f4001d5.png

471c212f6aa1ae35f3606e7e749a8b52.png

什么是FHS,Linux的文件系统目录标准是怎样的

Filesystem Hierarchy Standard(文件系统目录标准)的缩写,多数Linux版本采用这种文件组织形式,类似于Windows操作系统中c盘的文件目录,FHS采用树形结构组织文件. ...

Linux入门——文件系统目录结构

不同操作系统对于文件系统的组织是不一样的,当前主流的两大类操作系统windows和Linux它们在文件系统组织方式上有很大差别.windows的文件系统是以驱动器盘符为基础,这样文件是挂载在分区上的, ...

Linux 根文件系统目录结构

/:根目录 /bin:linux的常用命令 /sbin:linux的常用命令 /lib:库文件(so.elf) /etc:系统配置文件和脚本文件 /sys:驱动相关的信息 /dev:设备节点目录 /p ...

Linux文件系统和管理-1文件系统目录

文件系统目录结构 Linux常见目录及用途 bin binary 放的是二进制程序 /usr/bin 和这是同一回事 bin -> usr/bin /bin是 /usr/bin的快捷方式 boo ...

Linux文件系统目录

Linux操作系统目录呈树形结构,文件系统只有一个根目录,其余文件都是从根目录下延伸出来的 上图是一个Linux文件系统目录的展现,现在我们来看一下文件系统目录下相关目录及其功能 根目录( / ) L ...

linux普通文件权限和系统目录权限的实践及结论

测试结论:linux普通文件的读.写.执行权限说明 1.可读r:表示具有读取\阅读文件内容的权限 2.可写w:表示具有新增.修改文件内容的权限 1)如果没有r配合,那么vi编辑文件会提示无法编辑(但可 ...

linux 下文件误删恢复

linux 下文件误删恢复 0x01 事件背景 某天晚上写代码的时候,本来想删除当前目录下一个叫xxx的文件夹 rm -rdf ./xxx/*, 结果光顾着和人说话,一不留神手贱把命令敲成了rm -r ...

linux中文件的三种time(atime,mtime,ctime)

linux下文件有3个时间的,分别是atime,mtime,ctime.有些博友对这3个时间还是比较迷茫和困惑的,我整理了下,写下来希望对博友们有所帮助. 1 这三个time的含义 简名 全名 中文名 ...

linux各文件夹含义和作用

原文链接:https://blog.csdn.net/okyoung188/article/details/76315774 1.linux下各文件夹的意义:     /bin:是binary的缩写, ...

随机推荐

09---Net基础加强

复习 Person类: using System; using System.Collections.Generic; using System.Linq; using System.Text; us ...

FZU 2105 Digits Count(位数计算)

Description 题目描述 Given N integers A={A[0],A[1],...,A[N-1]}. Here we have some operations: Operation ...

TextBox(只允许输入字母或者数字)

实现如下: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System ...

SQLite数据库查看工具(免费)

1. SQLite Administrator http://sqliteadmin.orbmu2k.de/ iteSpy 2.  SQLiteSpy   http://www.yunqa.de/de ...

UIButton设置标题左对齐

Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//左对齐(UIControlContentHo ...

jquery-Ajax请求用例码

$.ajax({                    type:"post",                    url: 'domain’,                 ...

ruby 知识点随笔

print .puts 和 p 方法的区别."" 与 ''  的区别. 处理控制台编码问题 >ruby -E utf-8 脚本文件名称 # 执行脚本 >irb -E u ...

【BZOJ4671】异或图(斯特林反演)

[BZOJ4671]异或图(斯特林反演) 题面 BZOJ Description 定义两个结点数相同的图 G1 与图 G2 的异或为一个新的图 G, 其中如果 (u, v) 在 G1 与 G2 中的出 ...

软件设计基础-C/S系统

在软件设计开发过程中,逐渐形成了一些针对特定应用领域的软件系统组织方式的惯用模式 如经典的C/S(client/server,客户/服务器)模式和B/S(browser/server,浏览器/服务器) ...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值