Install Linux From Scratch

What is it ?

Linux from scratch is a book that explain how install linux from scratch.
https://linuxfromscratch.org/

Why ?

I would like to learn more about linux. I’t will not be the best distro, for daily usage it’s better to use something else.

Disclamer

This is not a tutorial, I’m reading the book from the beginning, I skip some checking step here.

Install

Partition

https://linuxfromscratch.org/lfs/view/stable/chapter02/creatingfilesystem.html
I don’t have free space left to create a new partition, I have to umout an existing partition to split it.
I need 20G of space.

sudo umount /iso

Then I resize it with gparted and create the new partition.
I create a ext4 partiton.
I will use the root user for everything now.

Setting The $LFS Variable

export LFS=/mnt/lfs

It’s just a shortcut, instead of typing /mnt/lfs you can do $LFS.
To be sure do this command.

echo $LFS

Mounting the New Partition

mkdir -pv $LFS
mount -v -t ext4 /dev/sda2 $LFS

I will add it to the fstab cuz it’s already late and I will restart my computer.

echo "/dev/sda2  /mnt/lfs ext4   defaults      1     1" >> /etc/fstab

Source directory

https://linuxfromscratch.org/lfs/view/stable/chapter03/introduction.html
In this few lines I create thee source directory, then I download the list with the required packages.
Then I download them via wget.

Do it as root !

su - root
mkdir -v $LFS/sources
chmod -v a+wt $LFS/sources
cd /tmp
curl https://linuxfromscratch.org/lfs/view/stable/wget-list -o wget-list
wget --input-file=wget-list --continue --directory-prefix=$LFS/sources

It’s downloading the patches too
I can verify the packages but, nop.

Creating a limited directory layout in LFS filesystem

https://linuxfromscratch.org/lfs/view/stable/chapter04/creatingminlayout.html
As root with the LFS variable.
I’m creating the directories for the new system.

mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin}

for i in bin lib sbin; do
  ln -sv usr/$i $LFS/$i
done

case $(uname -m) in
  x86_64) mkdir -pv $LFS/lib64 ;;
esac

The cross compiler

mkdir -pv $LFS/tools

Adding the LFS User

https://linuxfromscratch.org/lfs/view/stable/chapter04/addinguser.html
When logged in as user root, making a single mistake can damage or destroy a system.
As root, create the user lfs.

groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs

Password: toor
Grant access to lfs to all directories.

chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}
case $(uname -m) in
  x86_64) chown -v lfs $LFS/lib64 ;;
esac
chown -v lfs $LFS/sources
su - lfs

Now I can work as lfs instead of root, it’s better like that.

Setting Up the Environment

With the user lfs.
Create the .bash_profile

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

