Final Preparations
Section 4.1 Introduction
Final tasks to prep the system for the temporary bootstrap build. Discusses SBU 'Standard Build Unit' measurement of time, setting up an unprivileged user for the builds, etc... No real work to be done for this section, on to the next.Section 4.2 Tools directory
Our bootstrap LFS system will build the initial toolchain under $LFS/tools. This step is intended to setup the given path and symbolic links to seperate our initial LFS tool chain from our host gentoo's tool chain. Remember in a previous step, we built a set of persistent changes that we can apply after a gentoo reboot. One of those persistent changes was making sure that the $LFS variable was set to our initial target bootstrap filesystem, in which we are using the ZFS rootPool/root_fs dataset instead of a standard EXT4 partition. We can see that these changes are still in place on our recently rebooted system by issuing the following command:gentoo@livecd ~ $ echo $LFS /rootPool/root_fs/gentoo@livecd~ $
The instructions say to run the following commands as root:
mkdir -v $LFS/tools
ln -sv $LFS/tools
However, we will deviate slightly, since we are on a ZFS directory, we will use a new tools dataset and create a snapshot instead of a plain old directory:
gentoo@livecd ~ $ su livecd gentoo # zfs create rootPool/root_fs/toolslivecdgentoo #zfs snapshot rootPool/root_fs/tools@initlivecdgentoo #ln -sv $LFS/tools / '/tools' -> '/rootPool/root_fs//tools'livecdgentoo #exit exitgentoo@livecd~ $
Section 4.3 Temporary LFS user.
Section 4.3 recommends creating an LFS user, instead of performing everything as 'root'. It recommends using this user rather than a normal user so that it will be 'easier' to clean all the temporary bootstrap stuff up later. Since our host system is a gentoo live environment that already contains a non-root user of 'gentoo', we will just continue using the 'gentoo' user. One reason I am not creating a LFS specific user, is it would not be persistent across reboots without a lot of additional work. In addition the instructions include changing permissions of tools and source directories to be owned by the lfs user instead of root. My sources are already owned (including zfs granted permissions for management) to the gentoo user. I will just grant 'gentoo' the added tools information instead. So I will be skipping the following recommended commands as root:groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
Instead I will be performing the following commands for ZFS with the existing gentoo user:
gentoo@livecd ~ $ sudo chown -v gentoo:users /rootPool/root_fs/tools/ changed ownership of '/rootPool/root_fs/tools/' from root:root to gentoo:usersgentoo@livecd~ $sudo chmod -v a+wt $LFS/tools mode of '/rootPool/root_fs//tools' changed from 0755 (rwxr-xr-x) to 1777 (rwxrwxrwt)gentoo@livecd~ $sudo zfs allow users mount,create,snapshot,diff rootPool/root_fs/toolsgentoo@livecd~ $
Section 4.4 Setting Up the Environment.
We will be changing the gentoo user's environment to prevent contamination from the host gentoo system..bash_profile
We will update the profile so that on login a new bash shell will be executed with new clean environment different than the system environment.gentoo@livecd ~ $ cat > ~/.bash_profile << "EOF" > exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash > EOFgentoo@livecd~ $
.bashrc
We will update the bash resource settings so that we only have the environment variables we want. In addition we are setting the umask so that we will mask off the group/world write-able bits. This will make default mode of files 644 vs 666. The 'set +h' option turns off bash path hashing, to ensure that bash always searches the path for an executable, instead of caching the command. This ensures that as we build new programs in the target bootstrap environment, updated tools/paths will be used as they are installed or replaced.gentoo@livecd~ $cat >~/.bashrc << "EOF" > set +h > umask 022 > LFS=/rootPool/root_fs > LC_ALL=POSIX > LFS_TGT=$(uname -m)-lfs-linux-gnu > PATH=/tools/bin:/sbin:/bin:/usr/bin > export LFS LC_ALL LFS_TGT PATH > EOFgentoo@livecd~ $
Sourcing the New Profile
Finally we will snapshot these changes, and source the changes for testing, after which we will reboot, to make sure these changes are persistent across reboots.
gentoo@livecd~ $sudo zfs snapshot gentooScratch/persistentHomeGentoo@section_4.4_environmentgentoo@livecd~ $source ~/.bash_profilegentoo@livecd~ $env TERM=xterm LC_ALL=POSIX LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.cfg=00;32:*.conf=00;32:*.diff=00;32:*.doc=00;32:*.ini=00;32:*.log=00;32:*.patch=00;32:*.pdf=00;32:*.ps=00;32:*.tex=00;32:*.txt=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36: LFS=/rootPool/root_fs PATH=/tools/bin:/sbin:/bin:/usr/bin PWD=/home/gentoo LFS_TGT=x86_64-lfs-linux-gnu PS1=\[\033]0;\u@\h:\w\007\]\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] SHLVL=1 HOME=/home/gentoo _=/bin/envgentoo@livecd~ $ sudo reboot
I found that I need to add the following two lines to the end of my persistent script:
gentoo@livecd~ $tail -n 2 /mnt/cdrom/scratch/mountfs.sh mv /home/gentoo/.bash_profile /home/gentoo/lfs.bash_profile mv /home/gentoo/.bashrc /home/gentoo/lfs.bashrcgentoo@livecd~ $
This allows me after a reboot to have my full environment for bringing up my gentoo X-Windows desktop, firefox for updating this blog, and layout my work terminals. Once I am ready to start performing LFS steps in my target environment I need only run the following commands to be ready to work:
mv lfs.bash_profile .bash_profile
mv lfs.bashrc .bashrc
At which points sourcing the profile, or starting a new bash session will be setup for LFS user (with my existing gentoo account) access.
Section 4.5 More about SBUs
The LFS document talks about SBUs or Standard Build Unit, since many would like to know how long it will take to build the packages and system as a whole. This is used because different equipment will take different amounts of time. A value of '1' is the amount of time it takes to build the first pass of the 'binutils' package. These will be approximate values. One factor that can speed up the builds is to allow make to spawn parallel threads for the different compilation units. In the past I have often found that approximately launching 1.25 to 1.5 * the available processor threads will keep most of the CPU fully loaded, while having additional threads that can run while waiting on the IO intensive portions of a build. The value I will use for most builds will be 16 cores * 2 SMT/core * 1.37 make load = which is about 44 threads. Using this value I will update my .bashrc settings to the following:gentoo@livecd ~ $ cat .bashrc set +h umask 022 LFS=/rootPool/root_fs LC_ALL=POSIX LFS_TGT=$(uname -m)-lfs-linux-gnu PATH=/tools/bin:/sbin:/bin:/usr/bin MAKEFLAGS='-j44' export LFS LC_ALL LFS_TGT PATH MAKEFLAGSgentoo@livecd~ $
No comments:
Post a Comment