这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
|
jaysnote:ramfs_rootfs_initramfs [2018/11/19 13:51] jaylee |
jaysnote:ramfs_rootfs_initramfs [2021/06/22 23:14] (当前版本) |
||
|---|---|---|---|
| 行 49: | 行 49: | ||
| - The old initrd was always a separate file, while the initramfs archive is linked into the linux kernel image. | - The old initrd was always a separate file, while the initramfs archive is linked into the linux kernel image. | ||
| - | - The old initrd file was a gzipped filesystem image (in some file format, | + | - The old initrd file was a gzipped filesystem image (in some file format,such as ext2, that needed a driver built into the kernel), while the new initramfs archive is a gzipped cpio archive (like tar only simpler,see cpio(1) and `Documentation/ |
| - | | + | |
| - | | + | |
| - The program run by the old initrd (which was called /initrd, not /init) did some setup and then returned to the kernel, while the init program from initramfs is not expected to return to the kernel. | - The program run by the old initrd (which was called /initrd, not /init) did some setup and then returned to the kernel, while the init program from initramfs is not expected to return to the kernel. | ||
| 行 63: | 行 61: | ||
| The 2.6 kernel build process always creates a gzipped cpio format initramfs archive and links it into the resulting kernel binary. | The 2.6 kernel build process always creates a gzipped cpio format initramfs archive and links it into the resulting kernel binary. | ||
| - | The config option CONFIG_INITRAMFS_SOURCE (in General Setup in menuconfig, | + | The config option |
| - | and living in usr/ | + | |
| ```bash | ```bash | ||
| 行 79: | 行 76: | ||
| ``` | ``` | ||
| - | Run " | + | Run `" |
| - | One advantage of the configuration file is that root access is not required to set permissions or create device nodes in the new archive. | + | One advantage of the configuration file is that root access is not required to set permissions or create device nodes in the new archive. |
| - | The kernel does not depend on external cpio tools. | + | The kernel does not depend on external cpio tools. |
| - | (obviously) self-contained. | + | |
| - | The one thing you might need external cpio utilities installed for is creating or extracting your own preprepared cpio files to feed to the kernel build | + | The one thing you might need external cpio utilities installed for is creating or extracting your own preprepared cpio files to feed to the kernel build (instead of a config file or directory). |
| - | (instead of a config file or directory). | + | |
| The following command line can extract a cpio image (either by the above script or by the kernel build) back into its component files: | The following command line can extract a cpio image (either by the above script or by the kernel build) back into its component files: | ||
| 行 130: | 行 125: | ||
| ## Contents of initramfs: | ## Contents of initramfs: | ||
| - | An initramfs archive is a complete self-contained root filesystem for Linux. | + | An initramfs archive is a complete self-contained root filesystem for Linux.If you don't already understand what shared libraries, devices, and path you need to get a minimal root filesystem up and running, here are som references: |
| - | If you don't already understand what shared libraries, devices, and path ou need to get a minimal root filesystem up and running, here are som eferences: | + | |
| * http:// | * http:// | ||
| 行 139: | 行 133: | ||
| * http:// | * http:// | ||
| - | The " | + | The " |
| - | I use uClibc (http:// | + | I use uClibc (http:// |
| - | myself. | + | |
| - | In theory you could use glibc, but that's not well suited for small embedde | + | In theory you could use glibc, but that's not well suited for small embedde |
| - | A good first step is to get initramfs to run a statically linked "hello world" | + | A good first step is to get initramfs to run a statically linked "hello world" program as init, and test it under an emulator like qemu (www.qemu.org) |
| - | program as init, and test it under an emulator like qemu (www.qemu.org) | + | |
| ```c | ```c | ||
| 行 153: | 行 145: | ||
| include < | include < | ||
| - | |||
| include < | include < | ||
| 行 168: | 行 159: | ||
| ``` | ``` | ||
| - | When debugging a normal root filesystem, it's nice to be able to boot with " | + | When debugging a normal root filesystem, it's nice to be able to boot with " |
| ## Why cpio rather than tar? | ## Why cpio rather than tar? | ||
| 行 212: | 行 203: | ||
| "early userspace" | "early userspace" | ||
| - | The move to early userspace is necessary because finding and mounting the real root device is complex. | + | The move to early userspace is necessary because finding and mounting the real root device is complex. |
| - | and so on. | + | |
| This kind of complexity (which inevitably includes policy) is rightly handled in userspace. | This kind of complexity (which inevitably includes policy) is rightly handled in userspace. | ||