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: 軟鏈接
我猜目錄名字占了第一個inode-index.
inode-index和inodetable單獨開辟了一個block
目錄是特殊的文件,目錄內容包含: 文件名+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內容
什么是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,瀏覽器/服務器) ...
總結
以上是生活随笔為你收集整理的linux 往文件写4k大小,[svc]为何linux ext4文件系统目录默认大小是4k?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网站怎么搬家到快云vps里面去啊(快云科
- 下一篇: linux sed 空间模式,整理:SE