Raspberry Pi (Raspberry Pi) builds a Linux system (PiLFS) from scratch (II), raspberrypilfs

Source: Internet
Author: User

Raspberry Pi (Raspberry Pi) builds a Linux system (PiLFS) from scratch (II), raspberrypilfs

7. Build a temporary system

1. General Compilation Guide

A. Check whether the settings are correct.LFSEnvironment Variable

echo $LFS

B. Assume that you have correctly set the host system requirements and symbolic links.

C. For each software package:

(1) make sure you useLfsUser

(2) Unless otherwise specified, delete the decompressed directory and allbuildDirectory

 

2. execute shell scripts to build a temporary system.

cd $LFS/sourceschmod +x ch5-build.sh./ch5-build.sh

  

3. Change owner

All subsequent commands must startrootUser identity execution insteadlfsUser. In addition, confirm that the $ LFS variable is also defined in the root user environment.

Current,$LFS/toolsDirectory belongslfsUse the following command$LFS/toolsChange the directory ownerrootUser:

su - root export LFS=/mnt/lfs chown -R root:root $LFS/tools

 

8. Build an LFS System

1. Prepare the virtual Kernel File System

The kernel mounts several file systems to exchange information between itself and the user space program. These file systems are virtual and do not occupy the actual disk space,

Their contents are stored in the memory.

mkdir -pv $LFS/{dev,proc,sys,run}mknod -m 600 $LFS/dev/console c 5 1mknod -m 666 $LFS/dev/null c 1 3mknod -m 444 /dev/random c 1 8 mknod -m 444 /dev/urandom c 1 9 mount -v --bind /dev $LFS/devmount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620mount -vt proc proc $LFS/procmount -vt sysfs sysfs $LFS/sysmount -vt tmpfs tmpfs $LFS/runif [ -h $LFS/dev/shm ]; then  mkdir -pv $LFS/$(readlink $LFS/dev/shm)fi

2. Enter the Chroot environment

From hereLFSVariable, because all subsequent work will be limited to the LFS file system.

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

3. Create a directory

# Create some directory structures in the LFS file system. Use the following command to create a standard directory tree: # This directory tree is based on the file system directory structure standard (FHS) mkdir-pv/{bin, boot, etc/{opt, sysconfig}, home, lib/firmware, mnt, opt} mkdir-pv/{media/{floppy, cdrom}, sbin, srv, var} install-dv-m 0750/rootinstall-dv-m 1777/tmp/var/tmpmkdir-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/libexecmkdir-pv/usr/{, local/} share/man {1 .. 8} case $ (uname-m) in x86_64) mkdir-v/lib64; esacmkdir-v/var/{log, mail, spool} ln-sv/run/var/runln-sv/run/lock/var/lockmkdir-pv/var/{opt, cache, lib/{color, misc, locate}, local}

4. create necessary file and symbolic links

Ln-sv/tools/bin/{bash, cat, echo, pwd, stty}/binln-sv/tools/bin/perl/usr/binln-sv/tools/lib/libgcc_s.so {,. 1}/usr/libln-sv/tools/lib/libstdc ++. so {,. 6}/usr/libsed's/tools/usr/'/tools/lib/libstdc ++. la>/usr/lib/libstdc ++. la1-sv bash/bin/shln-sv/proc/self/mounts/etc/mtab # The actual password of the root user (here "x" is just a placeholder) will be created later. Cat>/etc/passwd <"EOF" root: x: 0: 0: root:/bin/bashbin: x: 1: 1: bin: /dev/null:/bin/falsedaemon: x: 6: 6: Daemon User:/dev/null:/bin/falsemessagebus: x: 18: 18: d-Bus Message Daemon User:/var/run/commands:/bin/falsenobody: x: 99: 99: Unprivileged User:/dev/null: /bin/falseEOFcat>/etc/group <"EOF" root: x: 0: bin: x: 1: daemonsys: 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: EOFexec/tools/bin/bash -- login + htouch/var/log/{btmp, lastlog, faillog, wtmp} chgrp-v utmp/var/log/lastlogchmod-v 664/var/log/lastlogchmod-v 600/var/log/btmp

5. execute shell scripts to build the LFS system.

cd /sourceschmod +x ch6-build.sh./ch6-build.sh

Master.tar.gz: Cross-compiled binary kernel, kernel module, bootloader, and GPU (VideoCore) firmware

You can select the installation and upgrade options as prompted by the script.

6. Clear useless content again

logoutchroot $LFS /tools/bin/env -i            \    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \    PATH=/bin:/usr/bin:/sbin:/usr/sbin   \    /tools/bin/bash --login/tools/bin/find /usr/lib -type f -name \*.a \   -exec /tools/bin/strip --strip-debug {} ';'/tools/bin/find /lib /usr/lib -type f -name \*.so* \   -exec /tools/bin/strip --strip-unneeded {} ';'/tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \    -exec /tools/bin/strip --strip-all {} ';'

7. Clean up

rm -rf /tmp/*logout chroot "$LFS" /usr/bin/env -i              \    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \    PATH=/bin:/usr/bin:/sbin:/usr/sbin     \    /bin/bash --loginrm -rf /tools rm -f /usr/lib/lib{bfd,opcodes}.arm -f /usr/lib/libbz2.arm -f /usr/lib/lib{com_err,e2p,ext2fs,ss}.arm -f /usr/lib/libltdl.arm -f /usr/lib/libfl.arm -f /usr/lib/libfl_pic.arm -f /usr/lib/libz.a

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.