博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LFS7.10——准备Host系统
阅读量:7224 次
发布时间:2019-06-29

本文共 19982 字,大约阅读时间需要 66 分钟。

转载请标明出处: 

实验环境:

Host:Windows10 + WMWare Workstation14.1.1 build-7528167

LSB Version: :core-4.1-amd64:core-4.1-noarch

Distributor ID: CentOS

Description: CentOS Linux release 7.5.1804 (Core)

Release: 7.5.1804

Codename: Core

LFS:7.10

准备host系统

依赖工具、库

要想构建LFS系统,首先需要一个Linux发行版本事先安装好,可以选择最小化安装。这个事先安装好的Linux(称为 host)提供必要的工具:

eg:编译器(compiler,)、链接器(linker,)、shell等等

借助这些工具构建我们的LFS系统。

为了构建LFS,host需要安装必要的工具。对于LFS 7.10来说,不建议使用小于下面列出版本号的tarball。

Bash-3.2(/bin/sh应该是bash的符号链接 或 硬链接)

This package satisfies an LSB core requirement to provide a Bourne Shell interface to the system.It was chosenover other shell packages because of its common usage and extensive capabilities beyond basic shell functions.
View Code

Binutils-2.17 (不建议使用版本号小于2.30的包,因为未被测试)

This package contains a linker, an assembler, and other tools for handling object files. The programs in this package are needed to compile most of the packages in an LFS system and beyond.
View Code

Bison-2.3 (/usr/bin/yacc应该是bison的一个链接;也可以链接到一个脚本,这个脚本会执行bison)

This package contains the GNU version of yacc(Yet Another Compiler Compiler) needed to build several other LFS programs.
View Code

Bzip2-1.0.4

This package contains programs for compressing and decompressing files.It is required to decompress many LFS packages.
View Code

Coreutils-6.9

This package contains a number of essential programs for viewing and manipulating files and directories. These programs are needed for command line file management, and are necessary for the installation procedures of every package in LFS.
View Code

Diffutils-2.8.1

This package contains programs that show the differences between files or directories. These programs can be used to create patches, and are also used in many packages' build procedures.
View Code

Findutils-4.2.31

This package contains programs to find files in a file system. It is used in many packages' build scripts.
View Code

Gawk-4.0.1(/usr/bin/awk应该是gawk的一个链接)

This package contains programs for manipulating text files. It is the GNU version of awk(Aho-Weinberg-Kernighan). It is used in many other packages' build scripts.
View Code

GCC-4.7包括C++编译器(不建议使用版本号大于7.3.0,因为未被测试)

This package is the Gnu Compiler Collection.It contains the C and C++ compilers as well as several others not built by LFS.
View Code

Glibc-2.11(不建议使用版本号大于2.27,因为未被测试)

This package contains the main Clibrary.Linux programs would not run without it.
View Code

Grep-2.5.1a

This package contains programs for searching through files. These programs are used by most packages' buildscripts.
View Code

Gzip-1.3.12

This package contains programs for compressing and decompressing files. It is needed to decompress manypackages in LFS and beyond.
View Code

Linux Kernel-2.6.32(编译glibc、udev会用到)

This package is the Operating System. It is the Linux in the GNU/Linux environment
View Code

M4-1.4.10

This package contains a general text macro processor useful as a build tool for other programs
View Code

Make-3.81

This package contains a program for directing the building of packages. It is required by almost every package inLFS.
View Code

Patch-2.5.4

This package contains a program for modifying or creating files by applying a patch file typically created by thediff program. It is needed by the build procedure for several LFS packages.
View Code

Perl-5.8.8

This package is an interpreter for the runtime language PERL. It is needed for the installation and test suites ofseveral LFS packages.
View Code

Sed-4.1.5

This package allows editing of text without opening it in a text editor. It is also needed by most LFS packages'configure scripts.
View Code

Tar-1.22

This package provides archiving and extraction capabilities of virtually all packages used in LFS.
View Code

Texinfo-4.7

This package contains programs for reading, writing, and converting info pages. It is used in the installationprocedures of many LFS packages.
View Code

Xz-5.0.0

This package contains programs for compressing and decompressing files. It provides the highest compressiongenerally available and is useful for decompressing packages in XZ or LZMA format.
View Code

