引导 Linux 系统涉及多项任务。该进程必须挂载虚拟和真实文件系统,初始化设备,激活交换,检查文件系统的完整性,挂载任何交换分区或文件,设置系统时钟,启动网络,启动系统所需的任何守护进程,并完成任何用户需要的其他自定义任务。必须组织此过程以确保以正确的顺序执行任务,但同时尽可能快地执行。
第9节 系统配置
system V
System V 是自 1983 年左右开始在 Unix 和类 Unix 系统(如 Linux)中使用的经典引导过程。它由一个小程序init 组成,它设置诸如登录(通过 getty)之类的基本程序并运行一个脚本. 该脚本通常名为rc,它控制一组附加脚本的执行,这些脚本执行初始化系统所需的任务。
该初始化程序是由控制/etc/inittab文件,并整理成可以由用户运行的运行级别:
1 2 3 4 5 6 7
0 — halt 1 — Single user mode 2 — Multiuser, without networking 3 — Full multiuser mode 4 — User definable 5 — Full multiuser mode with display manager 6 — reboot
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
创建 /etc/shells 文件
1 2 3 4 5 6 7 8
cat > /etc/shells << "EOF" # Begin /etc/shells
/bin/sh /bin/bash # End /etc/shells EOF
创建Bash Shell启动文件
1 2 3 4 5 6 7 8
cat > /etc/profile << "EOF" # Begin /etc/profile export LANG=zh_CN.UTF-8 export INPUTRC=/etc/inputrc alias ls="ls --color" export PS1='\u:\w\$ ' # End /etc/profile EOF
第10节 使LFS系统可引导
创建/etc/fstab文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
cat > /etc/fstab << "EOF" # Begin /etc/fstab # file system mount-point type options dump fsck # order
Device Drivers ---> Generic Driver Options ---> [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS]
General setup --> [ ] Auditing Support [CONFIG_AUDIT] [*] Control Group support [CONFIG_CGROUPS] [ ] Enable deprecated sysfs features to support old userspace tools [CONFIG_SYSFS_DEPRECATED] [*] Configure standard kernel features (expert users) [CONFIG_EXPERT] ---> [*] open by fhandle syscalls [CONFIG_FHANDLE] Processor type and features ---> [*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP]????? Firmware Drivers ---> [*] Export DMI identification via sysfs to userspace [CONFIG_DMIID] Networking support ---> Networking options ---> <*> The IPv6 protocol [CONFIG_IPV6] Device Drivers ---> Generic Driver Options ---> [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] Firmware Loader ---> [ ] Enable the firmware sysfs fallback mechanism [CONFIG_FW_LOADER_USER_HELPER] File systems ---> [*] Inotify support for userspace [CONFIG_INOTIFY_USER] Pseudo filesystems ---> [*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL]