[bootlin/training-materials updates] master: Improve initramfs explanations (da6689ab)

Michael Opdenacker michael.opdenacker at bootlin.com
Mon Mar 15 22:19:19 CET 2021


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/da6689ab9e6959cd788c1f149ba44f2ac3c899d7

>---------------------------------------------------------------

commit da6689ab9e6959cd788c1f149ba44f2ac3c899d7
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Mon Mar 15 22:18:10 2021 +0100

    Improve initramfs explanations
    
    - Clarify them
    - Include details about how to make an image
      that can be used in U-Boot
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


>---------------------------------------------------------------

da6689ab9e6959cd788c1f149ba44f2ac3c899d7
 slides/initramfs/initramfs.dia | 91 ++++++++++++++++++++++++++----------------
 slides/initramfs/initramfs.tex | 82 ++++++++++++++++++++-----------------
 2 files changed, 103 insertions(+), 70 deletions(-)

diff --git a/slides/initramfs/initramfs.dia b/slides/initramfs/initramfs.dia
index 59fb5805..e3ce27f0 100644
--- a/slides/initramfs/initramfs.dia
+++ b/slides/initramfs/initramfs.dia
@@ -2,10 +2,10 @@
 <dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
   <dia:diagramdata>
     <dia:attribute name="background">
-      <dia:color val="#ffffff"/>
+      <dia:color val="#ffffffff"/>
     </dia:attribute>
     <dia:attribute name="pagebreak">
-      <dia:color val="#000099"/>
+      <dia:color val="#000099ff"/>
     </dia:attribute>
     <dia:attribute name="paper">
       <dia:composite type="paper">
@@ -37,6 +37,9 @@
     </dia:attribute>
     <dia:attribute name="grid">
       <dia:composite type="grid">
+        <dia:attribute name="dynamic">
+          <dia:boolean val="true"/>
+        </dia:attribute>
         <dia:attribute name="width_x">
           <dia:real val="1"/>
         </dia:attribute>
@@ -53,7 +56,7 @@
       </dia:composite>
     </dia:attribute>
     <dia:attribute name="color">
-      <dia:color val="#d8e5e5"/>
+      <dia:color val="#d8e5e5ff"/>
     </dia:attribute>
     <dia:attribute name="guides">
       <dia:composite type="guides">
@@ -61,32 +64,51 @@
         <dia:attribute name="vguides"/>
       </dia:composite>
     </dia:attribute>
+    <dia:attribute name="display">
+      <dia:composite type="display">
+        <dia:attribute name="antialiased">
+          <dia:boolean val="true"/>
+        </dia:attribute>
+        <dia:attribute name="snap-to-grid">
+          <dia:boolean val="true"/>
+        </dia:attribute>
+        <dia:attribute name="snap-to-object">
+          <dia:boolean val="true"/>
+        </dia:attribute>
+        <dia:attribute name="show-grid">
+          <dia:boolean val="true"/>
+        </dia:attribute>
+        <dia:attribute name="show-connection-points">
+          <dia:boolean val="true"/>
+        </dia:attribute>
+      </dia:composite>
+    </dia:attribute>
   </dia:diagramdata>
-  <dia:layer name="Arrière-plan" visible="true" active="true">
+  <dia:layer name="Arrière-plan" visible="true" connectable="true" active="true">
     <dia:object type="Standard - Box" version="0" id="O0">
       <dia:attribute name="obj_pos">
         <dia:point val="19,6"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="18.95,5.95;44.05,14.05"/>
+        <dia:rectangle val="18.95,5.95;31.05,24.05"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
         <dia:point val="19,6"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
-        <dia:real val="25"/>
+        <dia:real val="12"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="8"/>
+        <dia:real val="18"/>
       </dia:attribute>
       <dia:attribute name="border_width">
         <dia:real val="0.10000000149011612"/>
       </dia:attribute>
       <dia:attribute name="border_color">
-        <dia:color val="#868686"/>
+        <dia:color val="#868686ff"/>
       </dia:attribute>
       <dia:attribute name="inner_color">
-        <dia:color val="#e5e5e5"/>
+        <dia:color val="#e5e5e5ff"/>
       </dia:attribute>
       <dia:attribute name="show_background">
         <dia:boolean val="true"/>
@@ -100,25 +122,25 @@
         <dia:point val="20,7"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="19.95,6.95;31.05,11.05"/>
+        <dia:rectangle val="19.95,6.95;30.05,16.05"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
         <dia:point val="20,7"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