执行如下命令,然后运行脚本version-check.sh,根据输出安装必要工具。安装的工具版本号 ≥ 上面最低版本号。

#!/bin/bash# Simple script to list version numbers of critical development toolsexport LC_ALL=C#deal with bashbash --version | head -n1 | cut -d" " -f2-4MYSH=$(readlink -f /bin/sh)echo "/bin/sh -> $MYSH"echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"unset MYSH#deal with binutilsecho -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-#deal with bisonbison --version | head -n1#deal with yaccif [ -h /usr/bin/yacc ]; thenecho "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";elif [ -x /usr/bin/yacc ]; thenecho yacc is `/usr/bin/yacc --version | head -n1`elseecho "yacc not found"fi#deal with bzip2bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-#deal with coreutilsecho -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2#deal with diffdiff --version | head -n1#deal with findfind --version | head -n1#deal with gawkgawk --version | head -n1#deal with awkif [ -h /usr/bin/awk ]; thenecho "/usr/bin/awk -> `readlink -f /usr/bin/awk`";elif [ -x /usr/bin/awk ]; thenecho awk is `/usr/bin/awk --version | head -n1`elseecho "awk not found"fi#deal with gccgcc --version | head -n1#deal with g++g++ --version | head -n1#deal with lssldd --version | head -n1 | cut -d" " -f2- # glibc version#deal with grepgrep --version | head -n1#deal with gzipgzip --version | head -n1cat /proc/version#deal with m4m4 --version | head -n1#deal with makemake --version | head -n1#deal with patchpatch --version | head -n1#deal with perlecho Perl `perl -V:version`#deal with sedsed --version | head -n1#deal with tartar --version | head -n1#deal with makeinfomakeinfo --version | head -n1#deal with xzxz --version | head -n1#test whether gcc is OKecho 'int main(){}' > dummy.c && g++ -o dummy dummy.cif [ -x dummy ]then echo "g++ compilation OK";else echo "g++ compilation failed"; firm -f dummy.c dummy
View Code

我的实验环境下,我是根据脚本提示依次安装所需要的包。当然你也可以使用一条yum命令搞定,如下

yum -y install bash binutils bison bzip2 coreutils diffutils findutils gawk gcc glibc grep gzip kernel m4 make patch perl sed tar texinfo xz gcc-c++ flex
View Code

有几个包需要单独说下:

没有g++这个包,需要安装gcc-c++

makeinfo这个包在texinfo包里面。

安装完bison后还要将yacc链接到bison

ln -sv /usr/bin/bison /usr/bin/yacc
View Code

安装完以后再次执行包检查脚本输出如下

bash, version 4.2.46(1)-release/bin/sh -> /usr/bin/bashBinutils: version 2.25.1-22.base.el7 bison (GNU Bison) 3.0.4/usr/bin/yacc -> /usr/bin/bisonbzip2,  Version 1.0.6, 6-Sept-2010.Coreutils:  8.22diff (GNU diffutils) 3.3find (GNU findutils) 4.5.11GNU Awk 4.0.2/usr/bin/awk -> /usr/bin/gawkgcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)(GNU libc) 2.17grep (GNU grep) 2.20gzip 1.5Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016m4 (GNU M4) 1.4.16GNU Make 3.82GNU patch 2.7.1Perl version='5.16.3';sed (GNU sed) 4.2.2tar (GNU tar) 1.26makeinfo (GNU texinfo) 5.1xz (XZ Utils) 5.2.2g++ compilation OK
View Code

在检查依赖库

#!/bin/bashfor lib in lib{gmp,mpfr,mpc}.la; doecho $lib: $(if find /usr/lib* -name $lib|grep -q $lib;then :;else echo not;fi) founddoneunset lib
View Code

我的环境上输出

[root@localhost LFS]# sh library-check.sh libgmp.la: not foundlibmpfr.la: not foundlibmpc.la: not found
View Code

注:这三个库,要么全都有,要么全都没有。不可以有的有有的没有

创建分区

准备用于安装 LFS 的分区。包括建立分区、为分区设置文件系统,挂载分区。

我单独给LFS一块20G的磁盘,分区安排如下

