LFS 10.0 零基础中文安装教程 超详细 (四)

                                   第四章  配置系统让系统可以启动

1、LFS-引导脚本

cd /sources
tar xvf lfs-bootscripts-20200818.tar.xz
cd lfs-bootscripts-20200818
make install
cd ..
rm -rf lfs-bootscripts-20200818

2、 创建自定义 udev 规则:

bash /lib/udev/init-net-rules.sh
cat /etc/udev/rules.d/70-persistent-net.rules

3、创建网络配置文件:

cd /etc/sysconfig/
cat > ifconfig.enp0s3 << "EOF"
ONBOOT=yes
IFACE=enp0s3
SERVICE=ipv4-static
IP=192.168.3.27
GATEWAY=192.168.3.1
PREFIX=24
BROADCAST=192.168.3.255
EOF

这里按照自己实际配置网络文件。就是第一章时,告诉大记住的网卡名,IP地址等。
4、创建/etc/resolv.conf文件:

cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf

domain mylfs10.0
nameserver 192.168.3.1

# End /etc/resolv.conf
EOF

5、配置系统主机名称:

echo "lfs10.0"  > /etc/hostname

6、创建 /etc/hosts 文件:

cat > /etc/hosts << "EOF"
# Begin /etc/hosts

127.0.0.1 localhost
192.168.3.20 lfs10.0 

# End /etc/hosts
EOF

7、创建 /etc/inittab 文件:

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:S016:once:/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

8、创建 /etc/sysconfig/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

9、配置控制台语言环境、创建 /etc/profile 文件:

cat > /etc/locale.conf << "EOF"

LANG=en_US.UTF-8

EOF

cat > /etc/profile << "EOF"
# Begin /etc/profile

export LANG=en_US.UTF-8

# End /etc/profile
EOF

10、创建/ etc / inputrc文件:

cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <[email protected]>

# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off

# Enable 8bit 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

11、创建/ etc / shells文件

cat > /etc/shells << "EOF"
# Begin /etc/shells

/bin/sh
/bin/bash

# End /etc/shells
EOF

12、创建 /etc/fstab 文件:

cat > /etc/fstab << "EOF"
# Begin /etc/fstab

# file system  mount-point  type     options             dump  fsck
#                                                              order

/dev/sda2     /            ext4    defaults            1     1
/dev/sda1     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
EOF

这里需要将<XXX>(系统的启动盘)、<yyy>(系统的交换分区)、<fff>(启动盘的分区格式)更改下。

13、配置、编译和安装linux5.8.3内核:

cd /sources
tar xvf linux-5.8.3.tar.xz
cd linux-5.8.3
make mrproper
make defconfig
make menuconfig

确保以下几项选择:

Device Drivers  --->
  Generic Driver Options  --->
   [ ] Support for uevent helper [CONFIG_UEVENT_HELPER]
   [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS]
Processor type and features  --->
   [*]   EFI stub support  [CONFIG_EFI_STUB]
General setup -->
   [*] Control Group support [CONFIG_CGROUPS]

配置好后,保存退出。
编译内核映像和模块并安装:

make
make modules_install

移动内核镜像到 /boot (x86体系结构):

cp -iv arch/x86/boot/bzImage /boot/vmlinuz-5.8.3-lfs-10.0

内核的符号文件:

cp -iv System.map /boot/System.map-5.8.3

安装Linux内核的文档:

install -d /usr/share/doc/linux-5.8.3
cp -r Documentation/* /usr/share/doc/linux-5.8.3

创建 /etc/modprobe.d/usb.conf 文件:

install -v -m755 -d /etc/modprobe.d
cat > /etc/modprobe.d/usb.conf << "EOF"
# 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
EOF

14、设置GRUB启动过程
将 GRUB 文件安装到 /boot/grub 并设置启动扇区:

grub-install /dev/sda

创建 /boot/grub/grub.cfg 文件:

cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,2)

menuentry "GNU/Linux, Linux 5.8.3-lfs-10.0" {
        linux   /boot/vmlinuz-5.8.3-lfs-10.0 root=/dev/sda2 ro
}
EOF

15、创建 /etc/lfs-release 文件:

echo 10.0 > /etc/lfs-release

16、创建 /etc/lsb-release 文件:

cat > /etc/lsb-release << "EOF"
DISTRIB_ID="Linux From Scratch"
DISTRIB_RELEASE="10.0"
DISTRIB_CODENAME="<your name here>"
DISTRIB_DESCRIPTION="Linux From Scratch"
EOF

17、创建 /etc/os-release 文件:

cat > /etc/os-release << "EOF"
NAME="Linux From Scratch"
VERSION="10.0"
ID=lfs
PRETTY_NAME="Linux From Scratch 10.0"
VERSION_CODENAME="<your name here>"
EOF

18、最后一步,重新启动系统
退出chroot环境:

logout

卸载虚拟文件系统:

umount -v $LFS/dev/pts
umount -v $LFS/dev
umount -v $LFS/run
umount -v $LFS/proc
umount -v $LFS/sys

卸载主分区:

umount -v $LFS

重新引导系统:

shutdown -r now

LFS 10.0 零基础中文安装教程  超详细 (四)

下一步,Blfs奋斗!
不足之处望大家批评指正!
谢谢大家观看~!~

猜你喜欢

转载自blog.51cto.com/9828355/2601755