-        <dia:real val="11"/>
+        <dia:real val="10"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="4"/>
+        <dia:real val="9"/>
       </dia:attribute>
       <dia:attribute name="border_width">
         <dia:real val="0.10000000149011612"/>
       </dia:attribute>
       <dia:attribute name="border_color">
-        <dia:color val="#d9cb2f"/>
+        <dia:color val="#d9cb2fff"/>
       </dia:attribute>
       <dia:attribute name="inner_color">
-        <dia:color val="#fff8a8"/>
+        <dia:color val="#fff8a8ff"/>
       </dia:attribute>
       <dia:attribute name="show_background">
         <dia:boolean val="true"/>
@@ -129,16 +151,16 @@
     </dia:object>
     <dia:object type="Standard - Box" version="0" id="O2">
       <dia:attribute name="obj_pos">
-        <dia:point val="32,7"/>
+        <dia:point val="20,17"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="31.95,6.95;43.05,11.05"/>
+        <dia:rectangle val="19.95,16.95;30.05,21.05"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
-        <dia:point val="32,7"/>
+        <dia:point val="20,17"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
-        <dia:real val="11"/>
+        <dia:real val="10"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
         <dia:real val="4"/>
@@ -147,10 +169,10 @@
         <dia:real val="0.10000000149011612"/>
       </dia:attribute>
       <dia:attribute name="border_color">
-        <dia:color val="#cc1f1a"/>
+        <dia:color val="#cc1f1aff"/>
       </dia:attribute>
       <dia:attribute name="inner_color">
-        <dia:color val="#ffacac"/>
+        <dia:color val="#ffacacff"/>
       </dia:attribute>
       <dia:attribute name="show_background">
         <dia:boolean val="true"/>
@@ -161,10 +183,10 @@
     </dia:object>
     <dia:object type="Standard - Text" version="1" id="O3">
       <dia:attribute name="obj_pos">
-        <dia:point val="21.35,9.3"/>
+        <dia:point val="21,9"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="21.35,8.3875;28.425,9.545"/>
+        <dia:rectangle val="21,8.08809;28.075,9.24418"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
@@ -178,10 +200,10 @@
             <dia:real val="0.98777773976325989"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="21.35,9.3"/>
+            <dia:point val="21,9"/>
           </dia:attribute>
           <dia:attribute name="color">
-            <dia:color val="#000000"/>
+            <dia:color val="#000000ff"/>
           </dia:attribute>
           <dia:attribute name="alignment">
             <dia:enum val="0"/>
@@ -194,10 +216,10 @@
     </dia:object>
     <dia:object type="Standard - Text" version="1" id="O4">
       <dia:attribute name="obj_pos">
-        <dia:point val="37.65,8.35"/>
+        <dia:point val="25,18"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="33.9925,7.4375;41.3075,10.5706"/>
+        <dia:rectangle val="21.3425,17.0881;28.6575,20.2197"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
@@ -213,10 +235,10 @@ archive#</dia:string>
             <dia:real val="0.98777773976325989"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="37.65,8.35"/>
+            <dia:point val="25,18"/>
           </dia:attribute>
           <dia:attribute name="color">
-            <dia:color val="#000000"/>
+            <dia:color val="#000000ff"/>
           </dia:attribute>
           <dia:attribute name="alignment">
             <dia:enum val="1"/>
@@ -229,15 +251,16 @@ archive#</dia:string>
     </dia:object>
     <dia:object type="Standard - Text" version="1" id="O5">
       <dia:attribute name="obj_pos">
-        <dia:point val="25.355,13.375"/>
+        <dia:point val="25,22"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="25.355,12.4336;37.7939,13.6779"/>
+        <dia:rectangle val="21.6025,21.0881;28.3975,23.232"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
-            <dia:string>#Kernel image (zImage, bzImage, etc.)#</dia:string>
+            <dia:string>#Kernel image
+(zImage, bzImage...)#</dia:string>
           </dia:attribute>
           <dia:attribute name="font">
             <dia:font family="Latin Modern Sans" style="0" name="Courier"/>
@@ -246,13 +269,13 @@ archive#</dia:string>
             <dia:real val="0.98777773976325989"/>
           </dia:attribute>
           <dia:attribute name="pos">
-            <dia:point val="25.355,13.375"/>
+            <dia:point val="25,22"/>
           </dia:attribute>
           <dia:attribute name="color">
-            <dia:color val="#000000"/>
+            <dia:color val="#000000ff"/>
           </dia:attribute>
           <dia:attribute name="alignment">
-            <dia:enum val="0"/>
+            <dia:enum val="1"/>
           </dia:attribute>
         </dia:composite>
       </dia:attribute>
