summaryrefslogtreecommitdiffstats
path: root/initrd.xml
diff options
context:
space:
mode:
Diffstat (limited to 'initrd.xml')
-rw-r--r--initrd.xml124
1 files changed, 124 insertions, 0 deletions
diff --git a/initrd.xml b/initrd.xml
new file mode 100644
index 0000000..3b03aab
--- /dev/null
+++ b/initrd.xml
@@ -0,0 +1,124 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+<!-- This document was created with Syntext Serna Free. -->
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
+<sect1 id="initrd">
+<?dbhtml filename="initrd.html"?> <title> Building the initramfs image</title>
+<note><para>This chapter is mandatory for both the livecd and the livekey.</para></note>
+ <para>To boot our live system, we will need an initramfs image, which will contain a couple of utilities and kernel modules, necessary to find our rootfs and mount it.
+ </para>
+ <para>Create a directory structure:</para>
+ <screen><userinput>mkdir -p initramfs/{bin,sbin,dev/{pts,shm},etc,proc,sys,rtmnt,lib}</userinput></screen>
+ <para>Copy busybox which we created in the chapter <xref linkend="busybox"/> to the bin directory</para>
+ <screen><userinput>cp &lt;path-to-busybox-builddir&gt;/busybox initramfs/bin </userinput></screen>
+ <para>Busybox can install symlinks for the desired utilities itself, however this can be done until the init script is running. So for some utilities that we need before this stage, we need to create the symlinks our selfs.</para>
+ <para><screen><userinput>ln -s /bin/busybox initramfs/bin/ash
+ln -s /bin/busybox initramfs/bin/mount </userinput></screen></para>
+ <para>We need access to some devicenodes before udev starts:</para>
+ <para><screen><userinput>mknod initramfs/dev/null c 1 3
+mknod initramfs/dev/tty c 5 0
+mknod initramfs/dev/console c 5 1 </userinput></screen></para>
+ <para>Add the necessary kernel modules:</para>
+ <para><screen><userinput>for filename in sd_mod usbcore ehci-hcd usb-storage usb-libusual uhci-hcd ext3 mbcache jbd
+do
+&#009;find /lib/modules/`uname -r` -name "$filename"* -exec cp -r --parents {} initramfs \;
+done</userinput></screen></para>
+ <para>This will search for the given modules, and copy them to the initramfs</para>
+ <para>Now we need to create the initscript:</para>
+ <screen><userinput>cat &gt; initramfs/init &lt;&lt; &quot;EOF&quot;
+#!/bin/ash
+
+PATH=/bin:/sbin
+
+# Mount proc and sysfs
+
+mount -t proc none /proc
+mount -t sysfs none /sys
+mount -t devtmpfs none /dev
+
+# Unpack the busybox
+
+/bin/busybox --install -s
+
+# Add modules
+
+if [ -z $(ls /lib/modules/) ]; then
+
+&#009;depmod -a
+
+&#009;modprobe sd_mod
+&#009;modprobe usbcore
+&#009;modprobe ehci-hcd
+&#009;modprobe usb-storage
+&#009;modprobe ext3
+
+fi
+
+# Check the command line
+
+initfile=&quot;/sbin/init&quot;
+root=&quot;&quot;
+
+# Check the parameterlist for rootdelay
+
+for arg in $(cat /proc/cmdline); do
+&#009;case $arg in
+
+&#009;rootdelay=*)
+&#009;&#009;dt=$(echo $arg | cut -d= -f2)
+&#009;&#009;sleep $dt
+&#009;&#009;;;
+&#009;esac
+done
+
+# Check the parameterlist for UUID= and LABEL=
+
+for arg in $(cat /proc/cmdline); do
+&#009;case $arg in
+
+&#009; root=*)
+&#009;&#009;option=$(echo $arg | cut -d= -f2)
+
+&#009;&#009;if [ $option == &quot;LABEL&quot; ] ; then
+&#009;&#009;&#009;root=$(findfs LABEL=$(echo $arg | cut -d= -f3))
+&#009;&#009;fi
+
+&#009;&#009;if [ $option == &quot;UUID&quot; ] ; then
+&#009;&#009;&#009;root=$(findfs UUID=$(echo $arg | cut -d= -f3))
+&#009;&#009;fi
+
+&#009;&#009;;;
+
+&#009;init=*)
+&#009;&#009;initfile=$(echo &quot;$@&quot; | cut -d &quot;=&quot; -f 2 )
+
+&#009;&#009;;;
+
+&#009;esac
+done
+
+if [ $root != &quot;&quot; ] ; then
+
+&#009;mount &quot;${root}&quot; /rtmnt
+
+&#009;if [[ -x &quot;/rtmnt/${initfile}&quot; ]] ; then
+
+&#009;&#009;umount /dev
+&#009;&#009;umount /sys
+&#009;&#009;umount /proc
+
+&#009;&#009;exec switch_root /rtmnt &quot;${initfile}&quot;
+&#009;fi
+fi
+
+# We shouldn&apos;t come here
+
+exec ash
+EOF
+chmod 0755 initramfs/init</userinput></screen>
+ <para>Pack our stuff:</para>
+ <screen><userinput>cd initramfs
+find ./ | cpio -H newc -o &gt; ../initrd
+cd ..
+gzip initrd</userinput></screen>
+<para>Keep our created initrd.gz for later use.</para>
+</sect1>