Create the .bashrc

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 CONFIG_SITE=$LFS/usr/share/config.site export LFS LC_ALL LFS_TGT PATH CONFIG_SITE`
EOF

Several commercial distributions add a non-documented instantiation of /etc/bash.bashrc to the initialization of bash. This file has the potential to modify the lfs user’s environment in ways that can affect the building of critical LFS packages. To make sure the lfs user’s environment is clean, check for the presence of /etc/bash.bashrc and, if present, move it out of the way. As the root user, run:
As root run:

exit
[ ! -e /etc/bash.bashrc ] || mv -v /etc/bash.bashrc /etc/bash.bashrc.NOUSE
su - lfs
export LFS=/mnt/lfs
source ~/.bash_profile

Compilation

The page about compilation:
https://linuxfromscratch.org/lfs/view/stable/partintro/toolchaintechnotes.html
If it take too much time to compile I will do it later.
It’s already too hot in my room because of the heat wave, so if I compile I will die.

I have to compile binutils first.

cd $LFS/sources
tar -xvf binutils-2.38.tar.xz
mkdir -v build
cd       build

Now prepare Binutils for compilation:

../configure --prefix=$LFS/tools \
             --with-sysroot=$LFS \
             --target=$LFS_TGT   \
             --disable-nls       \
             --disable-werror

The makefile is created.
continue with compiling the package:

make

Install the package:

make install

GCC-11.2.0 - Pass 1

https://linuxfromscratch.org/lfs/view/stable/chapter05/gcc-pass1.html
Extract gcc:

tar -xvf gcc-11.2.0.tar.xz
cd gcc-11.2.0
tar -xf ../mpfr-4.1.0.tar.xz
mv -v mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv -v mpc-1.2.1 mpc

On x86_64 hosts, set the default directory name for 64-bit libraries to “lib”:

case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
 ;;
esac

Create the build directorie.

mkdir -v build
cd       build

Prepare GCC for compilation:

../configure                  \
    --target=$LFS_TGT         \
    --prefix=$LFS/tools       \
    --with-glibc-version=2.35 \
    --with-sysroot=$LFS       \
    --with-newlib             \
    --without-headers         \
    --enable-initfini-array   \
    --disable-nls             \
    --disable-shared          \
    --disable-multilib        \
    --disable-decimal-float   \
    --disable-threads         \
    --disable-libatomic       \
    --disable-libgomp         \
    --disable-libquadmath     \
    --disable-libssp          \
    --disable-libvtv          \
    --disable-libstdcxx       \
    --enable-languages=c,c++

continue with compiling the package:

make

Install the package:

make install
cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h

I had lot of trouble here, if you have an error, compile binutils again.
Be sure you have the environement set:

set | grep LFS

Linux-5.16.9 API Headers

tar -xf linux-5.16.9.tar.xz
cd linux-5.16.9
make mrproper

Make the header in /usr

make headers
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include $LFS/usr

Glibc-2.35

create a symbolic link for LSB compliance for proper operation of the dynamic library loader:

case $(uname -m) in
    i?86)   ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
    ;;
    x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
            ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
    ;;
esac

Patch glibc:

tar -xvf glibc-2.35.tar.xz
cd glibc-2.35
patch -Np1 -i ../glibc-2.35-fhs-1.patch

Then build it:

mkdir -v build
cd       build
echo "rootsbindir=/usr/sbin" > configparms
../configure                             \
      --prefix=/usr                      \
      --host=$LFS_TGT                    \
      --build=$(../scripts/config.guess) \
      --enable-kernel=3.2                \
      --with-headers=$LFS/usr/include    \
      libc_cv_slibdir=/usr/lib
make


Nice, my OS is already half broken xD.
The first command is the one who can broke the system because if $LFS is empty it will be installed in your system. Because this library provides the basic routines for allocating memory, searching directories, opening and closing files, reading and writing files, string handling, pattern matching, arithmetic, and so on.

make DESTDIR=$LFS install
sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd

Sanity check:

echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep '/ld-linux'

If there is no error you can continue.

rm -v dummy.c a.out
$LFS/tools/libexec/gcc/$LFS_TGT/11.2.0/install-tools/mkheaders

Libstdc++ from GCC-11.2.0

https://linuxfromscratch.org/lfs/view/stable/chapter05/gcc-libstdc++-pass1.html
Libstdc++ is part of the GCC sources. You should first unpack the GCC tarball and change to the gcc-11.2.0 directory.
So let’s go to the gcc directory

cd ../../gcc-11.2.0
mv build/ build.back
mkdir -v build
cd       build
../libstdc++-v3/configure           \
    --host=$LFS_TGT                 \
    --build=$(../config.guess)      \
    --prefix=/usr                   \
    --disable-multilib              \
    --disable-nls                   \
    --disable-libstdcxx-pch         \
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/11.2.0
make
make DESTDIR=$LFS install

Cross Compiling Temporary Tools

https://linuxfromscratch.org/lfs/view/stable/chapter06/chapter06.html

M4-1.4.19

cd ../../
tar -xf m4-1.4.19.tar.xz
cd m4-1.4.19
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
make


Oh it’s broken.
Because I forgot this in the gcc directory:

cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h

Now we can install

make DESTDIR=$LFS install

Ncurses-6.3

https://linuxfromscratch.org/lfs/view/stable/chapter06/ncurses.html

tar -xvf ncurses-6.3
cd ncurses-6.3

Build tic:

mkdir build
pushd build
  ../configure
  make -C include
  make -C progs tic
popd

Prepare Ncurses for compilation:

./configure --prefix=/usr                \
            --host=$LFS_TGT              \
            --build=$(./config.guess)    \
            --mandir=/usr/share/man      \
            --with-manpage-format=normal \
            --with-shared                \
            --without-debug              \
            --without-ada                \
            --without-normal             \
            --disable-stripping          \
            --enable-widec


Make and install:

make -j4
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so

Bash-5.1.16

https://linuxfromscratch.org/lfs/view/stable/chapter06/bash.html

tar -xvf bash-5.1.16.tar.gz  
cd bash-5.1.16
./configure --prefix=/usr                   \
            --build=$(support/config.guess) \
            --host=$LFS_TGT                 \
            --without-bash-malloc
make -j4
make DESTDIR=$LFS install

Make a link for the programs that use sh for a shell:

ln -sv bash $LFS/bin/sh

Coreutils-9.0

https://linuxfromscratch.org/lfs/view/stable/chapter06/coreutils.html

tar -xvf coreutils-9.0.tar.xz
cd coreutils-9.0
./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --enable-install-program=hostname \
            --enable-no-install-program=kill,uptime
make -j4
make DESTDIR=$LFS install

Then move the program to the final destination.

mv -v $LFS/usr/bin/chroot              $LFS/usr/sbin
mkdir -pv $LFS/usr/share/man/man8
mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8
sed -i 's/"1"/"8"/'                    $LFS/usr/share/man/man8/chroot.8

Diffutils-3.8

https://linuxfromscratch.org/lfs/view/stable/chapter06/diffutils.html

tar -xvf diffutils-3.8.tar.xz 
cd diffutils-3.8
./configure --prefix=/usr --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

File-5.41

https://linuxfromscratch.org/lfs/view/stable/chapter06/file.html

cd file-5.41
mkdir build
pushd build
  ../configure --disable-bzlib      \
               --disable-libseccomp \
               --disable-xzlib      \
               --disable-zlib
  make
popd
./configure --prefix=/usr --host=$LFS_TGT --build=$(./config.guess)
make FILE_COMPILE=$(pwd)/build/src/file
make DESTDIR=$LFS install

Findutils-4.9.0

https://linuxfromscratch.org/lfs/view/stable/chapter06/findutils.html
That’s a lot of packages…

tar -xvf findutils-4.9.0.tar.xz
cd findutils-4.9.0
./configure --prefix=/usr                   \
            --localstatedir=/var/lib/locate \
            --host=$LFS_TGT                 \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

Gawk-5.1.1

https://linuxfromscratch.org/lfs/view/stable/chapter06/gawk.html

tar -xvf gawk-5.1.1.tar.xz 
cd gawk-5.1.1
sed -i 's/extras//' Makefile.in
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

Grep-3.7

https://linuxfromscratch.org/lfs/view/stable/chapter06/grep.html

tar -xvf grep-3.7.tar.xz
cd grep-3.7
./configure --prefix=/usr   \
            --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

Gzip-1.11

https://linuxfromscratch.org/lfs/view/stable/chapter06/gzip.html

tar -xvf gzip-1.11.tar.xz 
cd gzip-1.11.tar
./configure --prefix=/usr --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

Make-4.3

https://linuxfromscratch.org/lfs/view/stable/chapter06/make.html

cd make-4.3
./configure --prefix=/usr   \
            --without-guile \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

Patch-2.7.6

https://linuxfromscratch.org/lfs/view/stable/chapter06/patch.html

tar -xvf patch-2.7.6.tar.xz 
cd patch-2.7.6
./configure --prefix=/usr   \
            --host=$LFS_TGT \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

Sed-4.8

https://linuxfromscratch.org/lfs/view/stable/chapter06/sed.html

tar -xvf sed-4.8.tar.xz 
cd sed-4.8
./configure --prefix=/usr   \
            --host=$LFS_TGT
make -j4
make DESTDIR=$LFS install

Tar-1.34

https://linuxfromscratch.org/lfs/view/stable/chapter06/tar.html

tar -xvf tar-1.34.tar.xz 
cd tar-1.34 
./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess)
make -j4
make DESTDIR=$LFS install

Xz-5.2.5

https://linuxfromscratch.org/lfs/view/stable/chapter06/xz.html

tar -xvf xz-5.2.5.tar.xz
cd xz-5.2.5
./configure --prefix=/usr                     \
            --host=$LFS_TGT                   \
            --build=$(build-aux/config.guess) \
            --disable-static                  \
            --docdir=/usr/share/doc/xz-5.2.5
make -j4
make DESTDIR=$LFS install

Binutils-2.38 - Pass 2

https://linuxfromscratch.org/lfs/view/stable/chapter06/binutils-pass2.html

cd binutils-2.38
sed '6009s/$add_dir//' -i ltmain.sh
rm -rf build
mkdir -v build
cd       build
../configure                   \
    --prefix=/usr              \
    --build=$(../config.guess) \
    --host=$LFS_TGT            \
    --disable-nls              \
    --enable-shared            \
    --disable-werror           \
    --enable-64-bit-bfd
make -j4
make DESTDIR=$LFS install

GCC-11.2.0 - Pass 2

https://linuxfromscratch.org/lfs/view/stable/chapter06/gcc-pass2.html

rm gcc-11.2.0 -rf
tar -xvf gcc-11.2.0.tar.xz
cd gcc-11.2.0
tar -xf ../mpfr-4.1.0.tar.xz
mv -v mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv -v mpc-1.2.1 mpc
case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  ;;
esac
mkdir -v build
cd       build
mkdir -pv $LFS_TGT/libgcc
ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h
../configure                                       \
    --build=$(../config.guess)                     \
    --host=$LFS_TGT                                \
    --prefix=/usr                                  \
    CC_FOR_TARGET=$LFS_TGT-gcc                     \
    --with-build-sysroot=$LFS                      \
    --enable-initfini-array                        \
    --disable-nls                                  \
    --disable-multilib                             \
    --disable-decimal-float                        \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libquadmath                          \
    --disable-libssp                               \
    --disable-libvtv                               \
    --disable-libstdcxx                            \
    --enable-languages=c,c++
make -j4
make DESTDIR=$LFS install
ln -sv gcc $LFS/usr/bin/cc

Changing Ownership

The directory /mnt/lfs is owned by the user lfs on my host.
I need to change that to the user root of my system.
I open a new terminal as root then copy past the content of the .bashrc of lfs in the terminal.

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
CONFIG_SITE=$LFS/usr/share/config.site
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE

I know I could just export the $LFS and $LFS_TGT.

chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,tools}
case $(uname -m) in
  x86_64) chown -R root:root $LFS/lib64 ;;
esac

Preparing Virtual Kernel File Systems

https://linuxfromscratch.org/lfs/view/stable/chapter07/kernfs.html

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

Entering the Chroot Environment

chroot "$LFS" /usr/bin/env -i   \
    HOME=/root                  \
    TERM="$TERM"                \
    PS1='(lfs chroot) \u:\w\$ ' \
    PATH=/usr/bin:/usr/sbin     \
    /bin/bash --login


I have no name: This is normal because the /etc/passwd file has not been created yet.

Creating Directories

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/}{include,src}
mkdir -pv /usr/local/{bin,lib,sbin}
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

You can also create more directories:
https://refspecs.linuxfoundation.org/fhs.shtml

https://linuxfromscratch.org/lfs/view/stable/chapter07/createfiles.html
Don’t copy past this, it’s bugy, copy it from the LFS above.

ln -sv /proc/self/mounts /etc/mtab
cat > /etc/hosts << EOF
127.0.0.1  localhost $(hostname)
::1        localhost
EOF
cat > /etc/passwd << "EOF"
`root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/dev/null:/usr/bin/false daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false nobody:x:99:99:Unprivileged User:/dev/null:/usr/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: uuidd:x:80: wheel:x:97: nogroup:x:99: users:x:999:`
EOF
echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd
echo "tester:x:101:" >> /etc/group
install -o tester -d /home/tester
exec /usr/bin/bash --login
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

Libstdc++ from GCC-11.2.0, Pass 2

https://linuxfromscratch.org/lfs/view/stable/chapter07/gcc-libstdc++-pass2.html

cd /sources/gcc-11.2.0
ln -s gthr-posix.h libgcc/gthr-default.h
mkdir -v build
cd       build
../libstdc++-v3/configure            \
    CXXFLAGS="-g -O2 -D_GNU_SOURCE"  \
    --prefix=/usr                    \
    --disable-multilib               \
    --disable-nls                    \
    --host=$(uname -m)-lfs-linux-gnu \
    --disable-libstdcxx-pch
make -j4
make install

Gettext-0.21

https://linuxfromscratch.org/lfs/view/stable/chapter07/gettext.html

tar -xf gettext-0.21.tar.xz
cd gettext-0.21
./configure --disable-shared
make -j4
cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin

Bison-3.8.2

https://linuxfromscratch.org/lfs/view/stable/chapter07/bison.html

tar -xf bison-3.8.2.tar.xz
cd bison-3.8.2
./configure --prefix=/usr \
            --docdir=/usr/share/doc/bison-3.8.2
make -j4
make install

Perl-5.34.0

https://linuxfromscratch.org/lfs/view/stable/chapter07/perl.html

cd ../
tar -xf perl-5.34.0.tar.xz
cd perl-5.34.0
sh Configure -des                                        \
             -Dprefix=/usr                               \
             -Dvendorprefix=/usr                         \
             -Dprivlib=/usr/lib/perl5/5.34/core_perl     \
             -Darchlib=/usr/lib/perl5/5.34/core_perl     \
             -Dsitelib=/usr/lib/perl5/5.34/site_perl     \
             -Dsitearch=/usr/lib/perl5/5.34/site_perl    \
             -Dvendorlib=/usr/lib/perl5/5.34/vendor_perl \
             -Dvendorarch=/usr/lib/perl5/5.34/vendor_perl
make -j4
make install

Python-3.10.2

https://linuxfromscratch.org/lfs/view/stable/chapter07/Python.html

tar -xf Python-3.10.2.tar.xz
cd Python-3.10.2
./configure --prefix=/usr   \
            --enable-shared \
            --without-ensurepip
make -j4
make install

Texinfo-6.8

https://linuxfromscratch.org/lfs/view/stable/chapter07/texinfo.html

sed -e 's/__attribute_nonnull__/__nonnull/' \
    -i gnulib/lib/malloc/dynarray-skeleton.c
./configure --prefix=/usr
make -j4
make install

Util-linux-2.37.4

https://linuxfromscratch.org/lfs/view/stable/chapter07/util-linux.html

mkdir -pv /var/lib/hwclock
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime    \
            --libdir=/usr/lib    \
            --docdir=/usr/share/doc/util-linux-2.37.4 \
            --disable-chfn-chsh  \
            --disable-login      \
            --disable-nologin    \
            --disable-su         \
            --disable-setpriv    \
            --disable-runuser    \
            --disable-pylibmount \
            --disable-static     \
            --without-python     \
            runstatedir=/run
make -j4
make install

Cleaning

rm -rf /usr/share/{info,man,doc}/*
find /usr/{lib,libexec} -name \*.la -delete
rm -rf /tools

Backup

exit
umount $LFS/dev/pts
umount $LFS/{sys,proc,run,dev}
cd $LFS
tar -cJpf $HOME/lfs-temp-tools-11.1.tar.xz /iso

Restore

cd $LFS
rm -rf ./*
tar -xpf $HOME/lfs-temp-tools-11.1.tar.xz

https://linuxfromscratch.org/lfs/view/stable/part4.html

Installation of Man-pages

make prefix=/usr install

Installation of Iana-Etc

cp services protocols /etc

Installation of Glibc

patch -Np1 -i ../glibc-2.35-fhs-1.patch
mkdir -v build
cd       build
echo "rootsbindir=/usr/sbin" > configparms
../configure --prefix=/usr                            \
             --disable-werror                         \
             --enable-kernel=3.2                      \
             --enable-stack-protector=strong          \
             --with-headers=/usr/include              \
             libc_cv_slibdir=/usr/lib
make -j4
make check