[root@localhost ~]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xf1aba154   Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048      206847      102400   83  Linux/dev/sdb2          206848     8595455     4194304   82  Linux swap / Solaris/dev/sdb3         8595456    41943039    16673792   83  Linux
View Code
[root@localhost ~]# lsblk /dev/sdbNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 100M 0 part    #用于boot分区├─sdb2 8:18 0 4G 0 part      #用于swap分区└─sdb3 8:19 0 15.9G 0 part   #用于root分区
View Code

分区格式化

将sdb1和sdb3格式化为ext4文件系统。

mkfs -v -t ext4 /dev/sdb1;mkfs -v -t ext4 /dev/sdb3
View Code

设置swap分区,格式化/dev/sdb2为swap格式

[root@localhost ~]# mkswap /dev/sdb2Setting up swapspace version 1, size = 4194300 KiBno label, UUID=bb9ea40d-6101-4f0c-be3f-dde08974637d
View Code

启动swap分区

swapon /dev/sdb2
View Code
[root@localhost ~]# swapon -sFilename                Type        Size    Used    Priority/dev/dm-1                                  partition    4063228    0    -1/dev/sdb2                                  partition    4194300    0    -2
View Code

创建环境变量

在构建LFS的过程中,$LFS作为根分区挂载点会多次用到,应该确保在整个构建过程中$LFS都是可用的。

[root@localhost ~]# export LFS=/mnt/lfs[root@localhost ~]# echo $LFS/mnt/lfs[root@localhost ~]# mkdir -pv $LFSmkdir: created directory ‘/mnt/lfs’
View Code

在/root/.bash_profile文家最后添加export LFS=/mnt/lfs,使LFS这个环境变量永久化。最终结果如下

[root@localhost ~]# cat .bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then    . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport LFS=/mnt/lfs
View Code

检查环境变量

[root@localhost ~]# env | grep LFSLFS=/mnt/lfs
View Code

挂载新分区

分区创建好了,文件系统也指定好了。通过为分区指定一个挂载点,来使这个指定文件系统的分区变得可访问。

将sdb3挂载到$LFS变量下,sdb1挂载到$LFS/boot

[root@localhost ~]# mount -v -t ext4 /dev/sdb3 $LFSmount: /mnt/lfs does not contain SELinux labels.       You just mounted an file system that supports labels which does not       contain labels, onto an SELinux box. It is likely that confined       applications will generate AVC messages and not be allowed access to       this file system.  For more details see restorecon(8) and mount(8).mount: /dev/sdb3 mounted on /mnt/lfs.[root@localhost ~]# mkdir -pv $LFS/bootmkdir: created directory ‘/mnt/lfs/boot’[root@localhost ~]#  mount -v -t ext4  /dev/sdb1 $LFS/bootmount: /mnt/lfs/boot does not contain SELinux labels.       You just mounted an file system that supports labels which does not       contain labels, onto an SELinux box. It is likely that confined       applications will generate AVC messages and not be allowed access to       this file system.  For more details see restorecon(8) and mount(8).mount: /dev/sdb1 mounted on /mnt/lfs/boot.
View Code
[root@localhost ~]# lsblk /dev/sdb -fNAME   FSTYPE LABEL UUID                                 MOUNTPOINTsdb                                                      ├─sdb1 ext4         1bd2b5b6-a818-42f5-bc54-145327b832ab /mnt/lfs/boot├─sdb2 swap         bb9ea40d-6101-4f0c-be3f-dde08974637d [SWAP]└─sdb3 ext4         7f28d393-1ede-4f33-b97d-f8defe148c2e /mnt/lfs
View Code

为确保下次重启后挂载点仍可用,需要编辑/etc/fstab。swap分区不用修改fstab,他连挂载点都没有,怎么修改呢??  

[root@localhost ~]# cat /etc/fstab ## /etc/fstab# Created by anaconda on Fri Oct  5 17:14:12 2018## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/centos-root /                       xfs     defaults        0 0UUID=783b3030-8ead-4ad3-99d9-5ee1403779f0 /boot                   xfs     defaults        0 0/dev/mapper/centos-home /home                   xfs     defaults        0 0/dev/mapper/centos-swap swap                    swap    defaults        0 0/dev/sdb1              /mnt/lfs/boot            ext4    defaults        0 0/dev/sdb2              swap                     swap    defaults        0 0/dev/sdb3              /mnt/lfs                 ext4    defaults        0 0
View Code

