lfs(systemd版本)学习笔记-第4页
lfs(systemd版本)学习笔记-第3页 的地址:https://www.cnblogs.com/renren-study-notes/p/10385857.html
第7.2章节
网络配置
1.网络设备命名
cat > /etc/systemd/network/-ether0.link << "EOF"
[Match]
# Change the MAC address as appropriate for your network device
MACAddress=:::::AB(更改为网卡的mac号,在主机使用ifconfig查看) [Link]
Name=ether0(更改为网卡的名字,在主机使用ifconfig查看)
EOF
2.静态ip配置
cat > /etc/systemd/network/-eth-static.network << "EOF"
[Match]
Name=<network-device-name> [Network]
Address=192.168.0.2/
Gateway=192.168.0.1
DNS=192.168.0.1(使用静态/etc/resolv.conf文件,这个选项可以去掉)
Domains=<Your Domain Name>
EOF
3.dhcp配置
cat > /etc/systemd/network/-eth-dhcp.network << "EOF"
[Match]
Name=<network-device-name> [Network]
DHCP=ipv4 [DHCP]
UseDomains=true
EOF
4.systemd-resolved配置
ln -sfv /run/systemd/resolve/resolv.conf /etc/resolv.conf
5.静态resolv.conf配置
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf domain <Your Domain Name>
nameserver 8.8.8.8
nameserver 8.8.4.4
# End /etc/resolv.conf
EOF
6.配置主机名字
echo "<lfs>" > /etc/hostname <lfs>更换为主机名字
7.创建/etc/hosts文件
(1)使用dhcp自动分配
cat > /etc/hosts << "EOF"
# Begin /etc/hosts 127.0.0.1 localhost
127.0.1.1 <FQDN> <HOSTNAME>
<192.168.1.1> <FQDN> <HOSTNAME> [alias1] [alias2 ...]
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters # End /etc/hosts
EOF
(2)使用静态地址
cat > /etc/hosts << "EOF"
# Begin /etc/hosts 127.0.0.1 localhost
127.0.1.1 <FQDN> <HOSTNAME>
<192.168.0.2> <FQDN> <HOSTNAME> [alias1] [alias2] ...
:: localhost ip6-localhost ip6-loopback
ff02:: ip6-allnodes
ff02:: ip6-allrouters # End /etc/hosts
EOF
第7.5章节
如果电脑上面是多系统,并且有windows系统,就不要使用系统硬件时间作为系统时间(会有时差)。如果没有windows系统不需要更改。具体内容参见:我的linux时间综述笔记地址:https://www.cnblogs.com/renren-study-notes/p/10229743.html
硬件时间设置为本地时间
cat > /etc/adjtime << "EOF"
0.0 0.0 LOCAL
EOF
第7.7章节
配置语言环境
运行以下命令获取Glibc支持的所有语言环境的列表:
locale -a
结果:
C
en_US.utf8
POSIX
zh_CN.utf8
这里我们选择en_US.utf8
以下是对对所选择的语言的测试
LC_ALL=<locale name> locale charmap LC_ALL=<locale name> locale language
LC_ALL=<locale name> locale charmap
LC_ALL=<locale name> locale int_curr_symbol
LC_ALL=<locale name> locale int_prefix
确定正确的区域设置后,创建 /etc/profile文件:
cat > /etc/locale.conf << "EOF"
LANG=en_US.utf8
EOF
第7.8章节
1.创建/etc/inputrc配置文件
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
第7.9章节
1.创建/etc/shells文件
cat > /etc/shells << "EOF"
# Begin /etc/shells /bin/sh
/bin/bash # End /etc/shells
EOF
第7.10章节
1.引导时禁用屏幕清除
mkdir -pv /etc/systemd/system/getty@tty1.service.d cat > /etc/systemd/system/getty@tty1.service.d/noclear.conf << EOF
[Service]
TTYVTDisallocate=no
EOF
2.禁用/ tmp的tmpfs
ln -sfv /dev/null /etc/systemd/system/tmp.mount
第8.2章节
1.更改为lfs所创建的分区到相应位置即可(这个文件是配置lfs开机自动挂载的分区)
cat > /etc/fstab << "EOF"
# Begin /etc/fstab # file system mount-point type options dump fsck
# order /dev/<xxx>/<fff>defaults 1 1
/dev/<yyy>swap swap pri=1 0 0 # End /etc/fstab
EOF
第8.3章节
配置编译安装linux内核
1.首先进入sources目录
cd /sources
2.解压内核文件压缩包
tar -xvf linux-4.20.12.tar.xz
3.进入内核包目录
cd linux-4.20.12
4.准备编译
make mrproper
5.设置默认内核配置状态
make defconfig
6.设置内核也可以通过修改.config文件来进行设置
make menuconfig
7.设置书中提供的以下选项
General setup -->
[ ] Enable deprecated sysfs features to support old userspace tools [CONFIG_SYSFS_DEPRECATED]
[ ] Enable deprecated sysfs features by default [CONFIG_SYSFS_DEPRECATED_V2]
[*] open by fhandle syscalls [CONFIG_FHANDLE]
[ ] Auditing support [CONFIG_AUDIT]
[*] Control Group support [CONFIG_CGROUPS]
Processor type and features --->
[*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP]
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]
[ ] Fallback user-helper invocation for firmware loading [CONFIG_FW_LOADER_USER_HELPER]
Firmware Drivers --->
[*] Export DMI identification via sysfs to userspace [CONFIG_DMIID]
File systems --->
[*] Inotify support for userspace [CONFIG_INOTIFY_USER]
<*> Kernel automounter version support (also supports v3) [CONFIG_AUTOFS4_FS]
Pseudo filesystems --->
[*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL]
[*] Tmpfs extended attributes [CONFIG_TMPFS_XATTR]
Kernel hacking --->
Choose kernel unwinder (Frame pointer unwinder) ---> [CONFIG_UNWINDER_FRAME_POINTER]
8.如果您的主机硬件使用UEFI,请自行添加此项设置
Processor type and features --->
[*] EFI stub support [CONFIG_EFI_STUB]
9.设置调整完保存退出即可
10.编译内核映像和模块
make -j8
11.安装配置模块
make modules_install
12.复制一些内核的启动文件到boot分区
cp -iv arch/x86/boot/bzImage /boot/vmlinuz-4.20.12-lfs-8.4-systemd cp -iv System.map /boot/System.map-4.20.12 cp -iv .config /boot/config-4.20.12
13.安装Linux内核的文档:
install -d /usr/share/doc/linux-4.20.12
cp -r Documentation/* /usr/share/doc/linux-4.20.12
14.配置linux模块加载顺序
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
15.返回sources目录并删除包目录
cd $LFS/sources rm -rf linux-4.20.12
第8.4章节
安装配置grub引导
1.安装grub引导到MBR
grub-install /dev/sda
2.创建grub配置文件
cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5 insmod ext2
set root=(hd0,2) 括号里面更改为你所安装lfs的分区或boot分区 例如/dev/sda2为(hd0,2) menuentry "GNU/Linux, Linux 4.18.5-lfs-8.3" {
linux /boot/vmlinuz-4.18.5-lfs-8.3 root=/dev/sda2 ro(这里的/dev/sda2更改为你所安装lfs的分区号 例如/dev/sda2)
} (如果boot单独分区,则把这里的/boot删除。)
EOF
多系统引导文件示例:
cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5 menuentry "GNU/Linux, Linux 4.18.5-lfs-8.3" {
insmod ext2
set root=(hd0,5)
linux /vmlinuz-4.18.5-lfs-8.3 root=/dev/sda6 ro
}
menuentry 'Manjaro Linux'{
insmod ext2
set root='hd0,msdos9'
linux /vmlinuz-4.19-x86_64 root=/dev/sda10 ro
initrd /intel-ucode.img /initramfs-4.19-x86_64.img
}
menuentry 'Windows 7 (on /dev/sda1)'{
insmod ntfs
set root='hd0,msdos1'
chainloader +1
}
EOF
第9.1章节
设置系统版本及版本号
cat > /etc/os-release << "EOF"
NAME="Linux From Scratch"
VERSION="8.4-systemd"
ID=lfs
PRETTY_NAME="Linux From Scratch 8.4-systemd"
VERSION_CODENAME="<your name here>"(括号里改为自己起的名字)
EOF echo 8.3-systemd > /etc/lfs-release cat > /etc/lsb-release << "EOF"
DISTRIB_ID="Linux From Scratch"
DISTRIB_RELEASE="8.4-systemd"
DISTRIB_CODENAME="<your name here>"(括号里改为自己起的名字)
DISTRIB_DESCRIPTION="Linux From Scratch"
EOF
第9.3章节
运行下面的命令,退出chroot,卸载lfs的分区
exit umount -v $LFS/dev/pts
umount -v $LFS/dev
umount -v $LFS/run
umount -v $LFS/proc
umount -v $LFS/sys umount -v $LFS umount -v $LFS/usr
umount -v $LFS/home
umount -v $LFS
重启进入lfs系统
reboot
附录
如果需要本机的grub引导lfs则在root用户下运行以下命令创建lfs的引导项
需要安装os-prober软件包,并挂载lfs的分区,在运行下面命令,添加lfs的启动项
grub-mkconfig -o /boot/grub/grub.cfg
确定添加完lfs引导项后,重启机器进入lfs选项,即可进入lfs操作系统。
lfs(systemd版本)学习笔记-第4页的更多相关文章
- lfs(systemd版本)学习笔记-第3页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemd)学习笔记-第2页 的地址:https://www.cnblogs.com/renren-study-no ...
- lfs(systemd版本)学习笔记-第2页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemd)学习笔记-第1页 的地址:https://www.cnblogs.com/renren-study-no ...
- lfs(systemd版本)学习笔记-第1页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 一名linux爱好者,记录构建Linux From Scratch的过程 经博客园-骏马金龙前辈介绍,开始接触学习lfs,用博客 ...
- lfs(systemv版本)学习笔记-第1页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 一名linux爱好者,记录构建Linux From Scratch的过程 经博客园-骏马金龙前辈介绍,开始接触学习lfs,用博客 ...
- lfs(systemv版本)学习笔记-第4页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemv版本)学习笔记第3页:https://www.cnblogs.com/renren-study-notes ...
- lfs(systemv版本)学习笔记-第3页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemv版本)学习笔记-第2页的地址:https://www.cnblogs.com/renren-study-n ...
- lfs(systemv版本)学习笔记-第2页
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemv)学习笔记-第1页 的地址:https://www.cnblogs.com/renren-study-no ...
- 关于Angular.js Routing 的学习笔记(实现单页应用)
最近开始学习angular.js,发现angular.js确实很方便,也很强大.在看到 AngularJS Routing and Multiple Views 这一部分的时候,有点乱.现在通过记录一 ...
- react-router 4.0版本学习笔记
Router 所有路由组件的底层接口,一般情况都不使用,而是使用更加高级的路由. 最常用的有两种<BrowserRouter>.<HashRouter> <Browser ...
随机推荐
- Vuejs——(3)计算属性,样式和类绑定
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 先上总结: (十九)标签和API总结(2) vm指new Vue获取的实例 ①当dom标签里的值 ...
- open:在终端打开文件|应用程序等
1. 需求&解决方案 打开文件 或url(用默认应用程序): $ open fileName 打开文件 或url(用指定应用程序): $ open -a appName fileName ## ...
- vscode调试angular
之前在Asp.net MVC + Angular1 的项目中,要调试前台代码都是用浏览器的开发者工具,使用正常,也没有感觉太大的不方便. 后来接触Angular2项目,因为它是要经过编译的,所以在浏览 ...
- 请教:WCF速度似乎比Remoting慢
两段极为相似的代码,主要想看看过输与序列化过程两者的用时差异,结果10000次的调用,WCF用了11秒多,remoting用了5秒不到!这是测试的源代码 Remoting的服务端 public cla ...
- Django 通过 mongoengine 连接 MongoDB 进而使用orm进行CRUD
一. 在python脚本中, 我们通常可以使用pymongo模块实现与mongodb数据库的交互, 但是在使用Django框架进行定制开发的web server 项目中, 仍然使用pymongo模块的 ...
- Scala微服务架构 二
三. Scala的Macro(宏) Scala Macros对scala函数库编程人员来说是一项不可或缺的编程工具,可以通过它来解决一些用普通编程或者类层次编程(type level programm ...
- Tomcat 在 Linux 上的安装和配置
一.文件上传 先上传tomcat安装文件到Linux服务器 二.解压安装 使用以下命令解压安装包 .tar.gz 解压成功会生成一个文件夹 tomcat服务器运行时是需要JDK支持的,所以必须先安装好 ...
- [Mac]macOS Mojave :发现 Mac 的新功能。
1.深色模式 换种颜色看 Mac “深色模式”为桌面和内建应用带来更生动的外观,可让您轻松专注于最重要的内容. 若要在浅色和深色外观之间切换,请打开“系统偏好设置”并点按“通用”. 2.叠放 整理桌面 ...
- SQL Server性能优化(12)非聚集索引的组合索引存储结构
一,非聚集索引组合索引 用户可以在多个列上建立索引,这种索引叫做复合索引(组合索引).但复合索引在数据库操作期间所需的开销更小,可以代替多个单一索引.当表的行数远远大于索引键的数目时,使用这种方式可以 ...
- mybatis随笔五之Executor
在上一篇文章我们分析到了mapper接口方法的实现实际上是交由代理类来实现的,并最终调用Executor来查询,接下来我们对executor.query(ms, wrapCollection(para ...