Ignore:
Timestamp:
03/25/2020 09:46:27 PM (4 years ago)
Author:
Pierre Labastie <pieere@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, lazarus, lxqt, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
f716ef4
Parents:
9bd10279
Message:

format filesystems chapter

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@22895 af4574ff-66df-0310-9fd7-8a98e5e911e0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/filesystems/initramfs.xml

    r9bd10279 r29244b7  
    1616  <title>About initramfs</title>
    1717
    18   <para>The only purpose of an initramfs is to mount the root filesystem.  The
    19   initramfs is a complete set of directories that you would find on a normal
    20   root filesystem.  It is bundled into a single cpio archive and compressed
    21   with one of several compression algorithms.</para>
    22 
    23   <para>At boot time, the boot loader loads the kernel and the initramfs image
    24   into memory and starts the kernel.  The kernel checks for the presence of the
    25   initramfs and, if found, mounts it as / and runs /init. The init program is
    26   typically a shell script.  Note that the boot process takes longer, possibly
    27   significantly longer, if an initramfs is used.</para>
    28 
    29   <para>For most distributions, kernel modules are the biggest reason to have an
    30   initramfs.  In a general distribution, there are many unknowns such as file
    31   system types and disk layouts.  In a way, this is the opposite of LFS where
    32   the system capabilities and layout are known and a custom kernel is normally
    33   built.  In this situation, an initramfs is rarely needed.</para>
    34 
    35   <para>There are only four primary reasons to have an initramfs in the LFS
    36   environment: loading the rootfs from a network, loading it from an LVM
    37   logical volume, having an encrypted rootfs where a password is required, or
    38   for the convenience of specifying the rootfs as a LABEL or UUID.  Anything
    39   else usually means that the kernel was not configured properly.</para>
     18  <para>
     19    The only purpose of an initramfs is to mount the root filesystem.  The
     20    initramfs is a complete set of directories that you would find on a normal
     21    root filesystem.  It is bundled into a single cpio archive and compressed
     22    with one of several compression algorithms.
     23  </para>
     24
     25  <para>
     26    At boot time, the boot loader loads the kernel and the initramfs image
     27    into memory and starts the kernel.  The kernel checks for the presence
     28    of the initramfs and, if found, mounts it as / and runs /init. The init
     29    program is typically a shell script.  Note that the boot process takes
     30    longer, possibly significantly longer, if an initramfs is used.
     31  </para>
     32
     33  <para>
     34    For most distributions, kernel modules are the biggest reason to have
     35    an initramfs.  In a general distribution, there are many unknowns such
     36    as file system types and disk layouts.  In a way, this is the opposite
     37    of LFS where the system capabilities and layout are known and a custom
     38    kernel is normally built.  In this situation, an initramfs is rarely
     39    needed.
     40  </para>
     41
     42  <para>
     43    There are only four primary reasons to have an initramfs in the LFS
     44    environment: loading the rootfs from a network, loading it from an LVM
     45    logical volume, having an encrypted rootfs where a password is required, or
     46    for the convenience of specifying the rootfs as a LABEL or UUID.  Anything
     47    else usually means that the kernel was not configured properly.
     48  </para>
    4049
    4150  <sect2 id="initramfs-build">
    4251    <title>Building an initramfs</title>
    4352
    44     <para>If you do decide to build an initramfs, the following scripts
    45     will provide a basis to do it.  The scripts will allow specifying a
    46     rootfs via partition UUID or partition LABEL or a rootfs on an
    47     LVM logical volume.  They do not support an encrypted root file system
    48     or mounting the rootfs over a network card.  For a more complete
    49     capability see <ulink url="http://www.linuxfromscratch.org/hints/read.html">
    50     the LFS Hints</ulink> or <ulink url="http://fedoraproject.org/wiki/Dracut">
    51     dracut</ulink>.</para>
    52 
    53     <para>To install these scripts, run the following commands as the
    54     <systemitem class="username">root</systemitem> user:</para>
     53    <para>
     54      If you do decide to build an initramfs, the following scripts will
     55      provide a basis to do it.  The scripts will allow specifying a rootfs
     56      via partition UUID or partition LABEL or a rootfs on an LVM logical
     57      volume.  They do not support an encrypted root file system or mounting
     58      the rootfs over a network card.  For a more complete capability see
     59      <ulink url="http://www.linuxfromscratch.org/hints/read.html"> the LFS
     60      Hints</ulink> or <ulink
     61      url="http://fedoraproject.org/wiki/Dracut">dracut</ulink>.
     62    </para>
     63
     64    <para>
     65      To install these scripts, run the following commands as the
     66      <systemitem class="username">root</systemitem> user:
     67    </para>
    5568
    5669    <screen role="root"><userinput>cat &gt; /sbin/mkinitramfs &lt;&lt; "EOF"
     
    434447
    435448
    436     <para>To build an initramfs, run the following as the  <systemitem
    437     class="username">root</systemitem> user:</para>
     449    <para>
     450      To build an initramfs, run the following as the  <systemitem
     451      class="username">root</systemitem> user:
     452    </para>
    438453
    439454    <screen role="nodump"><userinput>mkinitramfs [KERNEL VERSION]</userinput></screen>
    440455
    441     <para>The optional argument is the directory where the appropriate kernel
    442     modules are located. This must be a subdirectory of <filename
    443     class='directory'> /lib/modules</filename>.  If no modules are specified,
    444     then the initramfs is named <emphasis>initrd.img-no-kmods</emphasis>.  If a
    445     kernel version is specified, the initrd is named
    446     <emphasis>initrd.img-$KERNEL_VERSION</emphasis> and is only appropriate for
    447     the specific kernel specified. The output file will be placed in the
    448     current directory.</para>
    449 
    450     <para>If early loading of microcode is needed (see <xref
    451     linkend="cpu-microcode"/>), you can install the appropriate blob or
    452     container in <filename class="directory">/lib/firmware</filename>.
    453     It will be automatically added to the initrd when running
    454     <command>mkinitramfs</command>.</para>
    455 
    456     <para>After generating the initrd, copy it to the <filename
    457     class='directory'>/boot</filename> directory.</para>
    458 
    459     <para>Now edit <filename>/boot/grub/grub.cfg</filename> and add a new
    460     menuentry.  Below are several examples.</para>
     456    <para>
     457      The optional argument is the directory where the appropriate kernel
     458      modules are located. This must be a subdirectory of <filename
     459      class='directory'> /lib/modules</filename>.  If no modules are specified,
     460      then the initramfs is named <emphasis>initrd.img-no-kmods</emphasis>.
     461      If a kernel version is specified, the initrd is named
     462      <emphasis>initrd.img-$KERNEL_VERSION</emphasis> and is only appropriate
     463      for the specific kernel specified. The output file will be placed in the
     464      current directory.
     465    </para>
     466
     467    <para>
     468      If early loading of microcode is needed (see <xref
     469      linkend="cpu-microcode"/>), you can install the appropriate blob or
     470      container in <filename class="directory">/lib/firmware</filename>.
     471      It will be automatically added to the initrd when running
     472      <command>mkinitramfs</command>.
     473    </para>
     474
     475    <para>
     476      After generating the initrd, copy it to the <filename
     477      class='directory'>/boot</filename> directory.
     478    </para>
     479
     480    <para>
     481      Now edit <filename>/boot/grub/grub.cfg</filename> and add a new
     482      menuentry.  Below are several examples.
     483    </para>
    461484
    462485     <screen role="nodump"><userinput># Generic initramfs and root fs identified by UUID
     
    481504}</userinput></screen>
    482505
    483     <para>Finally, reboot the system and select the desired system.</para>
     506    <para>
     507      Finally, reboot the system and select the desired system.
     508    </para>
    484509
    485510  </sect2>
Note: See TracChangeset for help on using the changeset viewer.