重启检查配置好的Host

[root@localhost ~]# swapon -sFilename                Type        Size    Used    Priority/dev/sdb2                                  partition    4194300    0    -1/dev/dm-1                                  partition    4063228    0    -2[root@localhost ~]# mount | grep sdb -i | column -t/dev/sdb3  on  /mnt/lfs       type  ext4  (rw,relatime,seclabel,data=ordered)/dev/sdb1  on  /mnt/lfs/boot  type  ext4  (rw,relatime,seclabel,data=ordered)[root@localhost ~]# env | grep lfs -iLFS=/mnt/lfs
View Code

由于swap分区没有挂载点,因此在mount下看不着。

下载包和补丁

包和补丁存放在$LFS/sources目录下

创建sources目录

mkdir -v $LFS/sources
View Code

修改权限(使sources目录仅能被owner和root删除)

[root@localhost ~]# ll $LFStotal 21drwxr-xr-x. 3 root root  1024 Dec 17 21:32 bootdrwx------. 2 root root 16384 Dec 17 21:32 lost+founddrwxr-xr-x. 2 root root  4096 Dec 17 22:14 sources[root@localhost ~]# chmod -v a+wt $LFS/sourcesmode of ‘/mnt/lfs/sources’ changed from 0755 (rwxr-xr-x) to 1777 (rwxrwxrwt)[root@localhost ~]# ll $LFStotal 21drwxr-xr-x. 3 root root  1024 Dec 17 21:32 bootdrwx------. 2 root root 16384 Dec 17 21:32 lost+founddrwxrwxrwt. 2 root root  4096 Dec 17 22:14 sources
View Code

下载wget-list文件,这里面包含各种包的链接。千万注意你的LFS版本,下面找你对应版本的wget-list文件。由于官方的wget-list部分链接失效,我修改了部分连接

