mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-21 13:33:45 +00:00
Update Linux.md
重新绘制磁盘与文件系统的配图,补充 NVMe 和线上问题排查常用的命令。
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="270" viewBox="0 0 760 270">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">ext2/ext4 文件系统:分区被分成多个块组</text>
|
||||
<rect x="30" y="70" width="70" height="40" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="65" y="94" class="c sub" style="fill:#444">启动块</text>
|
||||
<rect x="100" y="70" width="200" height="40" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="200" y="94" class="c sub b" style="fill:#444">块组 0</text>
|
||||
<rect x="300" y="70" width="200" height="40" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="400" y="94" class="c sub b" style="fill:#444">块组 1</text>
|
||||
<rect x="500" y="70" width="200" height="40" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="600" y="94" class="c sub b" style="fill:#444">块组 2</text>
|
||||
<rect x="700" y="70" width="60" height="40" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="730" y="94" class="c sub" style="fill:#444">…</text>
|
||||
<path d="M100,112 L30,150" class="line dash"/>
|
||||
<path d="M300,112 L730,150" class="line dash"/>
|
||||
<rect x="30" y="150" width="100" height="40" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="80" y="174" class="c sub" style="fill:#444">superblock</text>
|
||||
<rect x="130" y="150" width="90" height="40" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="175" y="174" class="c sub" style="fill:#444">块组描述符</text>
|
||||
<rect x="220" y="150" width="100" height="40" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="270" y="174" class="c sub" style="fill:#444">block bitmap</text>
|
||||
<rect x="320" y="150" width="100" height="40" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="370" y="174" class="c sub" style="fill:#444">inode bitmap</text>
|
||||
<rect x="420" y="150" width="120" height="40" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="480" y="174" class="c sub" style="fill:#444">inode table</text>
|
||||
<rect x="540" y="150" width="190" height="40" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="635" y="174" class="c sub" style="fill:#444">data blocks</text>
|
||||
<text x="30" y="214" class="sub">superblock 记录 inode 和 block 的总数与剩余数(多个块组中有备份);两个 bitmap 用 1 位表示一个 block 或 inode 是否已被使用;</text>
|
||||
<text x="30" y="232" class="sub">inode table 存放 inode,data blocks 存放文件内容。找空闲块时只需要扫描 bitmap。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,54 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="220" viewBox="0 0 760 220">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">GPT 分区表的布局(LBA 为 512 字节)</text>
|
||||
<rect x="30" y="70" width="80" height="44" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="70" y="96" class="c sub" style="fill:#444">保护性 MBR</text>
|
||||
<text x="70" y="62" class="c sub mono">LBA 0</text>
|
||||
<rect x="110" y="70" width="80" height="44" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="150" y="96" class="c sub" style="fill:#444">GPT 表头</text>
|
||||
<text x="150" y="62" class="c sub mono">LBA 1</text>
|
||||
<rect x="190" y="70" width="130" height="44" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="255" y="96" class="c sub" style="fill:#444">分区项 × 128</text>
|
||||
<text x="255" y="62" class="c sub mono">LBA 2~33</text>
|
||||
<rect x="320" y="70" width="220" height="44" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="430" y="96" class="c sub" style="fill:#444">各个分区</text>
|
||||
<text x="430" y="62" class="c sub mono"></text>
|
||||
<rect x="540" y="70" width="100" height="44" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="590" y="96" class="c sub" style="fill:#444">分区项备份</text>
|
||||
<text x="590" y="62" class="c sub mono"></text>
|
||||
<rect x="640" y="70" width="80" height="44" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="680" y="96" class="c sub" style="fill:#444">表头备份</text>
|
||||
<text x="680" y="62" class="c sub mono">最后</text>
|
||||
<text x="30" y="150" class="sub">每个分区项 128 字节,一个 LBA 放 4 个,32 个 LBA 共 128 个分区;表头带 CRC32 校验,损坏时用末尾的备份恢复。</text>
|
||||
<text x="30" y="168" class="sub">LBA 是 64 位的,按 512 字节计算最大支持 2⁶⁴ × 512 字节 = 8 ZiB;MBR 只有 32 位,最大 2 TiB。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,75 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="340" viewBox="0 0 760 340">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">inode 中的 block 指针(block 大小为 1 KB)</text>
|
||||
<rect x="30" y="50" width="160" height="250" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
|
||||
<text x="110" y="70" class="c b" style="fill:#444">inode</text>
|
||||
<rect x="44" y="82" width="132" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="110" y="100" class="c sub" style="fill:#444">权限、拥有者</text>
|
||||
<rect x="44" y="116" width="132" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="110" y="134" class="c sub" style="fill:#444">大小、时间</text>
|
||||
<rect x="44" y="150" width="132" height="28" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="110" y="168" class="c sub" style="fill:#444">直接指针 × 12</text>
|
||||
<rect x="44" y="184" width="132" height="28" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="110" y="202" class="c sub" style="fill:#444">一级间接</text>
|
||||
<rect x="44" y="218" width="132" height="28" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="110" y="236" class="c sub" style="fill:#444">二级间接</text>
|
||||
<rect x="44" y="252" width="132" height="28" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="110" y="270" class="c sub" style="fill:#444">三级间接</text>
|
||||
<line x1="178" y1="164" x2="300" y2="92" class="arrow "/>
|
||||
<text x="330" y="80" class="sub" style="fill:#444">12 个数据块:12 KB</text>
|
||||
<rect x="300" y="88" width="20" height="14" rx="2" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<rect x="324" y="88" width="20" height="14" rx="2" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<rect x="348" y="88" width="20" height="14" rx="2" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<rect x="372" y="88" width="20" height="14" rx="2" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="178" y1="198" x2="300" y2="150" class="arrow "/>
|
||||
<rect x="300" y="140" width="70" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="335" y="156" class="c sub" style="fill:#444">256 个指针</text>
|
||||
<line x1="372" y1="152" x2="410" y2="152" class="arrow "/>
|
||||
<text x="420" y="156" class="sub" style="fill:#444">256 个数据块:256 KB</text>
|
||||
<line x1="178" y1="232" x2="300" y2="206" class="arrow "/>
|
||||
<rect x="300" y="196" width="70" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="335" y="212" class="c sub" style="fill:#444">256</text>
|
||||
<line x1="372" y1="208" x2="398" y2="208" class="arrow "/>
|
||||
<rect x="400" y="196" width="70" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="435" y="212" class="c sub" style="fill:#444">256 × 256</text>
|
||||
<text x="480" y="212" class="sub" style="fill:#444">65536 个数据块:64 MB</text>
|
||||
<line x1="178" y1="266" x2="300" y2="262" class="arrow "/>
|
||||
<rect x="300" y="252" width="50" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="325" y="268" class="c sub" style="fill:#444">256</text>
|
||||
<rect x="360" y="252" width="50" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="385" y="268" class="c sub" style="fill:#444">256²</text>
|
||||
<rect x="420" y="252" width="50" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="445" y="268" class="c sub" style="fill:#444">256³</text>
|
||||
<text x="480" y="268" class="sub" style="fill:#444">16777216 个数据块:16 GB</text>
|
||||
<text x="30" y="324" class="sub">一个 1 KB 的块能存 1024 / 4 = 256 个块号,合计 12 + 256 + 256² + 256³ = 16843020 个块,约 16 GB,与 ext2 的最大文件一致。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
@@ -0,0 +1,53 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">MBR 与多重引导</text>
|
||||
<rect x="30" y="90" width="120" height="46" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="90" y="117" class="c sub b" style="fill:#444">第 1 个扇区</text>
|
||||
<rect x="150" y="90" width="230" height="46" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="265" y="117" class="c sub" style="fill:#444">分区 1:Windows</text>
|
||||
<rect x="380" y="90" width="340" height="46" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="550" y="117" class="c sub" style="fill:#444">分区 2:Linux</text>
|
||||
<text x="90" y="56" class="c sub">446 字节开机管理程序</text>
|
||||
<text x="90" y="72" class="c sub">+ 64 字节分区表</text>
|
||||
<rect x="380" y="136" width="90" height="24" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="425" y="152" class="c sub" style="fill:#444">启动扇区</text>
|
||||
<rect x="30" y="190" width="180" height="56" rx="6" fill="#FFFFFF" stroke="#BBBBBB"/>
|
||||
<text x="120" y="210" class="c sub b" style="fill:#444">开机菜单</text>
|
||||
<text x="120" y="228" class="c sub">M1:Windows M2:转交</text>
|
||||
<line x1="90" y1="138" x2="90" y2="188" class="arrow "/>
|
||||
<path d="M150,218 C200,200 230,150 260,138" class="arrow"/>
|
||||
<text x="240" y="182" class="sub">M1 直接加载</text>
|
||||
<path d="M212,230 C330,240 410,200 425,172" class="arrow"/>
|
||||
<text x="330" y="254" class="c sub">M2 转交给 Linux 分区启动扇区中的 GRUB</text>
|
||||
<text x="30" y="286" class="sub">BIOS 读取第 1 个扇区并执行其中的开机管理程序;先装 Windows 再装 Linux,因为安装 Windows 会覆盖 MBR 中的开机管理程序。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
Reference in New Issue
Block a user