目录
  1. 1. LFS系统构建04-系统配置
    1. 1.1. 引导linux的步骤
    2. 1.2. lfs-bootscripts
    3. 1.3. 创建自定义udev规则
    4. 1.4. 网络配置
    5. 1.5. 引导脚本的配置和使用
    6. 1.6. bash的启动文件
    7. 1.7. 创建inputrc文件
    8. 1.8. 创建shells文件
LFS系统构建04-系统配置

LFS系统构建04-系统配置

引导linux的步骤

  1. 挂载虚拟文件系统和真实文件系统
  2. 初始化设备
  3. 激活交换分区
  4. 检查文件系统
  5. 挂载交换分区或文件
  6. 设置系统时钟
  7. 启动网络
  8. 开启系统需要的守护进程
  9. 一些用户需要的自定义工作

lfs-bootscripts

1
2
3
4
cd $LFS/sources
tar -jxvf lfs-bootscripts-20180820.tar.bz2
cd lfs-bootscripts-20180820
make install

创建自定义udev规则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bash /lib/udev/init-net-rules.sh
cat /etc/udev/rules.d/70-persistent-net.rules
udevadm test /sys/block/hdd
sed -i -e 's/"write_cd_rules"/"write_cd_rules mode"/' /etc/udev/rules.d/83-cdrom-symlinks.rules

#处理多个设备
udevadm info -a -p /sys/class/video4linux/video0

cat > /etc/udev/rules.d/83-duplicate_devs.rules << "EOF"
# Persistent symlinks for webcam and tuner
KERNEL=="video*", ATTRS{idProduct}=="1910", ATTRS{idVendor}=="0d81", \
SYMLINK+="webcam"
KERNEL=="video*", ATTRS{device}=="0x036f", ATTRS{vendor}=="0x109e", \
SYMLINK+="tvtuner"
EOF
cd $LFS/sources

网络配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
cd /etc/sysconfig/

cat > ifconfig.eth0 << "EOF"
ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
EOF


cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
domain <Your Domain Name>
nameserver <IP address of your primary nameserver>
nameserver <IP address of your secondary nameserver>
# End /etc/resolv.conf
EOF

#设置主机名
echo "rack-leen" > /etc/hostname

#
cat > /etc/hosts << "EOF"
# Begin /etc/hosts
127.0.0.1 localhost
# End /etc/hosts
EOF

引导脚本的配置和使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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

#设置系统时间
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

#配置终端
cat > /etc/sysconfig/console << "EOF"
# Begin /etc/sysconfig/console
UNICODE="1"
KEYMAP="bg_bds-utf8"
FONT="LatArCyrHeb-16"
# End /etc/sysconfig/console
EOF

bash的启动文件

1
2
3
4
5
6
7
8
9
10
#设置字符集
LC_ALL=en_US.utf-8 locale charmap


#### bash的配置文件
cat > /etc/profile << "EOF"
# Begin /etc/profile
export LANG=<ll>_<CC>.<charmap><@modifiers>
# End /etc/profile
EOF

创建inputrc文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 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

创建shells文件

1
2
3
4
5
6
cat > /etc/shells << "EOF"
# Begin /etc/shells
/bin/sh
/bin/bash
# End /etc/shells
EOF
文章作者: rack-leen
文章链接: http://yoursite.com/2019/06/07/LFS/LFS%E7%B3%BB%E7%BB%9F%E6%9E%84%E5%BB%BA04-%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 rack-leen's blog
打赏
  • 微信
  • 支付宝

评论