https://download-mirror.savannah.gnu.org/releases/acl/acl-2.2.52.src.tar.gzhttps://download-mirror.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gzhttp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xzhttp://ftp.gnu.org/gnu/automake/automake-1.15.tar.xzhttp://ftp.gnu.org/gnu/bash/bash-4.3.30.tar.gzhttp://alpha.gnu.org/gnu/bc/bc-1.06.95.tar.bz2http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.xzhttp://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gzhttp://sourceforge.net/projects/check/files/check/0.10.0/check-0.10.0.tar.gzhttp://ftp.gnu.org/gnu/coreutils/coreutils-8.25.tar.xzhttp://dbus.freedesktop.org/releases/dbus/dbus-1.10.10.tar.gzhttp://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.tar.gzhttp://ftp.gnu.org/gnu/diffutils/diffutils-3.5.tar.xzhttp://dev.gentoo.org/~blueness/eudev/eudev-3.2.tar.gzhttp://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.43.1/e2fsprogs-1.43.1.tar.gzhttp://prdownloads.sourceforge.net/expat/expat-2.2.0.tar.bz2http://prdownloads.sourceforge.net/expect/expect5.45.tar.gzftp://ftp.astron.com/pub/file/file-5.28.tar.gzhttp://ftp.gnu.org/gnu/findutils/findutils-4.6.0.tar.gzhttps://src.fedoraproject.org/lookaside/pkgs/flex/flex-2.6.1.tar.xz/cd3c86290fc2676a641aefafeb10848a/flex-2.6.1.tar.xzhttp://ftp.gnu.org/gnu/gawk/gawk-4.1.3.tar.xzhttp://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2http://ftp.gnu.org/gnu/gdbm/gdbm-1.12.tar.gzhttp://ftp.gnu.org/gnu/gettext/gettext-0.19.8.1.tar.xzhttp://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.xzhttp://ftp.gnu.org/gnu/gmp/gmp-6.1.1.tar.xzhttp://ftp.gnu.org/gnu/gperf/gperf-3.0.4.tar.gzhttp://ftp.gnu.org/gnu/grep/grep-2.25.tar.xzhttp://ftp.gnu.org/gnu/groff/groff-1.22.3.tar.gzhttp://alpha.gnu.org/gnu/grub/grub-2.02~beta3.tar.xzhttp://ftp.gnu.org/gnu/gzip/gzip-1.8.tar.xzhttp://anduin.linuxfromscratch.org/LFS/iana-etc-2.30.tar.bz2http://ftp.gnu.org/gnu/inetutils/inetutils-1.9.4.tar.xzhttp://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gzhttps://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.7.0.tar.xzhttps://www.kernel.org/pub/linux/utils/kbd/kbd-2.0.3.tar.xzhttps://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-23.tar.xzhttp://www.greenwoodsoftware.com/less/less-481.tar.gzhttp://www.linuxfromscratch.org/lfs/downloads/7.10/lfs-bootscripts-20150222.tar.bz2https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.25.tar.xzhttps://download-mirror.savannah.gnu.org/releases/libpipeline/libpipeline-1.4.1.tar.gzhttp://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xzhttps://www.kernel.org/pub/linux/kernel/v4.x/linux-4.7.2.tar.xzhttp://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.xzhttp://ftp.gnu.org/gnu/make/make-4.2.1.tar.bz2https://download-mirror.savannah.gnu.org/releases/man-db/man-db-2.7.5.tar.xzhttps://www.kernel.org/pub/linux/docs/man-pages/man-pages-4.07.tar.xzhttps://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gzhttp://www.mpfr.org/mpfr-3.1.4/mpfr-3.1.4.tar.xzhttp://ftp.gnu.org/gnu//ncurses/ncurses-6.0.tar.gzhttp://ftp.gnu.org/gnu/patch/patch-2.7.5.tar.xzhttp://www.cpan.org/src/5.0/perl-5.24.0.tar.bz2https://pkg-config.freedesktop.org/releases/pkg-config-0.29.1.tar.gzhttp://sourceforge.net/projects/procps-ng/files/Production/procps-ng-3.3.12.tar.xzhttp://downloads.sourceforge.net/project/psmisc/psmisc/psmisc-22.21.tar.gzhttp://ftp.gnu.org/gnu/readline/readline-6.3.tar.gzhttp://ftp.gnu.org/gnu/sed/sed-4.2.2.tar.bz2http://ftp.lfs-matrix.net/pub/blfs/conglomeration/shadow/shadow-4.2.1.tar.xzhttp://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.1.tar.gzhttp://anduin.linuxfromscratch.org/sources/other/systemd/systemd-231.tar.xzhttps://download-mirror.savannah.gnu.org/releases/sysvinit/sysvinit-2.88dsf.tar.bz2http://ftp.gnu.org/gnu/tar/tar-1.29.tar.xzhttp://sourceforge.net/projects/tcl/files/Tcl/8.6.6/tcl-core8.6.6-src.tar.gzhttp://ftp.gnu.org/gnu/texinfo/texinfo-6.1.tar.xzhttp://www.iana.org/time-zones/repository/releases/tzdata2016f.tar.gzhttp://anduin.linuxfromscratch.org/LFS/udev-lfs-20140408.tar.bz2https://www.kernel.org/pub/linux/utils/util-linux/v2.28/util-linux-2.28.1.tar.xzftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2http://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gzhttp://tukaani.org/xz/xz-5.2.2.tar.xzhttps://zlib.net/fossils/zlib-1.2.8.tar.gzhttp://www.linuxfromscratch.org/patches/lfs/7.10/bash-4.3.30-upstream_fixes-3.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/bc-1.06.95-memory_leak-1.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/bzip2-1.0.6-install_docs-1.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/coreutils-8.25-i18n-2.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/glibc-2.24-fhs-1.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/kbd-2.0.3-backspace-1.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/readline-6.3-upstream_fixes-3.patchhttp://www.linuxfromscratch.org/patches/lfs/7.10/sysvinit-2.88dsf-consolidated-1.patch
View Code

下载包和补丁,比较耗时,有的包可能超时下载不了。下载完毕后共80个包(算上补丁)

wget --input-file=wget-list --continue --directory-prefix=$LFS/sources
View Code

准备临时系统环境

创建临时目录

编译LFS过程中会生成很多临时工具,这些工具不会最终成为LFS系统的一部分。为临时工具指定目录$LFS/tools,一方面用完之后可以直接删掉而不会影响系统,另一方面防止临时根据影响系统其他目录。

mkdir -v $LFS/tools
View Code

为tools目录创建符号链接

