Into chapter 10, updating notes.
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
# Chapter 10 - Making the System Bootable
|
||||||
|
## Sections 10.1 - Introduction
|
||||||
|
So close, just need to ...
|
||||||
|
- [ ] Create `/etc/fstab`
|
||||||
|
- [ ] Build our Kernel
|
||||||
|
- [ ] Install GRUB
|
||||||
|
## Section 10.2 - F-Stab!
|
||||||
|
We need to create our table of filesystems for the kernel.
|
||||||
|
```
|
||||||
|
cat > /etc/fstab << "EOF"
|
||||||
|
# Begin /etc/fstab
|
||||||
|
|
||||||
|
# file system mount-point type options dump fsck
|
||||||
|
# order
|
||||||
|
|
||||||
|
/dev/sdb2 swap swap pri=1 0 0
|
||||||
|
/dev/sdb3 / ext4 defaults 1 1
|
||||||
|
/dev/sdb4 /home ext4 defaults 1 2
|
||||||
|
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
|
||||||
|
tmpfs /dev/shm tmpfs nosuid,nodev 0 0
|
||||||
|
cgroup2 /sys/fs/cgroup cgroup2 nosuid,noexec,nodev 0 0
|
||||||
|
|
||||||
|
# End /etc/fstab
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
## Section 10.3 - Building the Linux Kernel
|
||||||
|
We finally get to build the kernel!
|
||||||
|
```
|
||||||
|
make mrproper
|
||||||
|
make menuconfig
|
||||||
|
```
|
||||||
|
Follow the selections in LFS book, the exit and save the configuration.
|
||||||
|
Then we can compile the kernel,
|
||||||
|
```
|
||||||
|
make
|
||||||
|
```
|
||||||
|
and install any kernel moduels,
|
||||||
|
```
|
||||||
|
make modules_install
|
||||||
|
```
|
||||||
|
Then move the freshly built kernel image to the boot partition,
|
||||||
|
```
|
||||||
|
cp -iv arch/x86/boot/bzImage /boot/vmlinuz-6.10.5-lfs-12.2
|
||||||
|
```
|
||||||
|
and bring its symbols map file,
|
||||||
|
```
|
||||||
|
cp -iv System.map /boot/System.map-6.10.5
|
||||||
|
```
|
||||||
|
and might as well include the kernel configuration file too,
|
||||||
|
```
|
||||||
|
cp -iv .config /boot/config-6.10.5
|
||||||
|
```
|
||||||
|
then install the kernel's documentation.
|
||||||
|
```
|
||||||
|
cp -r Documentation -T /usr/share/doc/linux-6.10.5
|
||||||
|
```
|
||||||
|
## Section 10.4 - Using GRUB and its Configuration
|
||||||
|
We need to install grub on our hard drive device. In this case, I have been working on separate hard drive device presented to the VM. The first ~500MB of that device was left unformatted to be available for GRUB.
|
||||||
|
```
|
||||||
|
grub-install /dev/sdb
|
||||||
|
```
|
||||||
|
and then create its config file,
|
||||||
|
```
|
||||||
|
cat > /boot/grub/grub.cfg << "EOF"
|
||||||
|
# Begin /boot/grub/grub.cfg
|
||||||
|
set default=0
|
||||||
|
set timeout=5
|
||||||
|
|
||||||
|
insmod part_gpt
|
||||||
|
insmod ext2
|
||||||
|
set root=(hd0,3)
|
||||||
|
|
||||||
|
menuentry "GNU/Linux, Linux 6.10.5-lfs-12.2" {
|
||||||
|
linux /boot/vmlinuz-6.10.5-lfs-12.2 root=/dev/sda3 ro
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Chapter 9 - System Configuration
|
|
||||||
## Sections 9.1
|
|
||||||
|
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
# Chapter 9 - System Configuration
|
||||||
|
## Sections 9.1 - System V Init
|
||||||
|
This section describes the system init that LFS, the tasks it makes to complete the boot process, and various run levels.
|
||||||
|
## Section 9.2 - LFS Init Scripts
|
||||||
|
LFS comes with some pre-configured scripts that work with this init process at boot time.
|
||||||
|
> Installed scripts:
|
||||||
|
> checkfs, cleanfs, console, functions, halt, ifdown, ifup, localnet, modules, mountfs, mountvirtfs, network, rc, reboot, sendsignals, setclock, ipv4-static, swap, sysctl, sysklogd, template, udev, and udev_retry
|
||||||
|
> Installed directories:
|
||||||
|
> /etc/rc.d, /etc/init.d (symbolic link), /etc/sysconfig, /lib/services, /lib/lsb (symbolic link)
|
||||||
|
This has its own sources, and is installed with `make`.
|
||||||
|
```
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
## Section 9.3 - Device and Kernel Modules
|
||||||
|
Just light reading ...
|
||||||
|
## Section 9.4 - Setting Up for Devices
|
||||||
|
Create rules for naming network devices.
|
||||||
|
```
|
||||||
|
bash /usr/lib/udev/init-net-rules.sh
|
||||||
|
```
|
||||||
|
## Section 9.5 - General Network Configuration
|
||||||
|
We need to setup the anticipated network interface.
|
||||||
|
```
|
||||||
|
cd /etc/sysconfig/
|
||||||
|
cat > ifconfig.eth0 << "EOF"
|
||||||
|
ONBOOT=yes
|
||||||
|
IFACE=eth0
|
||||||
|
SERVICE=ipv4-static
|
||||||
|
IP=192.168.2.250
|
||||||
|
GATEWAY=192.168.2.1
|
||||||
|
PREFIX=24
|
||||||
|
BROADCAST=192.168.2.255
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
Create our `resolve.conf` file,
|
||||||
|
```
|
||||||
|
cat > /etc/resolv.conf << "EOF"
|
||||||
|
# Begin /etc/resolv.conf
|
||||||
|
|
||||||
|
domain home.lan
|
||||||
|
nameserver 192.168.2.22
|
||||||
|
nameserver 192.168.2.1
|
||||||
|
|
||||||
|
# End /etc/resolv.conf
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
our hostname,
|
||||||
|
```
|
||||||
|
echo lfs > /etc/hostname
|
||||||
|
```
|
||||||
|
and also our `hosts` file,
|
||||||
|
```
|
||||||
|
cat > /etc/hosts << "EOF"
|
||||||
|
# Begin /etc/hosts
|
||||||
|
|
||||||
|
127.0.0.1 localhost.localdomain localhost
|
||||||
|
127.0.1.1 lfs.home.lan lfs
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
|
|
||||||
|
# End /etc/hosts
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
## Section 9.6 - Bootscript Usage and Configuration
|
||||||
|
We need to configure SysVinit
|
||||||
|
```
|
||||||
|
cat > /etc/inittab << "EOF"
|
||||||
|
# Begin /etc/inittab
|
||||||
|
|
||||||
|
id:3:initdefault:
|
||||||
|
|
||||||
|
si::sysinit:/etc/rc.d/init.d/rc S
|
||||||
|
|
||||||
|
l0:0:wait:/etc/rc.d/init.d/rc 0
|
||||||
|
l1:S1:wait:/etc/rc.d/init.d/rc 1
|
||||||
|
l2:2:wait:/etc/rc.d/init.d/rc 2
|
||||||
|
l3:3:wait:/etc/rc.d/init.d/rc 3
|
||||||
|
l4:4:wait:/etc/rc.d/init.d/rc 4
|
||||||
|
l5:5:wait:/etc/rc.d/init.d/rc 5
|
||||||
|
l6:6:wait:/etc/rc.d/init.d/rc 6
|
||||||
|
|
||||||
|
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
|
||||||
|
|
||||||
|
su:S06:once:/sbin/sulogin
|
||||||
|
s1:1:respawn:/sbin/sulogin
|
||||||
|
|
||||||
|
1:2345:respawn:/sbin/agetty --noclear tty1 9600
|
||||||
|
2:2345:respawn:/sbin/agetty tty2 9600
|
||||||
|
3:2345:respawn:/sbin/agetty tty3 9600
|
||||||
|
4:2345:respawn:/sbin/agetty tty4 9600
|
||||||
|
5:2345:respawn:/sbin/agetty tty5 9600
|
||||||
|
6:2345:respawn:/sbin/agetty tty6 9600
|
||||||
|
|
||||||
|
# End /etc/inittab
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
setting the system clock,
|
||||||
|
```
|
||||||
|
cat > /etc/sysconfig/clock << "EOF"
|
||||||
|
# Begin /etc/sysconfig/clock
|
||||||
|
|
||||||
|
UTC=1
|
||||||
|
|
||||||
|
# Set this to any options you might need to give to hwclock,
|
||||||
|
# such as machine hardware clock type for Alphas.
|
||||||
|
CLOCKPARAMS=
|
||||||
|
|
||||||
|
# End /etc/sysconfig/clock
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
and configuring the console.
|
||||||
|
```
|
||||||
|
cat > /etc/sysconfig/console << "EOF"
|
||||||
|
# Begin /etc/sysconfig/console
|
||||||
|
|
||||||
|
UNICODE="1"
|
||||||
|
FONT="Lat2-Terminus16"
|
||||||
|
|
||||||
|
# End /etc/sysconfig/console
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
## Section 9.7 - Configuring Locale
|
||||||
|
This locale stuff seems really annoying .. but it's necessary. These commands use glibc to determine locale information.
|
||||||
|
```
|
||||||
|
LC_ALL=en_US locale language
|
||||||
|
LC_ALL=en_US locale charmap
|
||||||
|
LC_ALL=en_US locale int_curr_symbol
|
||||||
|
LC_ALL=en_US locale int_prefix
|
||||||
|
```
|
||||||
|
Which can be used in our bash profile,
|
||||||
|
```
|
||||||
|
cat > /etc/profile << "EOF"
|
||||||
|
# Begin /etc/profile
|
||||||
|
|
||||||
|
for i in $(locale); do
|
||||||
|
unset ${i%=*}
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$TERM" = linux ]]; then
|
||||||
|
export LANG=C.UTF-8
|
||||||
|
else
|
||||||
|
export LANG=en_US.ISO-8859-1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# End /etc/profile
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
## Section 9.8 - Readline's `etc/inputrc/ File
|
||||||
|
This file is needed to support shells, such as `bash`, interpret keyboard input.
|
||||||
|
```
|
||||||
|
cat > /etc/inputrc << "EOF"
|
||||||
|
# Begin /etc/inputrc
|
||||||
|
# Modified by Chris Lynn <roryo@roryo.dynup.net>
|
||||||
|
|
||||||
|
# Allow the command prompt to wrap to the next line
|
||||||
|
set horizontal-scroll-mode Off
|
||||||
|
|
||||||
|
# Enable 8-bit input
|
||||||
|
set meta-flag On
|
||||||
|
set input-meta On
|
||||||
|
|
||||||
|
# Turns off 8th bit stripping
|
||||||
|
set convert-meta Off
|
||||||
|
|
||||||
|
# Keep the 8th bit for display
|
||||||
|
set output-meta On
|
||||||
|
|
||||||
|
# none, visible or audible
|
||||||
|
set bell-style none
|
||||||
|
|
||||||
|
# All of the following map the escape sequence of the value
|
||||||
|
# contained in the 1st argument to the readline specific functions
|
||||||
|
"\eOd": backward-word
|
||||||
|
"\eOc": forward-word
|
||||||
|
|
||||||
|
# for linux console
|
||||||
|
"\e[1~": beginning-of-line
|
||||||
|
"\e[4~": end-of-line
|
||||||
|
"\e[5~": beginning-of-history
|
||||||
|
"\e[6~": end-of-history
|
||||||
|
"\e[3~": delete-char
|
||||||
|
"\e[2~": quoted-insert
|
||||||
|
|
||||||
|
# for xterm
|
||||||
|
"\eOH": beginning-of-line
|
||||||
|
"\eOF": end-of-line
|
||||||
|
|
||||||
|
# for Konsole
|
||||||
|
"\e[H": beginning-of-line
|
||||||
|
"\e[F": end-of-line
|
||||||
|
|
||||||
|
# End /etc/inputrc
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
## Seciton 9.9 - Set Options for Shells
|
||||||
|
This shells available on the system must be identified.
|
||||||
|
```
|
||||||
|
cat > /etc/shells << "EOF"
|
||||||
|
# Begin /etc/shells
|
||||||
|
|
||||||
|
/bin/sh
|
||||||
|
/bin/bash
|
||||||
|
|
||||||
|
# End /etc/shells
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
22
lfs-scripts/bootscripts.sh
Normal file
22
lfs-scripts/bootscripts.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Set the package we're building.
|
||||||
|
package="lfs-bootscripts-20240825"
|
||||||
|
extension=".tar.xz"
|
||||||
|
|
||||||
|
# Decompress the source.
|
||||||
|
echo "Unpacking ${package}${extension} ..."
|
||||||
|
tar xvf ${package}${extension}
|
||||||
|
|
||||||
|
# Enter the unpacked sources.
|
||||||
|
echo "Entering ${package} directory ..."
|
||||||
|
cd ${package}
|
||||||
|
|
||||||
|
# LFS commands.
|
||||||
|
make install
|
||||||
|
|
||||||
|
# Exit sources directory.
|
||||||
|
echo "Exiting ${package} directory ..."
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Remove the directory of source files.
|
||||||
|
echo "Removing ${package} directory ..."
|
||||||
|
rm -rf ${package}
|
||||||
Reference in New Issue
Block a user