{"id":1832,"date":"2026-11-23T19:29:38","date_gmt":"2026-11-24T03:29:38","guid":{"rendered":"https:\/\/nanzhou.cc\/index.php\/2026\/11\/23\/linux-esp-boot-efi-initrd-initramfs-cpio-overlay-netboot\/"},"modified":"2026-11-23T19:44:10","modified_gmt":"2026-11-24T03:44:10","slug":"linux-boot-efi-systemd-boot-initrd-initramfs-cpio","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2026\/11\/23\/linux-boot-efi-systemd-boot-initrd-initramfs-cpio\/","title":{"rendered":"Inside \/boot\/efi &#038; initramfs: Standard ESP File Layout, systemd-boot BLS, initrd vs. initramfs &#038; CPIO"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/nanzhou.cc\/index.php\/2026\/11\/22\/linux-nvme-gpt-filesystems-mount-uefi-boot\/\">From Bare NVMe to Login Prompt<\/a>, we walked through how a blank NVMe SSD is partitioned with <code>GPT<\/code>, formatted into <code>vfat<\/code> and <code>ext4<\/code>, attached to the directory tree via <code>mount<\/code>, and booted into <code>systemd<\/code>. Now let&#8217;s zoom into the standard Linux UEFI boot partition and early-boot memory filesystem to answer three classic questions: <strong>What exact files sit inside <code>\/boot\/efi<\/code> on a standard <code>systemd-boot<\/code> system? What do <code>initrd<\/code> and <code>initramfs<\/code> actually do\u2014and why are their names used interchangeably? And what is the <code>CPIO<\/code> format inside an <code>initramfs<\/code> image?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4e0a\u4e00\u7bc7 <a href=\"https:\/\/nanzhou.cc\/index.php\/2026\/11\/22\/linux-nvme-gpt-filesystems-mount-uefi-boot\/\">From Bare NVMe to Login Prompt<\/a> \u4e2d\uff0c\u6211\u4eec\u68b3\u7406\u4e86\u7a7a\u767d NVMe \u4ece\u5207 <code>GPT<\/code> <code>partition<\/code>\u3001<code>format<\/code>\u3001<code>mount<\/code> \u5230 UEFI \u5f00\u673a\u8fdb\u5165 <code>systemd<\/code> \u7684\u6574\u4f53\u8109\u7edc\u3002\u8fd9\u4e00\u7bc7\u6211\u4eec\u4e13\u95e8\u62c6\u89e3\u6807\u51c6 Linux \u7684 UEFI \u542f\u52a8\u5206\u533a\u4e0e\u65e9\u671f\u5185\u5b58\u6587\u4ef6\u7cfb\u7edf\uff0c\u628a\u4e09\u4e2a\u6700\u5e38\u88ab\u95ee\u5230\u5e95\u5c42\u7ec6\u8282\u8bb2\u900f\uff1a<strong>\u6807\u51c6 <code>systemd-boot<\/code> \u673a\u5668\u7684 <code>\/boot\/efi<\/code> \u76ee\u5f55\u4e0b\u5230\u5e95\u653e\u4e86\u54ea\u51e0\u4e2a\u6587\u4ef6\uff1f\u7ecf\u5e38\u6df7\u7740\u53eb\u7684 <code>initrd<\/code> \u548c <code>initramfs<\/code> \u5230\u5e95\u662f\u5e72\u4ec0\u4e48\u7528\u7684\u3001\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u91cc\u9762\u7684 <code>CPIO<\/code> \u5f52\u6863\u53c8\u662f\u4ec0\u4e48\u7ed3\u6784\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. Complete File Anatomy of \/boot\/efi Under Standard systemd-boot (\/boot\/efi \u6807\u51c6\u76ee\u5f55\u4e0e\u6587\u4ef6\u5168\u62c6\u89e3)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Under the UEFI Specification, motherboard firmware reads bootloaders from an <strong>EFI System Partition (<code>ESP<\/code>)<\/strong>\u2014a small <code>GPT<\/code> partition tagged with Type GUID <code>C12A7328-F81F-11D2-BA4B-00A0C93EC93B<\/code> and formatted as <code>FAT32<\/code> (<code>vfat<\/code>). Inside a running Linux OS, this partition is typically mounted at <strong><code>\/boot\/efi<\/code><\/strong>; to power-on UEFI firmware, however, this partition&#8217;s root directory is simply <strong><code>\/<\/code><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167 UEFI \u6807\u51c6\u89c4\u8303\uff0c\u4e3b\u677f\u56fa\u4ef6\u4ece <strong>EFI System Partition\uff08<code>ESP<\/code>\uff09<\/strong> \u8bfb\u53d6\u5f15\u5bfc\u7a0b\u5e8f\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u6253\u6709\u4e13\u7528\u7c7b\u578b GUID\uff08<code>C12A7328-F81F-11D2-BA4B-00A0C93EC93B<\/code>\uff09\u5e76 <code>format<\/code> \u4e3a <code>FAT32<\/code>\uff08<code>vfat<\/code>\uff09\u7684\u5c0f\u5206\u533a\u3002\u8fdb\u5165 Linux \u7cfb\u7edf\u540e\uff0c\u6211\u4eec\u901a\u5e38\u628a\u5b83 <code>mount<\/code> \u5728 <strong><code>\/boot\/efi<\/code><\/strong>\uff1b\u800c\u5728\u521a\u4e0a\u7535\u7684 UEFI \u56fa\u4ef6\u773c\u91cc\uff0c\u8fd9\u4e2a\u5206\u533a\u7684\u6839\u76ee\u5f55\u672c\u8eab\u5c31\u662f <strong><code>\/<\/code><\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a standard Linux installation using <strong><code>systemd-boot<\/code><\/strong> and the upstream <strong>Boot Loader Specification (<code>BLS<\/code> Type #1)<\/strong>, the entire <code>\/boot\/efi<\/code> partition needs only <strong>6 files<\/strong>. Click any file in the interactive tree below to see who reads it, what goes inside, and why it is needed:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4f7f\u7528\u6807\u51c6 <strong><code>systemd-boot<\/code><\/strong> \u4e0e\u4e0a\u6e38 <strong>Boot Loader Specification\uff08<code>BLS<\/code> Type #1\uff09<\/strong> \u89c4\u8303\u7684 Linux \u7cfb\u7edf\u4e0a\uff0c\u6574\u4e2a <code>\/boot\/efi<\/code> \u5206\u533a\u6838\u5fc3\u53ea\u6709 <strong>6 \u4e2a\u6587\u4ef6<\/strong>\u3002\u70b9\u51fb\u4e0b\u65b9\u4ea4\u4e92\u5f0f\u76ee\u5f55\u6811\u4e2d\u7684\u4efb\u610f\u6587\u4ef6\uff0c\u5373\u53ef\u67e5\u770b\u5b83\u7684\u8bfb\u53d6\u65b9\u3001\u771f\u5b9e\u5185\u5bb9\u4e0e\u5177\u4f53\u804c\u8d23\uff1a<\/p>\n\n\n\n<div class=\"nz-esp-widget\" id=\"nz-esp-widget\">\n<style>\n#nz-esp-widget { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; padding: 16px; margin: 22px 0; color: #0f172a; box-sizing: border-box; user-select: none; -webkit-user-select: none; }\n#nz-esp-widget * { box-sizing: border-box; }\n#nz-esp-widget .nze-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; margin-bottom: 12px; font-size: 12.5px; color: #64748b; }\n#nz-esp-widget .nze-layout { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(300px, 1.45fr); gap: 12px; }\n@media (max-width: 720px) { #nz-esp-widget .nze-layout { grid-template-columns: 1fr; } }\n#nz-esp-widget .nze-tree { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }\n#nz-esp-widget .nze-dir { color: #64748b; padding: 3px 6px; font-weight: 600; }\n#nz-esp-widget .nze-file { cursor: pointer; padding: 5px 8px; border-radius: 6px; border: 1px solid transparent; margin: 2px 0; color: #0f172a; display: flex; justify-content: space-between; align-items: center; transition: all 0.12s ease; }\n#nz-esp-widget .nze-file:hover { background: #f1f5f9; border-color: #cbd5e1; }\n#nz-esp-widget .nze-file.active { background: #eff6ff; border-color: #2563eb; color: #1d4ed8; font-weight: 700; }\n#nz-esp-widget .nze-tag { font-size: 10.5px; color: #64748b; font-weight: 400; }\n#nz-esp-widget .nze-detail { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; font-size: 13.5px; line-height: 1.65; user-select: text; -webkit-user-select: text; }\n#nz-esp-widget .nze-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.8px; background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 9px 11px; margin: 8px 0; overflow-x: auto; white-space: pre; line-height: 1.5; }\n<\/style>\n<div class=\"nze-head\">\n  <span><strong>Standard \/boot\/efi File Explorer<\/strong> \u00b7 Click any file (\u70b9\u51fb\u6587\u4ef6\u67e5\u770b\u8be6\u60c5)<\/span>\n  <span style=\"font-family:ui-monospace,monospace;\">FAT32 ESP = &#8220;\/&#8221; in UEFI<\/span>\n<\/div>\n<div class=\"nze-layout\">\n  <div class=\"nze-tree\">\n    <div class=\"nze-dir\">\/boot\/efi\/ (FAT32 ESP Root)<\/div>\n    <div class=\"nze-dir\">\u251c\u2500\u2500 EFI\/BOOT\/<\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-0\" onclick=\"window.nzSelectEspFile(0)\"><span>&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500\u2500 BOOTAA64.EFI<\/span><span class=\"nze-tag\">[1]<\/span><\/div>\n    <div class=\"nze-dir\">\u251c\u2500\u2500 EFI\/systemd\/<\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-1\" onclick=\"window.nzSelectEspFile(1)\"><span>&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500\u2500 systemd-bootaa64.efi<\/span><span class=\"nze-tag\">[2]<\/span><\/div>\n    <div class=\"nze-dir\">\u251c\u2500\u2500 loader\/<\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-2\" onclick=\"window.nzSelectEspFile(2)\"><span>&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500\u2500 loader.conf<\/span><span class=\"nze-tag\">[3]<\/span><\/div>\n    <div class=\"nze-dir\">&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500\u2500 entries\/<\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-3\" onclick=\"window.nzSelectEspFile(3)\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500\u2500 linux-6.12.conf<\/span><span class=\"nze-tag\">[4]<\/span><\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-4\" onclick=\"window.nzSelectEspFile(4)\"><span>\u251c\u2500\u2500 vmlinuz-6.12.0<\/span><span class=\"nze-tag\">[5]<\/span><\/div>\n    <div role=\"button\" tabindex=\"0\" class=\"nze-file\" id=\"nzef-5\" onclick=\"window.nzSelectEspFile(5)\"><span>\u2514\u2500\u2500 initramfs-6.12.0.img<\/span><span class=\"nze-tag\">[6]<\/span><\/div>\n  <\/div>\n  <div class=\"nze-detail\" id=\"nze-file-detail\"><\/div>\n<\/div>\n<script>\n(function(){\n  var files = [\n    {\n      path: \"\/EFI\/BOOT\/BOOTAA64.EFI\", reader: \"Read by: UEFI Firmware (EDK2 \/ U-Boot)\",\n      code: \"# Standard UEFI default \/ removable-media boot path\\n# ARM64:  \/EFI\/BOOT\/BOOTAA64.EFI\\n# x86_64: \/EFI\/BOOT\/BOOTX64.EFI\",\n      en: \"Mandated by UEFI Spec Section 3.5.1.1. When a disk is freshly imaged or motherboard NVRAM has no explicit BootOrder entry yet, UEFI firmware scans the FAT32 ESP for this exact path and executes it. 'bootctl install' places a copy of systemd-boot right here.\",\n      zh: \"UEFI \u89c4\u8303 3.5.1.1 \u8282\u94a6\u5b9a\u7684\u9ed8\u8ba4\u515c\u5e95\u542f\u52a8\u8def\u5f84\uff08ARM64 \u4e3a BOOTAA64.EFI\uff0cx86_64 \u4e3a BOOTX64.EFI\uff09\u3002\u5f53\u65b0\u88c5\u597d\u7684\u786c\u76d8\u5c1a\u672a\u5728\u4e3b\u677f NVRAM \u4e2d\u5199\u5165 BootOrder \u542f\u52a8\u9879\u65f6\uff0c\u56fa\u4ef6\u626b\u5230 ESP \u540e\u4f1a\u81ea\u52a8\u5bfb\u627e\u5e76\u8fd0\u884c\u5b83\uff1bbootctl install \u9ed8\u8ba4\u5c31\u4f1a\u628a systemd-boot \u62f7\u4e00\u4efd\u5230\u8fd9\u91cc\u3002\"\n    },\n    {\n      path: \"\/EFI\/systemd\/systemd-bootaa64.efi\", reader: \"Read by: UEFI BootOrder \/ bootctl\",\n      code: \"# Vendor bootloader binary (~100 KB PE\/COFF EFI executable)\\n# Installed & updated by: bootctl install \/ bootctl update\",\n      en: \"The canonical vendor directory for systemd-boot on the ESP. When NVRAM variables are writable, 'bootctl install' registers an explicit UEFI boot entry pointing to \/EFI\/systemd\/systemd-bootaa64.efi while keeping BOOTAA64.EFI in sync as a fallback.\",\n      zh: \"systemd-boot \u5728 ESP \u4e0a\u7684\u6807\u51c6\u5382\u5546\u5b89\u88c5\u8def\u5f84\u3002\u5982\u679c\u4e3b\u677f\u652f\u6301\u6301\u4e45\u5316 NVRAM \u53d8\u91cf\uff0cbootctl install \u4f1a\u6ce8\u518c\u6307\u5411\u8fd9\u91cc\u7684 UEFI \u542f\u52a8\u9879\uff0c\u540c\u65f6\u4fdd\u6301\u5b83\u4e0e BOOTAA64.EFI \u540c\u6b65\u66f4\u65b0\u3002\"\n    },\n    {\n      path: \"\/loader\/loader.conf\", reader: \"Read by: systemd-boot\",\n      code: \"default linux-*.conf\\ntimeout 3\\nconsole-mode max\",\n      en: \"Global configuration file for systemd-boot. Controls which entry pattern boots by default ('default'), how many seconds to show the boot menu ('timeout 0' boots immediately with zero pause), and console display mode.\",\n      zh: \"systemd-boot \u7684\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\uff1a\u6307\u5b9a\u9ed8\u8ba4\u5339\u914d\u54ea\u4e2a\u542f\u52a8\u9879\uff08default\uff09\u3001\u83dc\u5355\u7b49\u5f85\u79d2\u6570\uff08\u8bbe\u4e3a timeout 0 \u5219\u96f6\u7b49\u5f85\u76f4\u63a5\u5f15\u5bfc\uff09\uff0c\u4ee5\u53ca\u4e32\u53e3\/\u5c4f\u5e55\u663e\u793a\u6a21\u5f0f\u3002\"\n    },\n    {\n      path: \"\/loader\/entries\/linux-6.12.conf\", reader: \"Read by: systemd-boot (BLS Type #1)\",\n      code: \"title   Linux 6.12.0\\nversion 6.12.0\\nlinux   \/vmlinuz-6.12.0\\ninitrd  \/initramfs-6.12.0.img\\noptions root=UUID=4f8a-9c12 rw quiet console=ttyAMA0,115200n8\",\n      en: \"Standard UAPI Boot Loader Specification (BLS) Type #1 drop-in file\u2014one plain-text '.conf' file per installed kernel version. Every path ('\/vmlinuz-...', '\/initramfs-...') is relative to the FAT32 ESP root, making A\/B kernel upgrades and rollbacks trivial.\",\n      zh: \"\u7b26\u5408\u4e0a\u6e38 UAPI Boot Loader Specification (BLS Type #1) \u6807\u51c6\u7684\u542f\u52a8\u9879\u914d\u7f6e\u2014\u2014\u6bcf\u4e2a\u5185\u6838\u7248\u672c\u5bf9\u5e94\u4e00\u4e2a\u7eaf\u6587\u672c .conf \u6587\u4ef6\u3002\u6ce8\u610f\u91cc\u9762\u7684 \/vmlinuz-... \u548c \/initramfs-... \u8def\u5f84\u90fd\u662f\u76f8\u5bf9\u4e8e FAT32 ESP \u6839\u76ee\u5f55\u7684\u3002\"\n    },\n    {\n      path: \"\/vmlinuz-6.12.0\", reader: \"Loaded by: systemd-boot via CONFIG_EFI_STUB\",\n      code: \"$ file \/boot\/efi\/vmlinuz-6.12.0\\nLinux kernel ARM64 boot executable Image, PE32+ executable (EFI application)\",\n      en: \"The compressed Linux kernel image. Because systemd-boot intentionally contains zero filesystem drivers of its own and relies strictly on UEFI firmware's FAT32 driver, vmlinuz must reside on the FAT32 ESP (not solely inside ext4). Compiled with CONFIG_EFI_STUB=y, the kernel has a valid PE\/COFF header and can be executed directly by UEFI.\",\n      zh: \"\u538b\u7f29\u7684 Linux \u5185\u6838\u955c\u50cf\u3002\u56e0\u4e3a systemd-boot \u523b\u610f\u4e0d\u5185\u7f6e\u4efb\u4f55\u590d\u6742\u6587\u4ef6\u7cfb\u7edf\u9a71\u52a8\uff0c\u5b8c\u5168\u590d\u7528 UEFI \u56fa\u4ef6\u81ea\u5e26\u7684 FAT32 \u8bfb\u53d6\u80fd\u529b\uff08\u8bfb\u4e0d\u4e86 ext4 \u6839\u5206\u533a\uff09\uff0c\u6240\u4ee5\u5185\u6838\u5fc5\u987b\u653e\u5728 ESP \u5206\u533a\u4e0a\u3002\u5f00\u542f CONFIG_EFI_STUB=y \u540e\uff0c\u5185\u6838\u81ea\u5e26 PE\/COFF \u5934\uff0c\u53ef\u76f4\u63a5\u4f5c\u4e3a EFI \u7a0b\u5e8f\u88ab\u56fa\u4ef6\u8c03\u7528\u542f\u52a8\u3002\"\n    },\n    {\n      path: \"\/initramfs-6.12.0.img\", reader: \"Loaded by: systemd-boot -> Unpacked by Kernel\",\n      code: \"$ lsinitramfs \/boot\/efi\/initramfs-6.12.0.img | head -n 5\\ninit\\nbin\/sh\\nusr\/lib\/modules\/6.12.0\/kernel\/drivers\/nvme\/host\/nvme.ko\\nsbin\/switch_root\",\n      en: \"The compressed CPIO archive containing the initial RAM filesystem (early user-space \/init, storage\/crypto drivers, and udev\/fsck helpers). systemd-boot loads it from the FAT32 ESP into memory and hands its address to the kernel via the UEFI LoadFile2 initrd protocol.\",\n      zh: \"\u6253\u5305\u4e86\u65e9\u671f\u5185\u5b58\u6839\u6587\u4ef6\u7cfb\u7edf\u7684\u538b\u7f29 CPIO \u5f52\u6863\uff08\u542b \/init \u5165\u53e3\u3001NVMe\/\u52a0\u5bc6\u7b49\u78c1\u76d8\u9a71\u52a8\u6a21\u5757\u53ca switch_root \u5de5\u5177\uff09\u3002systemd-boot \u4ece FAT32 ESP \u628a\u5b83\u8bfb\u5165\u5185\u5b58\uff0c\u518d\u901a\u8fc7\u6807\u51c6 UEFI LoadFile2 \u534f\u8bae\u628a\u5185\u5b58\u5730\u5740\u4ea4\u7ed9\u5185\u6838\u89e3\u538b\u3002\"\n    }\n  ];\n  window.nzSelectEspFile = function(idx) {\n    for (var i = 0; i < files.length; i++) {\n      var el = document.getElementById(\"nzef-\" + i);\n      if (el) el.className = \"nze-file\" + (i === idx ? \" active\" : \"\");\n    }\n    var f = files[idx];\n    document.getElementById(\"nze-file-detail\").innerHTML =\n      '<div style=\"display:flex;justify-content:space-between;flex-wrap:wrap;gap:6px;margin-bottom:6px;\"><span style=\"font-family:ui-monospace,monospace;font-weight:700;font-size:14px;\">' + f.path + '<\/span><span style=\"font-size:11.5px;background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe;border-radius:999px;padding:2px 8px;font-family:ui-monospace,monospace;\">' + f.reader + '<\/span><\/div>' +\n      '<div class=\"nze-code\">' + f.code + '<\/div>' +\n      '<p style=\"margin:0 0 8px 0;color:#1e293b;\">' + f.en + '<\/p>' +\n      '<p style=\"margin:0;padding-top:8px;border-top:1px dashed #e2e8f0;color:#475569;\">' + f.zh + '<\/p>';\n  };\n  window.nzSelectEspFile(3);\n})();\n<\/script>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. initrd vs. initramfs: What Are They For &amp; How Do They Differ? (initrd \u4e0e initramfs \u7684\u7528\u9014\u4e0e\u533a\u522b)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 Why Does Linux Need an Early Memory Rootfs at All?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If we kept every storage driver (<code>NVMe<\/code>, <code>SATA<\/code>, <code>SCSI<\/code>, <code>VirtIO<\/code>, <code>RAID<\/code>, <code>LVM<\/code>, <code>LUKS<\/code> encryption, <code>ext4<\/code>, <code>XFS<\/code>, <code>Btrfs<\/code>, network filesystems) statically compiled into <code>vmlinuz<\/code>, the kernel binary would become bloated and rigid\u2014and still couldn&#8217;t prompt for a LUKS passphrase or assemble complex multi-disk arrays that require user-space tools. Yet those modular <code>.ko<\/code> drivers and user-space tools live inside <code>\/lib\/modules<\/code> and <code>\/usr\/sbin<\/code> <strong>on the very root disk we haven&#8217;t mounted yet!<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u628a\u4e16\u4e0a\u6240\u6709\u5b58\u50a8\u63a7\u5236\u5668\u9a71\u52a8\uff08<code>NVMe<\/code>\u3001<code>SATA<\/code>\u3001<code>VirtIO<\/code>\u3001\u8f6f <code>RAID<\/code>\u3001<code>LVM<\/code>\uff09\u3001\u6587\u4ef6\u7cfb\u7edf\uff08<code>ext4<\/code>\u3001<code>XFS<\/code>\u3001<code>Btrfs<\/code>\uff09\u548c\u78c1\u76d8\u89e3\u5bc6\u903b\u8f91\u5168\u9759\u6001\u7f16\u6b7b\u8fdb <code>vmlinuz<\/code>\uff0c\u5185\u6838\u4f1a\u53d8\u5f97\u6781\u5176\u81c3\u80bf\uff0c\u800c\u4e14\u4f9d\u7136\u6ca1\u6cd5\u5b8c\u6210\u8f93\u5165 LUKS \u5bc6\u7801\u3001\u6267\u884c <code>fsck<\/code> \u4fee\u590d\u6216\u6309 <code>UUID<\/code> \u5f02\u6b65\u7ec4\u88c5\u590d\u6742\u5b58\u50a8\u6808\u7b49\u7528\u6237\u6001\u5de5\u4f5c\u3002\u7136\u800c\uff0c\u8fd9\u4e9b\u6a21\u5757\u5316 <code>.ko<\/code> \u9a71\u52a8\u548c\u5de5\u5177\u6070\u6070\u8eba\u5728<strong>\u8fd8\u6ca1\u6302\u8f7d\u4e0a\u7684\u6839\u5206\u533a <code>\/lib\/modules<\/code> \u91cc<\/strong>\u2014\u2014\u8fd9\u5c31\u662f\u7ecf\u5178\u7684\u542f\u52a8\u671f\u201c\u9e21\u751f\u86cb\u201d\u6b7b\u9501\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Linux solves this chicken-and-egg bootstrap problem by loading a tiny, self-contained <strong>temporary root filesystem into RAM<\/strong> alongside the kernel. Step through the 5 stages below to see how this temporary memory environment prepares the real disk and cleanly erases itself:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Linux \u7684\u6807\u51c6\u89e3\u6cd5\uff0c\u5c31\u662f\u7531 bootloader \u5728\u52a0\u8f7d\u5185\u6838\u7684\u540c\u65f6\uff0c\u987a\u624b\u628a\u4e00\u4e2a\u5305\u542b\u5fc5\u8981\u9a71\u52a8\u548c\u6302\u8f7d\u811a\u672c\u7684<strong>\u5fae\u578b\u4e34\u65f6\u6839\u6587\u4ef6\u7cfb\u7edf\u8bfb\u8fdb\u5185\u5b58<\/strong>\u3002\u70b9\u51fb\u4e0b\u65b9 5 \u4e2a\u6b65\u9aa4\uff0c\u67e5\u770b\u5b83\u4ece\u542f\u52a8\u3001\u6302\u76d8\u5230\u81ea\u6211\u9500\u6bc1\u8ba9\u4f4d\u7ed9\u771f\u6b63\u78c1\u76d8 <code>\/<\/code> \u7684\u5b8c\u6574\u751f\u547d\u5468\u671f\uff1a<\/p>\n\n\n\n<div class=\"nz-ir-widget\" id=\"nz-ir-widget\">\n<style>\n#nz-ir-widget { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; padding: 16px; margin: 22px 0; color: #0f172a; box-sizing: border-box; user-select: none; -webkit-user-select: none; }\n#nz-ir-widget * { box-sizing: border-box; }\n#nz-ir-widget .nzir-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; margin-bottom: 12px; font-size: 12.5px; color: #64748b; }\n#nz-ir-widget .nzir-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }\n@media (max-width: 740px) { #nz-ir-widget .nzir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }\n#nz-ir-widget .nzir-step { cursor: pointer; border: 1px solid #cbd5e1; background: #ffffff; border-radius: 7px; padding: 8px 9px; transition: all 0.15s ease; opacity: 0.72; }\n#nz-ir-widget .nzir-step:hover { border-color: #2563eb; opacity: 1; }\n#nz-ir-widget .nzir-step.active { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 2px rgba(37,99,235,0.22); opacity: 1; }\n#nz-ir-widget .nzir-num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 700; color: #2563eb; }\n#nz-ir-widget .nzir-t { font-size: 12.5px; font-weight: 700; color: #0f172a; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n#nz-ir-widget .nzir-sub { font-size: 11px; color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n#nz-ir-widget .nzir-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; font-size: 13.5px; line-height: 1.65; user-select: text; -webkit-user-select: text; }\n#nz-ir-widget .nzir-cmd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 8px 10px; margin: 8px 0; overflow-x: auto; white-space: pre; }\n<\/style>\n<div class=\"nzir-head\">\n  <span><strong>initramfs \u2192 switch_root Lifecycle<\/strong> \u00b7 Click any stage (\u70b9\u51fb\u9636\u6bb5\u67e5\u770b)<\/span>\n  <span style=\"font-family:ui-monospace,monospace;\">Early Userspace (RAM) \u2192 Real Disk &#8220;\/&#8221;<\/span>\n<\/div>\n<div class=\"nzir-grid\" id=\"nzir-steps\"><\/div>\n<div class=\"nzir-card\" id=\"nzir-detail\"><\/div>\n<script>\n(function(){\n  var stages = [\n    {\n      num: \"Phase 1\", t: \"UEFI Load\", sub: \"vmlinuz + initramfs\",\n      badge: \"World: UEFI Firmware\",\n      cmd: \"systemd-boot reads \/vmlinuz-6.12.0 + \/initramfs-6.12.0.img into RAM\",\n      en: \"systemd-boot parses \/loader\/entries\/linux-6.12.conf, reads both the kernel and the compressed initramfs archive from the FAT32 ESP into physical RAM, and jumps into the kernel's EFI stub.\",\n      zh: \"systemd-boot \u89e3\u6790\u542f\u52a8\u9879\u914d\u7f6e\uff0c\u5229\u7528\u56fa\u4ef6 FAT32 \u9a71\u52a8\u628a\u5185\u6838\u4e0e initramfs.img \u4e00\u5e76\u8bfb\u8fdb\u7269\u7406\u5185\u5b58\uff0c\u968f\u540e\u8df3\u8f6c\u5230\u5185\u6838 EFI \u5165\u53e3\u3002\"\n    },\n    {\n      num: \"Phase 2\", t: \"Unpack CPIO\", sub: \"Populate RAM rootfs\",\n      badge: \"World: Kernel Init\",\n      cmd: \"init\/initramfs.c: decompress zstd\/gzip -> unpack SVR4 'newc' CPIO into rootfs -> exec \/init\",\n      en: \"During kernel startup, Linux initializes an internal memory filesystem (rootfs \/ tmpfs), decompresses and extracts the CPIO archive into it, and spawns '\/init' as early PID 1.\",\n      zh: \"Kernel \u521d\u59cb\u5316\u5b8c\u57fa\u7840\u786c\u4ef6\u540e\uff0c\u628a\u5185\u5b58\u4e2d\u7684\u538b\u7f29 CPIO \u5f52\u6863\u76f4\u63a5\u89e3\u538b\u8fdb\u5185\u6838\u81ea\u5e26\u7684\u5185\u5b58\u76ee\u5f55\u6811\uff08rootfs\uff09\uff0c\u5e76\u5c06\u91cc\u9762\u7684 \/init \u4f5c\u4e3a\u65e9\u671f PID 1 \u542f\u52a8\u3002\"\n    },\n    {\n      num: \"Phase 3\", t: \"Drivers & udev\", sub: \"Find root block dev\",\n      badge: \"World: Early PID 1 (\/init)\",\n      cmd: \"mount -t proc proc \/proc\\nmount -t sysfs sysfs \/sys\\nmount -t devtmpfs devtmpfs \/dev\\nmodprobe nvme ext4   # wait for \/dev\/disk\/by-uuid\/... or \/dev\/nvme0n1p2\",\n      en: \"Running in RAM user-space, \/init mounts virtual filesystems (\/proc, \/sys, \/dev), loads storage\/encryption modules (nvme.ko, dm-crypt), parses 'root=...' from \/proc\/cmdline, and waits for the physical partition device node to appear.\",\n      zh: \"\u8dd1\u5728\u5185\u5b58\u91cc\u7684 \/init \u5148\u6302\u597d \/proc\u3001\/sys\u3001\/dev\uff0c\u6309\u9700\u52a0\u8f7d nvme\/ext4\/\u52a0\u5bc6\u7b49\u5185\u6838\u6a21\u5757\uff0c\u89e3\u6790 \/proc\/cmdline \u4e2d\u7684 root=... \u53c2\u6570\u5e76\u7b49\u5f85\u771f\u5b9e\u786c\u76d8\u5206\u533a\u8282\u70b9\u5c31\u7eea\u3002\"\n    },\n    {\n      num: \"Phase 4\", t: \"Mount \/sysroot\", sub: \"fsck + stage real \/\",\n      badge: \"World: Early PID 1 (\/init)\",\n      cmd: \"fsck.ext4 -p \/dev\/nvme0n1p2\\nmount -t ext4 -o ro \/dev\/nvme0n1p2 \/sysroot\",\n      en: \"Once the target block device appears, initramfs optionally checks filesystem health (fsck) and mounts the physical NVMe root partition at a temporary staging directory '\/sysroot'.\",\n      zh: \"\u76ee\u6807\u5757\u8bbe\u5907\u51fa\u73b0\u540e\uff0cinitramfs \u6309\u9700\u6267\u884c fsck \u68c0\u67e5\uff0c\u5e76\u628a\u771f\u6b63\u7684\u7269\u7406\u6839\u5206\u533a\uff08\u5982 nvme0n1p2\uff09\u5148\u6302\u8f7d\u5230\u5185\u5b58\u76ee\u5f55\u6811\u7684 \/sysroot \u4e0b\u3002\"\n    },\n    {\n      num: \"Phase 5\", t: \"switch_root\", sub: \"Free RAM & exec systemd\",\n      badge: \"World: Real Disk PID 1\",\n      cmd: \"exec switch_root \/sysroot \/sbin\/init   # -> \/lib\/systemd\/systemd takes over PID 1!\",\n      en: \"Unlike 'chroot' (which would leave the entire initramfs wasting unswappable RAM forever), 'switch_root' recursively deletes all files in the old initramfs to reclaim memory, pivots \/sysroot to '\/', and execs \/sbin\/init as the permanent PID 1. Disk systemd then reads \/etc\/fstab to mount \/data and \/boot\/efi.\",\n      zh: \"\u6ce8\u610f\u8fd9\u91cc\u4e0d\u80fd\u7528\u666e\u901a\u7684 chroot\uff08\u5426\u5219\u6574\u4e2a initramfs \u4f1a\u6c38\u4e45\u6b8b\u7559\u5728\u4e0d\u53ef\u4ea4\u6362\u7684\u5185\u5b58\u91cc\u767d\u5360\u7a7a\u95f4\uff09\uff1aswitch_root \u4f1a\u9012\u5f52\u6e05\u7a7a\u65e7\u5185\u5b58\u76d8\u91ca\u653e\u5185\u5b58\uff0c\u628a \/sysroot \u6276\u6b63\u4e3a\u771f\u6b63\u7684 \/\uff0c\u5e76\u901a\u8fc7 exec \u539f\u5730\u53d8\u8eab\u4e3a\u786c\u76d8\u4e0a\u7684 \/sbin\/init (systemd)\uff0c\u968f\u540e\u6309 \/etc\/fstab \u6302\u9f50\u5269\u4f59\u5206\u533a\u3002\"\n    }\n  ];\n  window.nzSelectIrStage = function(idx) {\n    var wrap = document.getElementById(\"nzir-steps\");\n    wrap.innerHTML = \"\";\n    for (var i = 0; i < stages.length; i++) {\n      var d = document.createElement(\"div\");\n      d.setAttribute(\"role\", \"button\");\n      d.setAttribute(\"tabindex\", \"0\");\n      d.className = \"nzir-step\" + (i === idx ? \" active\" : \"\");\n      d.setAttribute(\"onclick\", \"window.nzSelectIrStage(\" + i + \")\");\n      d.innerHTML = '<div class=\"nzir-num\">' + stages[i].num + '<\/div><div class=\"nzir-t\">' + stages[i].t + '<\/div><div class=\"nzir-sub\">' + stages[i].sub + '<\/div>';\n      wrap.appendChild(d);\n    }\n    var s = stages[idx];\n    document.getElementById(\"nzir-detail\").innerHTML =\n      '<div style=\"display:flex;justify-content:space-between;flex-wrap:wrap;gap:6px;margin-bottom:6px;\"><span style=\"font-weight:700;font-size:14px;\">' + s.num + ' \u00b7 ' + s.t + '<\/span><span style=\"font-size:11.5px;background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe;border-radius:999px;padding:2px 8px;font-family:ui-monospace,monospace;\">' + s.badge + '<\/span><\/div>' +\n      '<div class=\"nzir-cmd\">' + s.cmd + '<\/div>' +\n      '<p style=\"margin:0 0 8px 0;color:#1e293b;\">' + s.en + '<\/p>' +\n      '<p style=\"margin:0;padding-top:8px;border-top:1px dashed #e2e8f0;color:#475569;\">' + s.zh + '<\/p>';\n  };\n  window.nzSelectIrStage(4);\n})();\n<\/script>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 Why Are Both Names (&#8220;initrd&#8221; and &#8220;initramfs&#8221;) Still Used?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Beginners often wonder why documentation talks about building an <strong><code>initramfs<\/code><\/strong> while bootloader configs (<code>systemd-boot<\/code>, GRUB) still write <strong><code>initrd \/initramfs-6.12.0.img<\/code><\/strong>. They represent two generations of the same concept\u2014where the <strong>old name survived as the configuration interface<\/strong> while the <strong>new mechanism won under the hood<\/strong>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u540c\u5b66\u4f1a\u56f0\u60d1\uff1a\u4e3a\u4ec0\u4e48\u6559\u7a0b\u91cc\u90fd\u5728\u8bb2\u751f\u6210 <strong><code>initramfs<\/code><\/strong>\uff0c\u4f46\u6253\u5f00 <code>systemd-boot<\/code> \u6216 GRUB \u914d\u7f6e\u6587\u4ef6\u5199\u7684\u6307\u4ee4\u5374\u4f9d\u7136\u53eb <strong><code>initrd \/initramfs-6.12.0.img<\/code><\/strong>\uff1f\u5176\u5b9e\u5b83\u4eec\u662f\u540c\u4e00\u9700\u6c42\u7684\u4e24\u4ee3\u5b9e\u73b0\u2014\u2014<strong>\u8001\u4e00\u4ee3\u7684\u540d\u5b57\u4f5c\u4e3a\u914d\u7f6e\u63a5\u53e3\u4fdd\u7559\u4e86\u4e0b\u6765\uff0c\u800c\u5e95\u5c42\u7684\u8fd0\u884c\u673a\u5236\u65e9\u5df2\u5168\u9762\u6362\u6210\u4e86\u65b0\u4e00\u4ee3<\/strong>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Term<\/th><th>Full Name &amp; Era<\/th><th>Underlying Mechanism \/ \u5e95\u5c42\u5b9e\u73b0\u5dee\u5f02<\/th><th>Status Today \/ \u73b0\u72b6<\/th><\/tr><\/thead><tbody><tr><td><code>initrd<\/code><\/td><td><strong>Initial RAM Disk<\/strong><br>(Linux 2.4 legacy)<\/td><td>Simulated a fixed-size virtual block device (<code>\/dev\/ram0<\/code>) in RAM that had to be formatted with a real disk filesystem (<code>ext2<\/code>) and mounted\u2014duplicating data in both the fake block device and the page cache.<br>\u5728\u5185\u5b58\u4e2d\u786c\u6a21\u62df\u4e00\u5757\u56fa\u5b9a\u5927\u5c0f\u7684\u865a\u62df\u5757\u8bbe\u5907 <code>\/dev\/ram0<\/code>\uff0c\u91cc\u9762\u8fd8\u8981\u683c\u5f0f\u5316\u6210 <code>ext2<\/code> \u518d\u6302\u8f7d\uff0c\u9020\u6210\u53cc\u4efd\u7f13\u5b58\u6d6a\u8d39\u4e14\u5927\u5c0f\u6b7b\u677f\u3002<\/td><td><strong>Mechanism retired<\/strong>, but the keyword <code>initrd<\/code> remains the universal bootloader config directive &amp; UEFI handoff protocol name.<br><strong>\u5e95\u5c42\u5757\u8bbe\u5907\u673a\u5236\u5df2\u6dd8\u6c70<\/strong>\uff0c\u4f46 <code>initrd<\/code> \u4f5c\u4e3a\u914d\u7f6e\u6307\u4ee4\u540d\u4fdd\u7559\u81f3\u4eca\u3002<\/td><\/tr><tr><td><code>initramfs<\/code><\/td><td><strong>Initial RAM Filesystem<\/strong><br>(Linux 2.6+ standard)<\/td><td>No fake block device or <code>ext2<\/code> overhead: the kernel simply extracts a compressed <strong><code>CPIO<\/code> archive<\/strong> directly into a dynamic <code>ramfs<\/code>\/<code>tmpfs<\/code> tree in the page cache and executes <strong><code>\/init<\/code><\/strong>.<br>\u65e0\u9700\u6a21\u62df\u786c\u76d8\u6216\u683c\u5f0f\u5316\u6587\u4ef6\u7cfb\u7edf\uff1a\u5185\u6838\u76f4\u63a5\u628a\u538b\u7f29\u7684 <strong><code>CPIO<\/code> \u5f52\u6863<\/strong>\u89e3\u538b\u8fdb\u52a8\u6001\u4f38\u7f29\u7684\u5185\u5b58\u76ee\u5f55\u6811\uff08<code>tmpfs<\/code>\uff09\uff0c\u76f4\u63a5\u8fd0\u884c\u91cc\u9762\u7684 <strong><code>\/init<\/code><\/strong>\u3002<\/td><td><strong>100% of modern Linux distros<\/strong> (Ubuntu\/Debian <code>initramfs-tools<\/code>, Fedora\/RHEL <code>dracut<\/code>, Arch <code>mkinitcpio<\/code>) build and boot <code>initramfs<\/code>.<br><strong>\u73b0\u4ee3\u6240\u6709\u4e3b\u6d41 Linux \u53d1\u884c\u7248\u7684\u6807\u51c6\u673a\u5236\u3002<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. What Is CPIO? Inside the Archive Format of initramfs (CPIO \u5f52\u6863\u683c\u5f0f\u89e3\u6790)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even when a distro names the file <code>initrd.img<\/code> or <code>initramfs-6.12.0.img<\/code>, it is not an ISO or disk partition image\u2014it is a compressed <strong><code>CPIO<\/code> archive<\/strong> (specifically the SVR4 <strong><code>newc<\/code><\/strong> format, whose entries always start with the 6-byte ASCII magic string <code>070701<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u7ba1\u53d1\u884c\u7248\u628a\u542f\u52a8\u955c\u50cf\u8d77\u540d\u53eb <code>initrd.img<\/code> \u8fd8\u662f <code>initramfs-6.12.0.img<\/code>\uff0c\u5b83\u672c\u8d28\u4e0a\u90fd\u4e0d\u662f\u78c1\u76d8\u5206\u533a\u955c\u50cf\uff0c\u800c\u662f\u4e00\u4e2a\u7ecf\u8fc7 <code>zstd<\/code> \u6216 <code>gzip<\/code> \u538b\u7f29\u7684 <strong><code>CPIO<\/code>\uff08<em>Copy In and Copy Out<\/em>\uff09\u5f52\u6863\u5305<\/strong>\u2014\u2014\u5177\u4f53\u91c7\u7528\u7684\u662f SVR4 <strong><code>newc<\/code><\/strong> \u683c\u5f0f\uff08\u6bcf\u4e2a\u6761\u76ee\u90fd\u4ee5 6 \u5b57\u8282 ASCII \u9b54\u6570 <code>070701<\/code> \u5f00\u5934\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Layout of an uncompressed SVR4 \"newc\" CPIO stream (4-byte aligned):\n# \u672a\u538b\u7f29 SVR4 \"newc\" CPIO \u5b57\u8282\u6d41\u7684\u6781\u7b80\u987a\u5e8f\u7ed3\u6784\uff08\u6309 4 \u5b57\u8282\u5bf9\u9f50\uff09\uff1a\n\n+------------------------------------------------------------------+\n| Entry 1: 110-byte ASCII hex header (\"070701\", mode, uid, size..) |\n|          + NUL-padded filename (e.g. \"init\\0\\0\")                 |\n|          + raw file contents (padded with NULs to 4-byte align)  |\n+------------------------------------------------------------------+\n| Entry 2: 110-byte ASCII hex header + \"bin\/sh\\0...\" + file bytes  |\n+------------------------------------------------------------------+\n| ... more files, directories, symlinks, device nodes ...          |\n+------------------------------------------------------------------+\n| End Marker: 110-byte header + filename \"TRAILER!!!\"              |\n+------------------------------------------------------------------+<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why did the Linux kernel choose <code>newc<\/code> <code>CPIO<\/code> instead of <code>tar<\/code>?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e3a\u4ec0\u4e48 Linux \u5185\u6838\u94a6\u5b9a\u4e86 <code>newc<\/code> <code>CPIO<\/code> \u800c\u4e0d\u662f\u5927\u5bb6\u66f4\u719f\u6089\u7684 <code>tar<\/code>\uff1f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tiny in-kernel parser:<\/strong> Every header field (inode, permissions, UID\/GID, file size, device major\/minor, filename length) is fixed-width ASCII hex, allowing <code>init\/initramfs.c<\/code> inside the kernel to stream-extract directories, symlinks, and character\/block device nodes in just a couple hundred lines of C.<br><strong>\u5185\u6838\u89e3\u6790\u5668\u6781\u5ea6\u7cbe\u7b80\uff1a<\/strong>\u6240\u6709\u5143\u6570\u636e\uff08\u6743\u9650\u3001\u5927\u5c0f\u3001\u4e3b\u6b21\u8bbe\u5907\u53f7\u3001\u6587\u4ef6\u540d\u957f\u5ea6\uff09\u90fd\u662f\u5b9a\u957f ASCII \u5341\u516d\u8fdb\u5236\u5b57\u7b26\uff0c\u5185\u6838\u91cc\u7684 <code>init\/initramfs.c<\/code> \u53ea\u9700\u51e0\u767e\u884c C \u4ee3\u7801\u5c31\u80fd\u6d41\u5f0f\u8fd8\u539f\u76ee\u5f55\u3001\u8f6f\u94fe\u63a5\u548c\u8bbe\u5907\u8282\u70b9\u3002<\/li>\n<li><strong>Native archive concatenation (stacking):<\/strong> Because each CPIO stream simply ends with <code>TRAILER!!!<\/code>, the kernel can read <strong>multiple concatenated CPIO archives back-to-back<\/strong> in a single buffer! Modern distros use this every day to prepend an uncompressed <code>cpu-microcode.cpio<\/code> right in front of a <code>zstd<\/code>-compressed <code>initramfs.cpio.zst<\/code>\u2014the kernel updates CPU microcode at the earliest possible moment and immediately continues unpacking the main <code>initramfs<\/code> into the same RAM rootfs.<br><strong>\u539f\u751f\u652f\u6301\u591a\u5305\u62fc\u63a5\u53e0\u52a0\uff1a<\/strong>\u7531\u4e8e\u6bcf\u4e2a CPIO \u6d41\u53ea\u662f\u4ee5 <code>TRAILER!!!<\/code> \u6536\u5c3e\uff0cLinux \u5185\u6838\u5929\u751f\u652f\u6301\u628a<strong>\u591a\u4e2a\uff08\u751a\u81f3\u4e0d\u540c\u538b\u7f29\u683c\u5f0f\u7684\uff09CPIO \u5f52\u6863\u76f4\u63a5\u9996\u5c3e\u62fc\u63a5\u6216\u4f9d\u6b21\u4f20\u5165<\/strong>\uff01\u73b0\u4ee3\u53d1\u884c\u7248\u666e\u904d\u5229\u7528\u8fd9\u4e00\u6807\u51c6\u7279\u6027\uff0c\u628a\u672a\u538b\u7f29\u7684 <code>cpu-microcode.cpio<\/code> \u62fc\u5728 <code>zstd<\/code> \u538b\u7f29\u7684\u4e3b <code>initramfs<\/code> \u524d\u9762\uff0c\u8ba9\u5185\u6838\u4e00\u4e0a\u6765\u5148\u5237\u5165 CPU \u5fae\u7801\u8865\u4e01\uff0c\u7d27\u63a5\u7740\u65e0\u7f1d\u89e3\u538b\u4e3b <code>initramfs<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. Practical Commands to Inspect \/boot\/efi &amp; initramfs (\u5e38\u7528\u67e5\u770b\u4e0e\u62c6\u5305\u547d\u4ee4\u901f\u67e5)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can inspect every piece of a live machine&#8217;s UEFI boot tree and <code>initramfs<\/code> CPIO archive using standard Linux utilities:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4efb\u4f55\u6807\u51c6 Linux \u673a\u5668\u4e0a\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u51e0\u6761\u547d\u4ee4\u76f4\u63a5\u67e5\u770b UEFI \u542f\u52a8\u914d\u7f6e\u4e0e\u62c6\u89e3 <code>initramfs<\/code> \u5185\u90e8\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. Inspect active UEFI bootloader, ESP PARTUUID, and all BLS entries\n# 1. \u67e5\u770b\u5f53\u524d\u751f\u6548\u7684 UEFI \u5f15\u5bfc\u5668\u3001ESP \u5206\u533a\u4fe1\u606f\u4e0e\u5168\u90e8 BLS \u542f\u52a8\u9879\nbootctl status\n\n# 2. Verify that vmlinuz has CONFIG_EFI_STUB=y (valid UEFI PE32+ executable)\n# 2. \u9a8c\u8bc1\u5185\u6838\u955c\u50cf\u662f\u5426\u5f00\u542f\u4e86 CONFIG_EFI_STUB\uff08\u53ef\u76f4\u63a5\u4f5c\u4e3a EFI \u7a0b\u5e8f\u542f\u52a8\uff09\nfile \/boot\/efi\/vmlinuz-*\n\n# 3. List files inside a compressed initramfs image (Debian\/Ubuntu or Fedora\/RHEL)\n# 3. \u4e0d\u89e3\u538b\u76f4\u63a5\u5217\u51fa\u538b\u7f29 initramfs \u5f52\u6863\u5185\u7684\u5168\u90e8\u6587\u4ef6\u6e05\u5355\nlsinitramfs \/boot\/initrd.img-$(uname -r)   # Debian \/ Ubuntu\nlsinitrd \/boot\/initramfs-$(uname -r).img   # Fedora \/ RHEL \/ Rocky\n\n# 4. Manually unpack an initramfs CPIO archive into \/tmp\/inspect-initramfs\n# 4. \u624b\u5de5\u628a\u4e00\u4e2a zstd \u538b\u7f29\u7684 initramfs CPIO \u5305\u89e3\u5f00\u5230\u4e34\u65f6\u76ee\u5f55\u67e5\u770b\u91cc\u9762\u7684 \/init \u811a\u672c\nmkdir -p \/tmp\/inspect-initramfs &amp;&amp; cd \/tmp\/inspect-initramfs\nzstdcat \/boot\/efi\/initramfs-6.12.0.img | cpio -idmv\n\n# 5. Repackage a directory into a standard SVR4 \"newc\" CPIO initramfs\n# 5. \u5c06\u76ee\u5f55\u91cd\u65b0\u6253\u5305\u6210\u7b26\u5408\u5185\u6838\u6807\u51c6\u7684 SVR4 \"newc\" (070701) CPIO \u955c\u50cf\nfind . -print0 | cpio --null -o -H newc --owner 0:0 | zstd -19 &gt; \/tmp\/new-initramfs.img<\/code><\/pre>\n\n","protected":false},"excerpt":{"rendered":"<p>In From Bare NVMe to Login Prompt, we walked through how a blank NVMe SSD is partitioned with GPT, formatted into vfat and ext4, attached to the directory tree via mount, and booted into systemd. Now let&#8217;s zoom into the standard Linux UEFI boot partition and early-boot memory filesystem to answer three classic questions: What&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"0","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,16,22],"tags":[],"class_list":["post-1832","post","type-post","status-publish","format-standard","hentry","category-embedded","category-linux","category-operation-systems"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/1832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=1832"}],"version-history":[{"count":3,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/1832\/revisions"}],"predecessor-version":[{"id":1835,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/1832\/revisions\/1835"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=1832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=1832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=1832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}