diff options
author | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2020-06-07 20:16:00 +0000 |
---|---|---|
committer | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2020-06-07 20:16:00 +0000 |
commit | fcc027677da55c41dcaea045f5b9ff8b088e6495 (patch) | |
tree | 42500a7858959695b971e7f28f1d0bf33185db2e /chapter10 | |
parent | d53fefab5a6772fef606392a61608fc290e6a7ae (diff) |
Initial commit of alternative cross LFS
git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross2@11897 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter10')
-rw-r--r-- | chapter10/chapter10.xml | 19 | ||||
-rw-r--r-- | chapter10/fstab.xml | 125 | ||||
-rw-r--r-- | chapter10/grub.xml | 191 | ||||
-rw-r--r-- | chapter10/introduction.xml | 18 | ||||
-rw-r--r-- | chapter10/kernel.xml | 403 |
5 files changed, 756 insertions, 0 deletions
diff --git a/chapter10/chapter10.xml b/chapter10/chapter10.xml new file mode 100644 index 000000000..d7236b21c --- /dev/null +++ b/chapter10/chapter10.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<chapter id="chapter-bootable" xreflabel="Chapter 10"> + <?dbhtml dir="chapter10"?> + <?dbhtml filename="chapter10.html"?> + + <title>Making the LFS System Bootable</title> + + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="fstab.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernel.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="grub.xml"/> + +</chapter> diff --git a/chapter10/fstab.xml b/chapter10/fstab.xml new file mode 100644 index 000000000..ebfae3aaf --- /dev/null +++ b/chapter10/fstab.xml @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 id="ch-bootable-fstab"> + <?dbhtml filename="fstab.html"?> + + <title>Creating the /etc/fstab File</title> + + <indexterm zone="ch-bootable-fstab"> + <primary sortas="e-/etc/fstab">/etc/fstab</primary> + </indexterm> + + <para>The <filename>/etc/fstab</filename> file is used by some programs to + determine where file systems are to be mounted by default, in which order, and + which must be checked (for integrity errors) prior to mounting. Create a new + file systems table like this:</para> + +<screen revision="sysv"><userinput>cat > /etc/fstab << "EOF" +<literal># Begin /etc/fstab + +# file system mount-point type options dump fsck +# order + +/dev/<replaceable><xxx></replaceable> / <replaceable><fff></replaceable> defaults 1 1 +/dev/<replaceable><yyy></replaceable> swap swap pri=1 0 0 +proc /proc proc nosuid,noexec,nodev 0 0 +sysfs /sys sysfs nosuid,noexec,nodev 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +tmpfs /run tmpfs defaults 0 0 +devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 + +# End /etc/fstab</literal> +EOF</userinput></screen> + +<screen revision="systemd"><userinput>cat > /etc/fstab << "EOF" +<literal># Begin /etc/fstab + +# file system mount-point type options dump fsck +# order + +/dev/<replaceable><xxx></replaceable> / <replaceable><fff></replaceable> defaults 1 1 +/dev/<replaceable><yyy></replaceable> swap swap pri=1 0 0 + +# End /etc/fstab</literal> +EOF</userinput></screen> + + <para>Replace <replaceable><xxx></replaceable>, + <replaceable><yyy></replaceable>, and <replaceable><fff></replaceable> + with the values appropriate for the system, for example, <filename + class="partition">sda2</filename>, <filename + class="partition">sda5</filename>, and <systemitem + class="filesystem">ext4</systemitem>. For details on the six + fields in this file, see <command>man 5 fstab</command>.</para> + + <para>Filesystems with MS-DOS or Windows origin (i.e. vfat, ntfs, smbfs, + cifs, iso9660, udf) need a special option, utf8, in order for non-ASCII + characters in file names to be interpreted properly. For non-UTF-8 locales, + the value of <option>iocharset</option> should be set to be the same as the + character set of the locale, adjusted in such a way that the kernel + understands it. This works if the relevant character set definition (found + under File systems -> Native Language Support when configuring the kernel) + has been compiled into the kernel or built as a module. However, if the + character set of the locale is UTF-8, the corresponding option + <option>iocharset=utf8</option> would make the file system case sensitive. To + fix this, use the special option <option>utf8</option> instead of + <option>iocharset=utf8</option>, for UTF-8 locales. The + <quote>codepage</quote> option is also needed for vfat and smbfs filesystems. + It should be set to the codepage number used under MS-DOS in your country. + For example, in order to mount USB flash drives, a ru_RU.KOI8-R user would + need the following in the options portion of its mount line in + <filename>/etc/fstab</filename>:</para> + +<screen><literal>noauto,user,quiet,showexec,codepage=866,iocharset=koi8r</literal></screen> + + <para>The corresponding options fragment for ru_RU.UTF-8 users is:</para> + +<screen><literal>noauto,user,quiet,showexec,codepage=866,utf8</literal></screen> + + <para>Note that using <option>iocharset</option> is the default for + <literal>iso8859-1</literal> (which keeps the file system case + insensitive), and the <option>utf8</option> option tells + the kernel to convert the file names using UTF-8 so they can be + interpreted in the UTF-8 locale.</para> + + <!--note> + <para>In the latter case, the kernel emits the following message:</para> + +<screen><computeroutput>FAT: utf8 is not a recommended IO charset for FAT filesystems, + filesystem will be case sensitive!</computeroutput></screen> + + <para>This negative recommendation should be ignored, since all other values + of the <quote>iocharset</quote> option result in wrong display of filenames in + UTF-8 locales.</para> + </note--> + + <para>It is also possible to specify default codepage and iocharset values for + some filesystems during kernel configuration. The relevant parameters + are named + <quote>Default NLS Option</quote> (<option>CONFIG_NLS_DEFAULT)</option>, + <quote>Default Remote NLS Option</quote> (<option>CONFIG_SMB_NLS_DEFAULT</option>), + <quote>Default codepage for FAT</quote> (<option>CONFIG_FAT_DEFAULT_CODEPAGE</option>), and + <quote>Default iocharset for FAT</quote> (<option>CONFIG_FAT_DEFAULT_IOCHARSET</option>). + There is no way to specify these settings for the + ntfs filesystem at kernel compilation time.</para> + + <para>It is possible to make the ext3 filesystem reliable across power + failures for some hard disk types. To do this, add the + <option>barrier=1</option> mount option to the appropriate entry in + <filename>/etc/fstab</filename>. To check if the disk drive supports + this option, run + <ulink url="&blfs-book;general/hdparm.html">hdparm</ulink> + on the applicable disk drive. For example, if:</para> + +<screen role="nodump"><userinput>hdparm -I /dev/sda | grep NCQ</userinput></screen> + + <para>returns non-empty output, the option is supported.</para> + + <para>Note: Logical Volume Management (LVM) based partitions cannot use the + <option>barrier</option> option.</para> + +</sect1> diff --git a/chapter10/grub.xml b/chapter10/grub.xml new file mode 100644 index 000000000..d6897d5e5 --- /dev/null +++ b/chapter10/grub.xml @@ -0,0 +1,191 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 id="ch-bootable-grub" role="wrap"> + <?dbhtml filename="grub.html"?> + + <sect1info condition="script"> + <productname>grub</productname> + <productnumber>&grub-version;</productnumber> + <address>&grub-url;</address> + </sect1info> + + <title>Using GRUB to Set Up the Boot Process</title> + + <sect2> + <title>Introduction</title> + + <warning><para>Configuring GRUB incorrectly can render your system + inoperable without an alternate boot device such as a CD-ROM. This + section is not required to boot your LFS system. You may just + want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or + LILO.</para></warning> + + + <para> Ensure that an emergency boot disk is ready to <quote>rescue</quote> + the computer if the computer becomes unusable (un-bootable). If you do not + already have a boot device, you can create one. In order for the procedure + below to work, you need to jump ahead to BLFS and install + <userinput>xorriso</userinput> from the <ulink + url="&blfs-book;multimedia/libisoburn.html"> + libisoburn</ulink> package.</para> + +<screen role="nodump"><userinput>cd /tmp +grub-mkrescue --output=grub-img.iso +xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></screen> + + <note> + <para> + To boot LFS on host systems that have UEFI enabled, the kernel needs to + have been built with the CONFIG_EFI_STUB capabality described in the + previous section. However, LFS can be booted using GRUB2 without such + an addition. To do this, the UEFI Mode and Secure Boot capabilities in + the host system's BIOS need to be turned off. For details, see <ulink + url="&hints-root;lfs-uefi.txt"> + the lfs-uefi.txt hint</ulink> at + &hints-root;lfs-uefi.txt. + </para> + </note> + + </sect2> + + <sect2> + <title>GRUB Naming Conventions</title> + + <para>GRUB uses its own naming structure for drives and partitions in + the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis> + is the hard drive number and <emphasis>m</emphasis> is the partition + number. The hard drive number starts from zero, but the partition number + starts from one for normal partitions and five for extended partitions. + Note that this is different from earlier versions where + both numbers started from zero. For example, partition <filename + class="partition">sda1</filename> is <emphasis>(hd0,1)</emphasis> to + GRUB and <filename class="partition">sdb3</filename> is + <emphasis>(hd1,3)</emphasis>. In contrast to Linux, GRUB does not + consider CD-ROM drives to be hard drives. For example, if using a CD + on <filename class="partition">hdb</filename> and a second hard drive + on <filename class="partition">hdc</filename>, that second hard drive + would still be <emphasis>(hd1)</emphasis>.</para> + + </sect2> + + <sect2> + <title>Setting Up the Configuration</title> + + <para>GRUB works by writing data to the first physical track of the + hard disk. This area is not part of any file system. The programs + there access GRUB modules in the boot partition. The default location + is /boot/grub/.</para> + + <para>The location of the boot partition is a choice of the user that + affects the configuration. One recommendation is to have a separate small + (suggested size is 100 MB) partition just for boot information. That way + each build, whether LFS or some commercial distro, can access the same boot + files and access can be made from any booted system. If you choose to do + this, you will need to mount the separate partition, move all files in the + current <filename class="directory">/boot</filename> directory (e.g. the + linux kernel you just built in the previous section) to the new partition. + You will then need to unmount the partition and remount it as <filename + class="directory">/boot</filename>. If you do this, be sure to update + <filename>/etc/fstab</filename>.</para> + + <para>Using the current lfs partition will also work, but configuration + for multiple systems is more difficult.</para> + + <para>Using the above information, determine the appropriate + designator for the root partition (or boot partition, if a separate + one is used). For the following example, it is assumed that the root + (or separate boot) partition is <filename + class="partition">sda2</filename>.</para> + + <para>Install the GRUB files into <filename + class="directory">/boot/grub</filename> and set up the boot track:</para> + + <warning> + <para>The following command will overwrite the current boot loader. Do not + run the command if this is not desired, for example, if using a third party + boot manager to manage the Master Boot Record (MBR).</para> + </warning> + +<screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen> + + <note> + <para>If the system has been booted using UEFI, + <command>grub-install</command> will try to install files for the + <emphasis>x86_64-efi</emphasis> target, but those files + have not been installed in chapter 6. If this is the case, add + <option>--target i386-pc</option> to the command above.</para> + </note> + +<!-- This does not seem to be true any more + <note><para><application>grub-install</application> is a script and calls another + program, grub-probe, that may fail with a message "cannot stat `/dev/root'". + If so, create a temporary symbolic link from your root partition to /dev/root:</para> + +<screen role="nodump"><userinput>ln -sv /dev/sda2 /dev/root</userinput></screen> + + <para>The symbolic link will only be present until the system is rebooted. + The link is only needed for the installation procedure. + </para></note> +--> + </sect2> + + <sect2 id="grub-cfg"> + <title>Creating the GRUB Configuration File</title> + + <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para> + + <screen revision="sysv"><userinput>cat > /boot/grub/grub.cfg << "EOF" +<literal># Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod ext2 +set root=(hd0,2) + +menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" { + linux /boot/vmlinuz-&linux-version;-lfs-&version; root=/dev/sda2 ro +}</literal> +EOF</userinput></screen> + + <screen revision="systemd"><userinput>cat > /boot/grub/grub.cfg << "EOF" +<literal># Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod ext2 +set root=(hd0,2) + +menuentry "GNU/Linux, Linux &linux-version;-lfs-&versiond;" { + linux /boot/vmlinuz-&linux-version;-lfs-&versiond; root=/dev/sda2 ro +}</literal> +EOF</userinput></screen> + + + <note><para>From <application>GRUB</application>'s perspective, the + kernel files are relative to the partition used. If you + used a separate /boot partition, remove /boot from the above + <emphasis>linux</emphasis> line. You will also need to change the + <emphasis>set root</emphasis> line to point to the boot partition. + </para></note> + + <para>GRUB is an extremely powerful program and it provides a tremendous + number of options for booting from a wide variety of devices, operating + systems, and partition types. There are also many options for customization + such as graphical splash screens, playing sounds, mouse input, etc. The + details of these options are beyond the scope of this introduction.</para> + + <caution><para>There is a command, <application>grub-mkconfig</application>, that + can write a configuration file automatically. It uses a set of scripts in + /etc/grub.d/ and will destroy any customizations that you make. These scripts + are designed primarily for non-source distributions and are not recommended for + LFS. If you install a commercial Linux distribution, there is a good chance + that this program will be run. Be sure to back up your grub.cfg file.</para></caution> + + </sect2> + +</sect1> diff --git a/chapter10/introduction.xml b/chapter10/introduction.xml new file mode 100644 index 000000000..5cb40b882 --- /dev/null +++ b/chapter10/introduction.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 id="ch-bootable-introduction"> + <?dbhtml filename="introduction.html"?> + + <title>Introduction</title> + + <para>It is time to make the LFS system bootable. This chapter + discusses creating an <filename>fstab</filename> file, building a + kernel for the new LFS system, and installing the GRUB boot loader so + that the LFS system can be selected for booting at startup.</para> + +</sect1> diff --git a/chapter10/kernel.xml b/chapter10/kernel.xml new file mode 100644 index 000000000..0033028cf --- /dev/null +++ b/chapter10/kernel.xml @@ -0,0 +1,403 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 id="ch-bootable-kernel" role="wrap"> + <?dbhtml filename="kernel.html"?> + + <sect1info condition="script"> + <productname>kernel</productname> + <productnumber>&linux-version;</productnumber> + <address>&linux-url;</address> + </sect1info> + + <title>Linux-&linux-version;</title> + + <indexterm zone="ch-bootable-kernel"> + <primary sortas="a-Linux">Linux</primary> + </indexterm> + + <sect2 role="package"> + <title/> + + <para>The Linux package contains the Linux kernel.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&linux-ch8-sbu;</seg> + <seg>&linux-ch8-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of the kernel</title> + + <para>Building the kernel involves a few steps—configuration, + compilation, and installation. Read the <filename>README</filename> file + in the kernel source tree for alternative methods to the way this book + configures the kernel.</para> + + <para>Prepare for compilation by running the following command:</para> + +<screen><userinput remap="pre">make mrproper</userinput></screen> + + <para>This ensures that the kernel tree is absolutely clean. The + kernel team recommends that this command be issued prior to each + kernel compilation. Do not rely on the source tree being clean after + un-tarring.</para> + + <!-- Support for compiling a keymap into the kernel is deliberately removed --> + + <para>Configure the kernel via a menu-driven interface. For general + information on kernel configuration see <ulink + url="&hints-root;kernel-configuration.txt"/>. BLFS has some information + regarding particular kernel configuration requirements of packages outside + of LFS at <ulink + url="&blfs-book;longindex.html#kernel-config-index"/>. Additional + information about configuring and building the kernel can be found at + <ulink url="http://www.kroah.com/lkn/"/> </para> + + <note> + + <para>A good starting place for setting up the kernel configuration is to + run <command>make defconfig</command>. This will set the base + configuration to a good state that takes your current system architecture + into account.</para> + + <para>Be sure to enable/disable/set the following features or the system might + not work correctly or boot at all:</para> + + <screen role="nodump" revision="sysv"> +Device Drivers ---> + Generic Driver Options ---> + [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] + [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] + +Kernel hacking ---> + Choose kernel unwinder (Frame pointer unwinder) ---> [CONFIG_UNWINDER_FRAME_POINTER]</screen> + + <screen role="nodump" revision="systemd"> +General setup --> + [*] Control Group support [CONFIG_CGROUPS] + [ ] Enable deprecated sysfs features to support old userspace tools [CONFIG_SYSFS_DEPRECATED] + [*] Configure standard kernel features (expert users) [CONFIG_EXPERT] ---> + [*] open by fhandle syscalls [CONFIG_FHANDLE] + [ ] Auditing support [CONFIG_AUDIT] +Processor type and features ---> + [*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP] +Firmware Drivers ---> + [*] Export DMI identification via sysfs to userspace [CONFIG_DMIID] +Networking support ---> + Networking options ---> + <*> The IPv6 protocol [CONFIG_IPV6] +Device Drivers ---> + Generic Driver Options ---> + [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] + [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] + Firmware Loader ---> + [ ] Enable the firmware sysfs fallback mechanism [CONFIG_FW_LOADER_USER_HELPER] +File systems ---> + [*] Inotify support for userspace [CONFIG_INOTIFY_USER] + <*> Kernel automounter support (supports v3, v4, and v5) [CONFIG_AUTOFS_FS] + Pseudo filesystems ---> + [*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL] + [*] Tmpfs extended attributes [CONFIG_TMPFS_XATTR]</screen> + </note> + + <note revision="systemd"> + <para>While "The IPv6 Protocol" is not strictly + required, it is highly recommended by the systemd developers.</para> + </note> + + <para revision="sysv">There are several other options that may be desired + depending on the requirements for the system. For a list of options needed + for BLFS packages, see the <ulink + url="&lfs-root;blfs/view/&short-version;/longindex.html#kernel-config-index">BLFS + Index of Kernel Settings</ulink> + (&lfs-root;blfs/view/&short-version;/longindex.html#kernel-config-index).</para> + + <note> + <para>If your host hardware is using UEFI, then the 'make defconfig' + above should automatically add in some EFI-related kernel options.</para> + + <para>In order to allow your LFS kernel to be booted from within your + host's UEFI boot environment, your kernel must have this option + selected:</para> + +<screen role="nodump">Processor type and features ---> + [*] EFI stub support [CONFIG_EFI_STUB]</screen> + + <para>A fuller description of managing UEFI environments from within LFS + is covered by the lfs-uefi.txt hint at + <ulink + url="&hints-root;lfs-uefi.txt"/>. + </para> + </note> + + <variablelist> + <title>The rationale for the above configuration items:</title> + + <varlistentry> + <term><parameter>Support for uevent helper</parameter></term> + <listitem> + <para>Having this option set may interfere with device + management when using Udev/Eudev. </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><parameter>Maintain a devtmpfs</parameter></term> + <listitem> + <para>This will create automated device nodes which are populated by the + kernel, even without Udev running. Udev then runs on top of this, + managing permissions and adding symlinks. This configuration + item is required for all users of Udev/Eudev.</para> + </listitem> + </varlistentry> + + </variablelist> + +<screen role="nodump"><userinput>make menuconfig</userinput></screen> + + <variablelist> + <title>The meaning of optional make environment variables:</title> + + <varlistentry> + <term><parameter>LANG=<host_LANG_value> LC_ALL=</parameter></term> + <listitem> + <para>This establishes the locale setting to the one used on the + host. This may be needed for a proper menuconfig ncurses interface + line drawing on a UTF-8 linux text console.</para> + + <para>If used, be sure to replace + <replaceable><host_LANG_value></replaceable> by the value of + the <envar>$LANG</envar> variable from your host. You can + alternatively use instead the host's value of <envar>$LC_ALL</envar> + or <envar>$LC_CTYPE</envar>.</para> + </listitem> + </varlistentry> + + </variablelist> + + <para>Alternatively, <command>make oldconfig</command> may be more + appropriate in some situations. See the <filename>README</filename> + file for more information.</para> + + <para>If desired, skip kernel configuration by copying the kernel + config file, <filename>.config</filename>, from the host system + (assuming it is available) to the unpacked <filename + class="directory">linux-&linux-version;</filename> directory. However, + we do not recommend this option. It is often better to explore all the + configuration menus and create the kernel configuration from + scratch.</para> + + <para>Compile the kernel image and modules:</para> + +<screen><userinput remap="make">make</userinput></screen> + + <para>If using kernel modules, module configuration in <filename + class="directory">/etc/modprobe.d</filename> may be required. + Information pertaining to modules and kernel configuration is + located in <xref linkend="ch-config-udev"/> and in the kernel + documentation in the <filename + class="directory">linux-&linux-version;/Documentation</filename> directory. + Also, <filename>modprobe.d(5)</filename> may be of interest.</para> + + <para>Unless module support has been disabled in the kernel configuration, + install the modules with:</para> + +<screen><userinput remap="install">make modules_install</userinput></screen> + + <para>After kernel compilation is complete, additional steps are + required to complete the installation. Some files need to be copied to + the <filename class="directory">/boot</filename> directory.</para> + + <caution> + <para>If the host system has a separate /boot partition, the files copied + below should go there. The easiest way to do that is to bind /boot on the + host (outside chroot) to /mnt/lfs/boot before proceeding. As the root + user in the <emphasis>host system</emphasis>:</para> + +<screen role="nodump"><userinput>mount --bind /boot /mnt/lfs/boot</userinput></screen> + </caution> + + <para>The path to the kernel image may vary depending on the platform being + used. The filename below can be changed to suit your taste, but the stem of + the filename should be <emphasis>vmlinuz</emphasis> to be compatible with + the automatic setup of the boot process described in the next section. The + following command assumes an x86 architecture:</para> + +<screen revision="sysv"><userinput remap="install">cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&version;</userinput></screen> + +<screen revision="systemd"><userinput remap="install">cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&versiond;</userinput></screen> + + <para><filename>System.map</filename> is a symbol file for the kernel. + It maps the function entry points of every function in the kernel API, + as well as the addresses of the kernel data structures for the running + kernel. It is used as a resource when investigating kernel problems. + Issue the following command to install the map file:</para> + +<screen><userinput remap="install">cp -iv System.map /boot/System.map-&linux-version;</userinput></screen> + + <para>The kernel configuration file <filename>.config</filename> + produced by the <command>make menuconfig</command> step + above contains all the configuration selections for the kernel + that was just compiled. It is a good idea to keep this file for future + reference:</para> + +<screen><userinput remap="install">cp -iv .config /boot/config-&linux-version;</userinput></screen> + + <para>Install the documentation for the Linux kernel:</para> + +<screen><userinput remap="install">install -d /usr/share/doc/linux-&linux-version; +cp -r Documentation/* /usr/share/doc/linux-&linux-version;</userinput></screen> + + <para>It is important to note that the files in the kernel source + directory are not owned by <emphasis>root</emphasis>. Whenever a + package is unpacked as user <emphasis>root</emphasis> (like we did + inside chroot), the files have the user and group IDs of whatever + they were on the packager's computer. This is usually not a problem + for any other package to be installed because the source tree is + removed after the installation. However, the Linux source tree is + often retained for a long time. Because of this, there is a chance + that whatever user ID the packager used will be assigned to somebody + on the machine. That person would then have write access to the kernel + source.</para> + + <note> + <para>In many cases, the configuration of the kernel will need to be + updated for packages that will be installed later in BLFS. Unlike + other packages, it is not necessary to remove the kernel source tree + after the newly built kernel is installed.</para> + + <para>If the kernel source tree is going to be retained, run + <command>chown -R 0:0</command> on the <filename + class="directory">linux-&linux-version;</filename> directory to ensure + all files are owned by user <emphasis>root</emphasis>.</para> + </note> + + <warning> + <para>Some kernel documentation recommends creating a symlink from + <filename class="symlink">/usr/src/linux</filename> pointing to the kernel + source directory. This is specific to kernels prior to the 2.6 series and + <emphasis>must not</emphasis> be created on an LFS system as it can cause + problems for packages you may wish to build once your base LFS system is + complete.</para> + </warning> + + <warning> + <para>The headers in the system's <filename + class="directory">include</filename> directory (<filename + class="directory">/usr/include</filename>) should + <emphasis>always</emphasis> be the ones against which Glibc was compiled, + that is, the sanitised headers installed in <xref + linkend="ch-tools-linux-headers"/>. Therefore, they should + <emphasis>never</emphasis> be replaced by either the raw kernel headers + or any other kernel sanitized headers.</para> + </warning> + + </sect2> + + <sect2 id="conf-modprobe" role="configuration"> + <title>Configuring Linux Module Load Order</title> + + <indexterm zone="conf-modprobe"> + <primary sortas="e-/etc/modprobe.d/usb.conf">/etc/modprobe.d/usb.conf</primary> + </indexterm> + + <para>Most of the time Linux modules are loaded automatically, but + sometimes it needs some specific direction. The program that loads + modules, <command>modprobe</command> or <command>insmod</command>, uses + <filename>/etc/modprobe.d/usb.conf</filename> for this purpose. This file + needs to be created so that if the USB drivers (ehci_hcd, ohci_hcd and + uhci_hcd) have been built as modules, they will be loaded in the correct + order; ehci_hcd needs to be loaded prior to ohci_hcd and uhci_hcd in order + to avoid a warning being output at boot time.</para> + + <para>Create a new file <filename>/etc/modprobe.d/usb.conf</filename> by running + the following:</para> + +<screen><userinput>install -v -m755 -d /etc/modprobe.d +cat > /etc/modprobe.d/usb.conf << "EOF" +<literal># Begin /etc/modprobe.d/usb.conf + +install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true +install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true + +# End /etc/modprobe.d/usb.conf</literal> +EOF</userinput></screen> + + </sect2> + + <sect2 id="contents-kernel" role="content"> + <title>Contents of Linux</title> + + <segmentedlist> + <segtitle>Installed files</segtitle> + <segtitle>Installed directories</segtitle> + + <seglistitem> + <seg>config-&linux-version;, + <phrase revision="sysv">vmlinuz-&linux-version;-lfs-&version;,</phrase> + <phrase revision="systemd">vmlinuz-&linux-version;-lfs-&versiond;,</phrase> + and System.map-&linux-version;</seg> + <seg>/lib/modules, /usr/share/doc/linux-&linux-version;</seg> + </seglistitem> + </segmentedlist> + + <variablelist> + <bridgehead renderas="sect3">Short Descriptions</bridgehead> + <?dbfo list-presentation="list"?> + <?dbhtml list-presentation="table"?> + + <varlistentry id="config"> + <term><filename>config-&linux-version;</filename></term> + <listitem> + <para>Contains all the configuration selections for the kernel</para> + <indexterm zone="ch-bootable-kernel config"> + <primary sortas="e-/boot/config">/boot/config-&linux-version;</primary> + </indexterm> + </listitem> + </varlistentry> + + <varlistentry id="lfskernel"> + <term revision="sysv"><filename>vmlinuz-&linux-version;-lfs-&version;</filename></term> + <term revision="systemd"><filename>vmlinuz-&linux-version;-lfs-&versiond;</filename></term> + <listitem> + <para>The engine of the Linux system. When turning on the computer, + the kernel is the first part of the operating system that gets loaded. + It detects and initializes all components of the computer's hardware, + then makes these components available as a tree of files to the + software and turns a single CPU into a multitasking machine capable + of running scores of programs seemingly at the same time</para> + <indexterm zone="ch-bootable-kernel lfskernel"> + <primary sortas="b-lfskernel">lfskernel-&linux-version;</primary> + </indexterm> + </listitem> + </varlistentry> + + <varlistentry id="System.map"> + <term><filename>System.map-&linux-version;</filename></term> + <listitem> + <para>A list of addresses and symbols; it maps the entry points and + addresses of all the functions and data structures in the + kernel</para> + <indexterm zone="ch-bootable-kernel System.map"> + <primary sortas="e-/boot/System.map">/boot/System.map-&linux-version;</primary> + </indexterm> + </listitem> + </varlistentry> + + </variablelist> + + </sect2> + +</sect1> |