From 26452e38a2cf2f9426da4f78459e8ac72fa60079 Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 20 Jun 2021 10:51:00 -0400 Subject: [PATCH] README updates --- .README.md.un~ | Bin 0 -> 2042 bytes README.md | 2 +- README.md~ | 269 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 .README.md.un~ create mode 100644 README.md~ diff --git a/.README.md.un~ b/.README.md.un~ new file mode 100644 index 0000000000000000000000000000000000000000..10ec3fd752a4c0701245e9bdfdd90270d4fd3817 GIT binary patch literal 2042 zcmeHIzfV*_5Z(h5PZOlDv7FEd38Dqp*=QgHg1-{)+H-H;9B;$E-Iv|B2NV=^6edX=b?&sKiXez@o7VJfAT5GL_MXEkA@)P4@rU=F&HneG6PhO zkEt9&oIW7n+oX3d3QwhIJiT=B2ijLr8Yra7wZ#QkeOPlP25mRsm6ysObZV>TZhM|6 zRl$ynprnNu5UQNiIRmcG`yNX4!CAsAJ@(O~RSC8LAFX9ja(w1h4(r;+ZRot1hd!c# zzDGt%pb2Q@W&3e$lj%@-O*d<2`5u)!&8TZJR7~s;eR3sESCZoAm@*uoabuWWYzs0!pbipWcFNEAO9r8sw& yVfvZk_s7irA9F_=GZ%=v__#T9CT>KCxt}lI%74w7n44Z@ZYr05nOl3mzWxPMD/lfs-packages-10.0.tar . +tar xf lfs-packages-10.0.tar +mv 10.0 sources +chmod -v a+wt $LFS/sources +mv $LFS/sources/tcl8.6.10-src.tar.gz $LFS/sources/tcl8.6.10.tar.gz +``` + +Copy all the shell scripts from this repository to your $LFS directory: + +``` +cp //*.sh $LFS +``` + +Create the basic filesystem for LFS: + +``` +mkdir -pv $LFS/{bin,etc,lib,sbin,usr,var,lib64,tools} +``` + +Create the lfs user, used during the initial build process (you will have to type a password): + +``` +groupadd lfs +useradd -s /bin/bash -g lfs -m -k /dev/null lfs +passwd lfs +``` + +Make lfs own the entire filesystem: + +``` +chown -R lfs:lfs $LFS/* +chown lfs:lfs $LFS +``` + +Login as the lfs user: + +``` +su - lfs +``` + +:point_right: Run commands below as lfs. + +Create a .bash_profile file: + +``` +cat > ~/.bash_profile << "EOF" +exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash +EOF +``` + +Create a .bashrc file: + +``` +cat > ~/.bashrc << "EOF" +set +h +umask 022 +LFS=/mnt/lfs +LC_ALL=POSIX +LFS_TGT=$(uname -m)-lfs-linux-gnu +PATH=/usr/bin +if [ ! -L /bin ]; then PATH=/bin:$PATH; fi +PATH=$LFS/tools/bin:$PATH +export LFS LC_ALL LFS_TGT PATH +EOF + +source ~/.bashrc +``` + +Run the lfs-cross.sh script, which will build the cross-toolchain and cross compiling temporary tools from chapters 5 and 6: + +``` +sh $LFS/lfs-cross.sh | tee $LFS/lfs-cross.log +``` + +Return to being root: + +``` +exit +``` + +:point_right: Run commands below as root. + +Make root own the entire filesystem again: + +``` +chown -R root:root $LFS/* +chown root:root $LFS +``` + +Prepare 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 +mount -v --bind /dev $LFS/dev +mount -v --bind /dev/pts $LFS/dev/pts +mount -vt proc proc $LFS/proc +mount -vt sysfs sysfs $LFS/sys +mount -vt tmpfs tmpfs $LFS/run +if [ -h $LFS/dev/shm ]; then + mkdir -pv $LFS/$(readlink $LFS/dev/shm) +fi +``` + +Enter the chroot environment: + +``` +chroot "$LFS" /usr/bin/env -i \ + HOME=/root \ + TERM="$TERM" \ + PS1='(lfs chroot) \u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash --login +h +``` + +Create essential directories, files and symlinks: + +``` +mkdir -pv /{boot,home,mnt,opt,srv} +mkdir -pv /etc/{opt,sysconfig} +mkdir -pv /lib/firmware +mkdir -pv /media/{floppy,cdrom} +mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} +mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} +mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo} +mkdir -pv /usr/{,local/}share/man/man{1..8} +mkdir -pv /var/{cache,local,log,mail,opt,spool} +mkdir -pv /var/lib/{color,misc,locate} +ln -sfv /run /var/run +ln -sfv /run/lock /var/lock +install -dv -m 0750 /root +install -dv -m 1777 /tmp /var/tmp +ln -sv /proc/self/mounts /etc/mtab +echo "127.0.0.1 localhost $(hostname)" > /etc/hosts +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 +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: +input:x:24: +mail:x:34: +kvm:x:61: +wheel:x:97: +nogroup:x:99: +users:x:999: +EOF +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 +exec /bin/bash --login +h +``` + +Run the lfs-chroot.sh script, which will build additional temporary tools: + +``` +sh /lfs-chroot.sh | tee /lfs-chroot.log +``` + +Cleanup before the final build phase: + +``` +find /usr/{lib,libexec} -name \*.la -delete +rm -rf /usr/share/{info,man,doc}/* +``` + +For the final build phase, run the lfs-system.sh script: + +``` +sh /lfs-system.sh | tee /lfs-system.log +``` + +You must now set a password for the root user (you will have to type a password): + +``` +passwd root +``` + +Logout from the chroot environment and re-enter it with updated configuration: + +``` +logout +chroot "$LFS" /usr/bin/env -i \ + HOME=/root TERM="$TERM" \ + PS1='(lfs chroot) \u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash --login +``` + +Run the final script to configure the rest of the system: + +``` +sh /lfs-final.sh | tee /lfs-final.log +``` + +# The end + +You can now create a new VM using the virtual hard disk with the LFS build. It will be bootable and fully functional. Enjoy!