GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.kernel.org — Early userspace support — The Linux Kernel documentation Early userspace support¶Last update: 2004-12-20 tlh “Early userspace” is a set of libraries and programs that provide various pieces of functionality that are important enough to be available while a Linux kernel is coming up, but that don’t need to be run inside the kernel itself. It consists of several major infrastructure components:
The cpio file format used by initramfs is the “newc” (aka “cpio -H newc”) format, and is documented in the file “initramfs buffer format”. There are two ways to add an early userspace image: specify an existing cpio archive to be used as the image or have the kernel build process build the image from specifications. CPIO ARCHIVE method¶You can create a cpio archive that contains the early userspace image. Your cpio archive should be specified in CONFIG_INITRAMFS_SOURCE and it will be used directly. Only a single cpio file may be specified in CONFIG_INITRAMFS_SOURCE and directory and file names are not allowed in combination with a cpio archive. IMAGE BUILDING method¶The kernel build process can also build an early userspace image from source parts rather than supplying a cpio archive. This method provides a way to create images with root-owned files even though the image was built by an unprivileged user. The image is specified as one or more sources in CONFIG_INITRAMFS_SOURCE. Sources can be either directories or files - cpio archives are not allowed when building from sources. A source directory will have it and all of its contents packaged. The specified directory name will be mapped to ‘/’. When packaging a directory, limited user and group ID translation can be performed. INITRAMFS_ROOT_UID can be set to a user ID that needs to be mapped to user root (0). INITRAMFS_ROOT_GID can be set to a group ID that needs to be mapped to group root (0). A source file must be directives in the format required by the scripts/gen_init_cpio utility (run ‘scripts/gen_init_cpio -h’ to get the file format). The directives in the file will be passed directly to scripts/gen_init_cpio. When a combination of directories and files are specified then the initramfs image will be an aggregate of all of them. In this way a user can create a ‘root-image’ directory and install all files into it. Because device-special files cannot be created by a unprivileged user, special files can be listed in a ‘root-files’ file. Both ‘root-image’ and ‘root-files’ can be listed in CONFIG_INITRAMFS_SOURCE and a complete early userspace image can be built by an unprivileged user. As a technical note, when directories and files are specified, the entire CONFIG_INITRAMFS_SOURCE is passed to scripts/gen_initramfs.sh. This means that CONFIG_INITRAMFS_SOURCE can really be interpreted as any legal argument to gen_initramfs.sh. If a directory is specified as an argument then the contents are scanned, uid/gid translation is performed, and scripts/gen_init_cpio file directives are output. If a file is specified as an argument to scripts/gen_initramfs.sh then the contents of the file are simply copied to the output. All of the output directives from directory scanning and file contents copying are processed by scripts/gen_init_cpio. See also ‘scripts/gen_initramfs.sh -h’. Where’s this all leading?¶The klibc distribution contains some of the necessary software to make early userspace useful. The klibc distribution is currently maintained separately from the kernel. You can obtain somewhat infrequent snapshots of klibc from https://www.kernel.org/pub/linux/libs/klibc/ For active users, you are better off using the klibc git repository, at https://git.kernel.org/?p=libs/klibc/klibc.git The standalone klibc distribution currently provides three components, in addition to the klibc library:
kinit is built as a single statically linked binary to save space. Eventually, several more chunks of kernel functionality will hopefully move to early userspace:
If kinit doesn’t meet your current needs and you’ve got bytes to burn, the klibc distribution includes a small Bourne-compatible shell (ash) and a number of other utilities, so you can replace kinit and build custom initramfs images that meet your needs exactly. For questions and help, you can sign up for the early userspace mailing list at https://www.zytor.com/mailman/listinfo/klibc How does it work?¶The kernel has currently 3 ways to mount the root filesystem:
Bryan O’Sullivan <bos@serpentine.com> |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |