zoukankan      html  css  js  c++  java
  • LFS7.10——构建LFS系统

    参考:LFS7.10——准备Host系统

    LFS7.10——构造临时Linux系统

    本文正式开始构建LFS系统,后面所有命令的执行都是在root用户下完成的。

    这时开始构建LFS前准备工作

    更改$LFS/tools属主

    chown -R root:root $LFS/tools

    准备Virtual Kernel File Systems

    mkdir -pv $LFS/{dev,proc,sys,run}

    创建初始设备节点

    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3

    挂载和激活 /dev

    mount -v --bind /dev $LFS/dev

    挂载Virtual Kernel File Systems

    mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
    mount -vt proc proc $LFS/proc
    mount -vt sysfs sysfs $LFS/sys
    mount -vt tmpfs tmpfs $LFS/run

    进入 Chroot 环境

    chroot "$LFS" /tools/bin/env -i 
    HOME=/root 
    TERM="$TERM" 
    PS1='u:w$ ' 
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin 
    /tools/bin/bash --login +h
    View Code

    准备LFS文件系统里面二点目录结构

    mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
    mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
    install -dv -m 0750 /root
    install -dv -m 1777 /tmp /var/tmp
    mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
    mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
    mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
    mkdir -v /usr/libexec
    mkdir -pv /usr/{,local/}share/man/man{1..8}
    case $(uname -m) in
    x86_64) ln -sv lib /lib64
    ln -sv lib /usr/lib64
    ln -sv lib /usr/local/lib64 ;;
    esac
    mkdir -v /var/{log,mail,spool}
    ln -sv /run /var/run
    ln -sv /run/lock /var/lock
    mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}
    View Code

    创建必需的文件和符号链接

    ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
    ln -sv /tools/bin/perl /usr/bin
    ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
    ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
    sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
    ln -sv bash /bin/sh
    View Code

    ln -sv /proc/self/mounts /etc/mtab

    创建/etc/passwd 文件

    cat > /etc/passwd << "EOF"
    root:x:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/dev/null:/bin/false
    daemon:x:6:6:Daemon User:/dev/null:/bin/false
    messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
    nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    EOF
    View Code

    创建/etc/group 文件

    cat > /etc/group << "EOF"
    root:x:0:
    bin:x:1:daemon
    sys:x:2:
    kmem:x:3:
    tape:x:4:
    tty:x:5:
    daemon:x:6:
    floppy:x:7:
    disk:x:8:
    lp:x:9:
    dialout:x:10:
    audio:x:11:
    video:x:12:
    utmp:x:13:
    usb:x:14:
    cdrom:x:15:
    adm:x:16:
    messagebus:x:18:
    systemd-journal:x:23:
    input:x:24:
    mail:x:34:
    nogroup:x:99:
    users:x:999:
    EOF
    View Code

    exec /tools/bin/bash --login +h

    初始化一下日志文件并加上合适的权限

    touch /var/log/{btmp,lastlog,faillog,wtmp}
    chgrp -v utmp /var/log/lastlog
    chmod -v 664 /var/log/lastlog
    chmod -v 600 /var/log/btmp
    View Code

    安装Linux-4.7.2 API Headers

    tar -xvf linux-4.7.2.tar.xz
    cd linux-4.7.2
    make mrproper
    make INSTALL_HDR_PATH=dest headers_install
    find dest/include ( -name .install -o -name ..install.cmd ) -delete
    cp -rv dest/include/* /usr/include
    cd ..
    rm -rf linux-4.7.2

    安装Man-pages

    tar -xvf man-pages-4.07.tar.xz
    cd man-pages-4.07
    make install
    cd ..
    rm -rf man-pages-4.07

    Glibc

    安装

    tar -xvf glibc-2.24.tar.xz
    cd glibc-2.24
    patch -Np1 -i ../glibc-2.24-fhs-1.patch
    mkdir -v build
    cd build

    ../configure --prefix=/usr 
    --enable-kernel=2.6.32 
    --enable-obsolete-rpc
    View Code

    make -j8

    make check

    touch /etc/ld.so.conf
    make install

    cp -v ../nscd/nscd.conf /etc/nscd.conf
    mkdir -pv /var/cache/nscd
    View Code
    mkdir -pv /usr/lib/locale
    localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
    localedef -i de_DE -f ISO-8859-1 de_DE
    localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
    localedef -i de_DE -f UTF-8 de_DE.UTF-8
    localedef -i en_GB -f UTF-8 en_GB.UTF-8
    localedef -i en_HK -f ISO-8859-1 en_HK
    localedef -i en_PH -f ISO-8859-1 en_PH
    localedef -i en_US -f ISO-8859-1 en_US
    localedef -i en_US -f UTF-8 en_US.UTF-8
    localedef -i es_MX -f ISO-8859-1 es_MX
    localedef -i fa_IR -f UTF-8 fa_IR
    localedef -i fr_FR -f ISO-8859-1 fr_FR
    localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
    localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
    localedef -i it_IT -f ISO-8859-1 it_IT
    localedef -i it_IT -f UTF-8 it_IT.UTF-8
    localedef -i ja_JP -f EUC-JP ja_JP
    localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
    localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
    localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
    localedef -i zh_CN -f GB18030 zh_CN.GB18030
    View Code

    make localedata/install-locales

    配置Glibc

    创建一个新文件/etc/nsswitch.conf

    cat > /etc/nsswitch.conf << "EOF"
    # Begin /etc/nsswitch.conf
    passwd: files
    group: files
    shadow: files
    hosts: files dns
    networks: files
    protocols: files
    services: files
    ethers: files
    rpc: files
    # End /etc/nsswitch.conf
    EOF
    View Code

    安装时区数据:

    tar -xf ../../tzdata2016f.tar.gz
    ZONEINFO=/usr/share/zoneinfo
    mkdir -pv $ZONEINFO/{posix,right}
    for tz in etcetera southamerica northamerica europe africa antarctica 
    asia australasia backward pacificnew systemv; do
    zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
    zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
    zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
    done
    cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
    zic -d $ZONEINFO -p America/New_York
    unset ZONEINFO
    View Code

    tzselect

    cp -v /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

    配置Dynamic Loader

    创建/etc/ld.so.conf

    cat > /etc/ld.so.conf << "EOF"
    # Begin /etc/ld.so.conf
    /usr/local/lib
    /opt/lib
    EOF
    View Code
    cat >> /etc/ld.so.conf << "EOF"
    # Add an include directory
    include /etc/ld.so.conf.d/*.conf
    EOF
    mkdir -pv /etc/ld.so.conf.d
    View Code

    调整工具链

    与LFS7.10 Adjusting the Toolchain 预期结果不符,还在排查问题,未完待续。。。

  • 相关阅读:
    JavaScript 工作必知(九)function 说起 闭包问题
    AngularJs(七) 模块的创建
    javaScript 工作必知(八) 属性的特性 值、写、枚举、可配置
    javaScript 工作必知(七) 对象继承
    javaScript 工作必知(六) delete in instanceof
    数据可视化产品示例和相关文章
    echarts的世界地图json
    webstorm使用svn
    初识产品运维
    UglifyJS 压缩选项
  • 原文地址:https://www.cnblogs.com/kelamoyujuzhen/p/10140532.html
Copyright © 2011-2022 走看看