[20549cb0] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-bootable-temp" role="wrap">
|
---|
| 9 | <?dbhtml filename="grub-cfg.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info condition="script">
|
---|
| 12 | <productname>grub</productname>
|
---|
| 13 | <productnumber>&grub-version;</productnumber>
|
---|
| 14 | <address>&grub-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
| 17 | <title>Making the Temporary System Bootable</title>
|
---|
| 18 |
|
---|
| 19 | <sect2>
|
---|
| 20 | <title>Introduction</title>
|
---|
| 21 |
|
---|
| 22 | <para>In a normal LFS building procedure, we will chroot into the
|
---|
| 23 | temporary system and continue to build additional temporary tools.
|
---|
| 24 | But, as we've explained, in the Cross Edition we need to make the
|
---|
| 25 | temporary system bootable and boot it on the target system.</para>
|
---|
| 26 | </sect2>
|
---|
| 27 |
|
---|
| 28 | <sect2>
|
---|
| 29 | <title>Creating the GRUB Configuration File</title>
|
---|
| 30 |
|
---|
| 31 | <para>Generate <filename>$LFS/boot/grub/grub.cfg</filename>:</para>
|
---|
| 32 |
|
---|
[b2ae446] | 33 | <screen><userinput>mkdir -pv $LFS/boot/grub
|
---|
| 34 | cat > $LFS/boot/grub/grub.cfg << "EOF"
|
---|
[20549cb0] | 35 | <literal># Begin /boot/grub/grub.cfg
|
---|
| 36 | set default=0
|
---|
| 37 | set timeout=5
|
---|
| 38 |
|
---|
| 39 | menuentry "LFS Temporary System" {
|
---|
[388ffda4] | 40 | linux /vmlinuz root=/dev/sda3 rw init=/bin/bash
|
---|
[20549cb0] | 41 | boot
|
---|
| 42 | }</literal>
|
---|
| 43 | EOF</userinput></screen>
|
---|
| 44 |
|
---|
| 45 | <variablelist>
|
---|
| 46 | <title>The meaning of the linux command options:</title>
|
---|
| 47 |
|
---|
| 48 | <varlistentry>
|
---|
| 49 | <term><parameter>root=/dev/sda3</parameter></term>
|
---|
| 50 | <listitem>
|
---|
| 51 | <para>We will use the third parition as the partition for the
|
---|
| 52 | root filesystem of the LFS system.</para>
|
---|
| 53 | </listitem>
|
---|
| 54 | </varlistentry>
|
---|
| 55 |
|
---|
| 56 | <varlistentry>
|
---|
| 57 | <term><parameter>rw</parameter></term>
|
---|
| 58 | <listitem>
|
---|
| 59 | <para>Tell the kernel to mount the root filesystem read-write.
|
---|
| 60 | In normal distros there is <parameter>ro</parameter> instead, so
|
---|
| 61 | the kernel will mount the root filesystem read-only. Then
|
---|
| 62 | the <command>init</command> process can check the filesystem
|
---|
| 63 | integrity and remount it read-write. For the temporary system
|
---|
| 64 | it's not needed.</para>
|
---|
| 65 | </listitem>
|
---|
| 66 | </varlistentry>
|
---|
| 67 |
|
---|
| 68 | <varlistentry>
|
---|
| 69 | <term><parameter>init=/bin/bash</parameter></term>
|
---|
| 70 | <listitem>
|
---|
| 71 | <para>By default the kernel runs <command>/sbin/init</command>
|
---|
| 72 | as the first process. It's provided by SysVinit or Systemd
|
---|
| 73 | package, which is not installed yet. We explicitly tell the
|
---|
| 74 | kernel to run <command>/bin/bash</command> instead to start a
|
---|
| 75 | shell, so we can run further commands interactively.</para>
|
---|
| 76 | </listitem>
|
---|
| 77 | </varlistentry>
|
---|
| 78 |
|
---|
| 79 | <varlistentry>
|
---|
| 80 | <term>(optional) <parameter>console=ttyS0,115200</parameter></term>
|
---|
| 81 | <listitem>
|
---|
| 82 | <para>Use the serial port at <filename>/dev/ttyS0</filename> as
|
---|
| 83 | the output console device. It's very useful if the virtual
|
---|
| 84 | console is not avaliable (for example, the target system may lack
|
---|
| 85 | graphic output, or the framebuffer console may be too slow).
|
---|
| 86 | And, by connecting the host system and the target system with a
|
---|
| 87 | NULL modem or USB serial converter, it will be able to copy the
|
---|
| 88 | commands from the book and paste it into a terminal emulator
|
---|
| 89 | (for example,
|
---|
| 90 | <ulink url='&blfs-book;general/screen.html'>GNU Screen</ulink>)
|
---|
| 91 | on the host, to execute them on the target system.
|
---|
| 92 | <parameter>115200</parameter> specifies the baudrate, the default
|
---|
| 93 | (9600) is too slow for large amount of console output building
|
---|
| 94 | LFS.</para>
|
---|
| 95 | </listitem>
|
---|
| 96 | </varlistentry>
|
---|
| 97 | </variablelist>
|
---|
| 98 |
|
---|
| 99 | <note><para>From <application>GRUB</application>'s perspective, the
|
---|
| 100 | kernel files are relative to the partition used. We will use a
|
---|
| 101 | a separate /boot partition, so /boot is not needed in the above
|
---|
| 102 | <emphasis>linux</emphasis> line.
|
---|
| 103 | </para></note>
|
---|
| 104 |
|
---|
| 105 | </sect2>
|
---|
| 106 |
|
---|
| 107 | <sect2>
|
---|
| 108 | <title>Copy the Temporary System to the Target Machine</title>
|
---|
| 109 |
|
---|
| 110 | <note>
|
---|
| 111 | <para>The commands in the subsection must be performed on the host
|
---|
| 112 | system while logged in as user
|
---|
| 113 | <systemitem class="username">root</systemitem>
|
---|
| 114 | and no longer as user <systemitem class="username">lfs</systemitem>.
|
---|
| 115 | Also, double check that <envar>$LFS</envar> is set in <systemitem
|
---|
| 116 | class="username">root</systemitem>'s environment.</para>
|
---|
| 117 | </note>
|
---|
| 118 |
|
---|
| 119 | <para>Now it's the time to copy the
|
---|
| 120 | <filename class="directory">$LFS</filename> hierarchy over to your
|
---|
| 121 | target machine. You'll need a <quote>moveable</quote> device for this.
|
---|
| 122 | Using a normal USB stick is likely a bad choice: the USB sticks are
|
---|
| 123 | generally not optimized for reading or writing many small files
|
---|
| 124 | (which will happen building packages from source). Especially, if a
|
---|
| 125 | ext filesystem is used, the performance can be very bad. You may use
|
---|
| 126 | a USB to SATA adapter and a HDD or SSD (then you can directly connect
|
---|
| 127 | it onto the SATA port of the target system, or continuing to use the
|
---|
| 128 | adapter on a USB port of the target system), or a USB stick with an I/O
|
---|
| 129 | controller for SSD (these USB sticks are significantly more expansive
|
---|
| 130 | than a normal one).</para>
|
---|
| 131 |
|
---|
| 132 | <para>Create a GUID partition table on the device, and then create
|
---|
| 133 | three partitions on it. The first will be used as the BIOS boot
|
---|
| 134 | partition, 1 MB is sufficient enough. But if you want to use EFI to
|
---|
| 135 | boot your LFS system later, assign 100 MB for it so it will be possible
|
---|
| 136 | to convert it into an EFI system partition. The second partition will
|
---|
| 137 | be used as the boot partition, 500 MB is sufficient enough. The third
|
---|
| 138 | will be the root partition, it should be at least 20 GB.</para>
|
---|
| 139 |
|
---|
| 140 | <para>Create filesystems for the partitions:</para>
|
---|
| 141 |
|
---|
| 142 | <screen><userinput role='nodump'>mkfs.ext4 /dev/<replaceable>sdx</replaceable>2
|
---|
| 143 | mkfs.ext4 /dev/<replaceable>sdx</replaceable>3</userinput></screen>
|
---|
| 144 |
|
---|
| 145 | <para>
|
---|
| 146 | It's not needed to create a filesystem for the BIOS boot partition.
|
---|
| 147 | But, its type should be set to <quote>BIOS boot</quote> in
|
---|
| 148 | the partition table using <command>fdisk</command>:
|
---|
| 149 | </para>
|
---|
| 150 |
|
---|
| 151 | <screen role="nodump"><userinput>fdisk /dev/<replaceable>sdx</replaceable></userinput>
|
---|
| 152 | <literal>
|
---|
| 153 | Welcome to fdisk (util-linux &util-linux-version;).
|
---|
| 154 | Changes will remain in memory only, until you decide to write them.
|
---|
| 155 | Be careful before using the write command.
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 | Command (m for help): </literal><userinput>t</userinput>
|
---|
| 159 | <literal>Partition number (1-9, default 9): </literal><userinput>1</userinput>
|
---|
| 160 | <literal>Partition type or alias (type L to list all): </literal><userinput>BIOS boot</userinput>
|
---|
| 161 | <literal>Changed type of partition 'Linux' to 'BIOS boot'.
|
---|
| 162 |
|
---|
| 163 | Command (m for help): </literal><userinput>w</userinput>
|
---|
| 164 | <literal>The partition table has been altered.
|
---|
| 165 | Calling ioctl() to re-read partition table.
|
---|
| 166 | Syncing disks.</literal></screen>
|
---|
| 167 |
|
---|
[3a5d53a] | 168 | <para>In <xref linkend="ch-tools-cleanup"/> it's optional to make a
|
---|
| 169 | backup for the temporary system. If you'd like to do so, prepare
|
---|
| 170 | another parition (1 GB should be enough) and make an
|
---|
| 171 | <systemitem class="filesystem">ext4</systemitem> filesystem to hold
|
---|
| 172 | the backup:</para>
|
---|
| 173 |
|
---|
| 174 | <screen><userinput role='nodump'>mkfs.ext4 /dev/<replaceable>sdx4</replaceable></userinput></screen>
|
---|
| 175 |
|
---|
[20549cb0] | 176 | <para><replaceable>sdx</replaceable> should be replaced with the name
|
---|
| 177 | of the device node corresponding to your moveable device. Then mount
|
---|
| 178 | the filesystems:</para>
|
---|
| 179 |
|
---|
| 180 | <screen><userinput role='nodump'>mkdir -pv /mnt/lfs-target
|
---|
| 181 | mount -v -t ext4 /dev/<replaceable>sdx</replaceable>3 /mnt/lfs-target
|
---|
| 182 | mkdir -pv /mnt/lfs-target/boot
|
---|
| 183 | mount -v -t ext4 /dev/<replaceable>sdx</replaceable>2 /mnt/lfs-target/boot</userinput></screen>
|
---|
| 184 |
|
---|
| 185 | <para>Copy the temporary system onto the device, and change the
|
---|
| 186 | ownership of the copy to user
|
---|
| 187 | <systemitem class="username">root</systemitem>:</para>
|
---|
| 188 |
|
---|
| 189 | <screen><userinput role='nodump'>cp -av $LFS/* /mnt/lfs-target
|
---|
| 190 | chown -R root:root /mnt/lfs-target</userinput></screen>
|
---|
| 191 |
|
---|
| 192 | <para>Install the bootloader onto the device:</para>
|
---|
| 193 |
|
---|
| 194 | <screen><userinput role='nodump'>$LFS/tools/sbin/lfs-grub-install \
|
---|
| 195 | --target=i386-pc \
|
---|
| 196 | --boot-directory=/mnt/lfs-target/boot \
|
---|
| 197 | /dev/<replaceable>sdx</replaceable></userinput></screen>
|
---|
| 198 |
|
---|
| 199 | <para>Create the mountpoint for
|
---|
| 200 | <systemitem class="filesystem">devtmpfs</systemitem>, so the kernel
|
---|
| 201 | will mount it automatically:</para>
|
---|
| 202 |
|
---|
| 203 | <screen><userinput role='nodump'>install -v -dm755 /mnt/lfs-target/dev</userinput></screen>
|
---|
| 204 |
|
---|
| 205 | <para>Now, unmount the device:</para>
|
---|
| 206 |
|
---|
| 207 | <screen><userinput role='nodump'>umount -Rv /mnt/lfs-target</userinput></screen>
|
---|
| 208 |
|
---|
| 209 | <para>Now unplug the device and connect it onto the target system,
|
---|
| 210 | and boot the target system with this device as the boot device.
|
---|
| 211 | Read the manual from the vendor of the target system to know how to
|
---|
| 212 | select the boot device.</para>
|
---|
| 213 |
|
---|
| 214 | </sect2>
|
---|
| 215 |
|
---|
| 216 | </sect1>
|
---|