[root@localhost lfs]# ln -sv $LFS/tools /‘/tools’ -> ‘/mnt/lfs/tools’
View Code

添加lfs用户

root用户随便犯个小错误都有可能破坏或摧毁整个系统,因此在编译上文提到的包和补丁时最好使用lfs用户。同时为lfs用户环境做些限制,尽量避免host对其影响。

groupadd lfsuseradd -s /bin/bash -g lfs -m -k /dev/null lfs命令行选项的意思:    -s /bin/bash    把bash 设置为 lfs 用户的默认 shell。    -g lfs    这个选项将用户lfs 添加到组 lfs 中。    -m    为lfs 用户创建主目录。    -k /dev/null    这个参数通过令输入位置为null设备,防止可能从一个skeleton目录中(默认是/etc/skel )复制文件。    lfs    这是创建的组和用户的实际名称。
View Code

为lfs设置密码

passwd lfs
View Code

更改sources、tools的属主

chown -v lfs $LFS/toolschown -v lfs $LFS/sources
View Code

如果想要切换到lfs用户可使用命令。su -除了切换用户身份外,shell也会切换为登陆shell。参考:

su - lfs
View Code

修改lfs用户shell环境

当以lfs用户登陆时,通常是个登陆shell。这个登陆shell需要先读取2个配置文件的配置信息:host的/etc/profile 和 lfs用户.bash_profile

修改.bash_profile,表明除HOME 、TERM 和 PS1 变量环境变量按设置保留外,其他环境变量全部清空。为啥这么做?因为host的/etc/profile可能之前被写入了部分环境变量,这些环境变量可能会加载到lfs用户这里进而污染lfs的shell环境。

cat > ~/.bash_profile << "EOF"exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bashEOF
View Code

对于一个shell ,通常是non-login shell,这种shell不读取/etc/profile 或 .bash_profile文件,而是读取.bashrc文件。创建或修改.bashrc文件如下

cat > ~/.bashrc << "EOF"set +humask 022LFS=/mnt/lfsLC_ALL=POSIXLFS_TGT=$(uname -m)-lfs-linux-gnuPATH=/tools/bin:/bin:/usr/binexport LFS LC_ALL LFS_TGT PATHEOF
View Code

set +h 命令关闭了 bash 的哈希功能。hash可以加快命令查找速度,但是这对于编译LFS不是啥好事。由于我们前面对tools做过软连接,取消hash可以强制每次查找命令时都从$PATH查找,这样tools下面一旦某些根据可用就能马上被系统用上。

LFS用于设置挂载点

source命令加载下配置文件,使修改生效

source ~/.bash_profile
View Code

说明

SBU

Standard Build Unit(标准编译单位)指代具体的编译时间。这里以编译Binutils所用时间作为一个标准编译单位(SBU),其它软件的生成时间都以其为标准进行比较。

Test Suites

测试套件由于帮助我们“检查”软件编译是否正确,出软件包的功能是否都如开发人员预想的那样正常。但是,它并不能总是保证所测试的软件包就一定没有问题。在编译临时工具的时候不建议使用测试套件

 

 

 

 

转载于:https://www.cnblogs.com/kelamoyujuzhen/p/9163282.html

你可能感兴趣的文章
NTP常见问题和解决方案&配置文件详解
查看>>
crontab计划任务补充知识
查看>>
数据库备份
查看>>
独家 | 图灵奖得主Raj Reddy:通用AI还很遥远,人类将成宠物
查看>>
java中自动生成XML文件
查看>>
Docker 数据卷,数据卷容器详细介绍
查看>>
VS2015编译Live555流媒体服务器
查看>>
依赖属性之“风云再起”三
查看>>
利用K8S技术栈打造个人私有云(连载之:K8S资源控制)
查看>>
mysql内存过高解决办法
查看>>
CentOS7 Ceph RBD CephFS 存储
查看>>
[转载] 白话解释 非对称加密,电子签名,电子证书,根证书,HTTPS,PKI 到底是什么...
查看>>
Samba文件共享服务器搭建详解
查看>>
几个有用的MSSQL语句
查看>>
Apache用户认证
查看>>
zabbix与nagios对比
查看>>
Glusterfs分布式文件系统
查看>>
selenium入门
查看>>
selinux的状态查看及关闭
查看>>
linux添加端口并生效
查看>>