diff --git a/slides/initramfs/initramfs.tex b/slides/initramfs/initramfs.tex
index 11dd9671..a0eeadc0 100644
--- a/slides/initramfs/initramfs.tex
+++ b/slides/initramfs/initramfs.tex
@@ -1,17 +1,12 @@
 \begin{frame}
-  \frametitle{rootfs in memory: initramfs (1)}
+  \frametitle{Root filesystem in memory: initramfs}
+  It is also possible to boot the system with a filesystem in memory:
+  {\em initramfs}
   \begin{itemize}
-  \item It is also possible to have the root filesystem integrated
-    into the kernel image
-  \item It is therefore loaded into memory together with the kernel
-  \item This mechanism is called {\bf initramfs}
-    \begin{itemize}
-    \item It integrates a compressed archive of the filesystem into
-      the kernel image
-    \item Variant: the compressed archive can also be loaded separately
-      by the bootloader.
-    \end{itemize}
-  \item It is useful for two cases
+  \item Either from a compressed CPIO archive integrated into the kernel image
+  \item Or from such an archive loaded by the bootloader into memory
+  \item At boot time, this archive is extracted into the Linux file cache
+  \item It is useful for two cases:
     \begin{itemize}
     \item Fast booting of very small root filesystems. As the
       filesystem is completely loaded at boot time, application
@@ -23,36 +18,51 @@
       desktop/server distributions to keep the kernel image size
       reasonable.
     \end{itemize}
+  \item Details (in kernel sources): \\
+    \kerneldochtml{filesystems/ramfs-rootfs-initramfs}\\
   \end{itemize}
 \end{frame}
 
-\begin{frame}
-  \frametitle{rootfs in memory: initramfs (2)}
-  \begin{center}
-    \includegraphics[width=0.9\textwidth]{slides/initramfs/initramfs.pdf}
-  \end{center}
+\begin{frame}[fragile]
+  \frametitle{External initramfs}
+  \begin{itemize}
+  \item To create one, first create a compressed CPIO archive:
+ \begin{verbatim}
+cd rootfs/
+find . | cpio -H newc -o > ../initramfs.cpio
+cd ..
+gzip initramfs.cpio
+\end{verbatim}
+  \item If you're using U-Boot, you'll need to include your archive
+  in a U-Boot container:
+  \begin{verbatim}
+mkimage -n 'Ramdisk Image' -A arm -O linux -T ramdisk -C gzip \
+        -d initramfs.cpio.gz uInitramfs
+\end{verbatim}
+  \item Then, in the bootloader, load the kernel binary, DTB and
+  \code{uInitramfs} in RAM and boot the kernel as follows:
+  \begin{verbatim}
+bootm kernel-addr initramfs-addr dtb-addr
+\end{verbatim}
+  \end{itemize}
 \end{frame}
 
 \begin{frame}
-  \frametitle{rootfs in memory: initramfs (3)}
+  \frametitle{Built-in initramfs}
+  \begin{columns}
+  \column{0.75\textwidth}
+  To have the kernel Makefile include an initramfs archive in
+  the kernel image: use the \kconfig{CONFIG_INITRAMFS_SOURCE}
+  option.
   \begin{itemize}
-  \item The contents of an initramfs are defined at the kernel
-    configuration level, with the \kconfig{CONFIG_INITRAMFS_SOURCE}
-    option
-    \begin{itemize}
-    \item Can be the path to a directory containing the root
-      filesystem contents
-    \item Can be the path to a cpio archive
-    \item Can be a text file describing the contents of the initramfs \\
-      (see documentation for details)
-    \end{itemize}
-  \item The kernel build process will automatically take the contents
-    of the \kconfig{CONFIG_INITRAMFS_SOURCE} option and integrate the
-    root filesystem into the kernel image
-  \item Details (in kernel sources): \\
-    {\small
-    \kerneldochtml{filesystems/ramfs-rootfs-initramfs}\\
-    \kerneldochtml{driver-api/early-userspace}
-    }
+  \item It can be the path to a directory containing the root
+    filesystem contents
+  \item It can be the path to a ready made cpio archive
+  \item It can be a text file describing the contents of the initramfs
   \end{itemize}
+  See the kernel documentation for details:
+  \kerneldochtml{driver-api/early-userspace/early_userspace_support}
+  \column{0.25\textwidth}
+    \includegraphics[width=0.9\textwidth]{slides/initramfs/initramfs.pdf}
+  \end{columns}
 \end{frame}




More information about the training-materials-updates mailing list