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奮鬥!
不足之處望大家批評指正!
謝謝大家觀看~!~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章