I did LFS8.2 originally, but the time was limited, so I went to ALFS. There are no fewer potholes than LFS.


The first is the environment

Vmware Workstation Pro 14 Debian9.5, a virtual hard disk with 20 GB of ram, 12GB of ram, 4 x 2.7 GHz UEFI grub2 boot

Check the dependency environment

cat > version-check.sh << "EOF"
#! /bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d"" -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH

echo -n "Binutils: "; ld --version | head -n1 | cut -d"" -f3-
bison --version | head -n1

if [ -h /usr/bin/yacc ]; then
  echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
  echo yacc is `/usr/bin/yacc --version | head -n1`
else
  echo "yacc not found" 
fi

bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d"" -f1, 6 -echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1

if [ -h /usr/bin/awk ]; then
  echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
  echo awk is `/usr/bin/awk --version | head -n1`
else 
  echo "awk not found" 
fi

gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d"" -f2 -# glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1
xz --version | head -n1

echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
  then echo "g++ compilation OK";
  else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
EOF

bash version-check.shCopy the code

Then make up the dependency as the case may be

By default you should have the following packages installed for development

sudo apt install build-essential texinfo m4 gawk bison Copy the code

/bin/sh points to Dash instead of bash

sudo ln -s bash /bin/sh -f
Copy the code

Checking library consistency

cat > library-check.sh << "EOF"
#! /bin/bash
for lib in lib{gmp,mpfr,mpc}.la; do
  echo $lib: $(if find /usr/lib* -name $lib|
               grep -q $lib;then :;else echo not;fi) found
done
unset lib
EOF

bash library-check.shCopy the code

It’s either none or both, and I have both

download

Automatic script jhalfs download address LFS8.0 software package download address (not sure whether the official give is complete, the last 8.2 package is missing a package) download LFS8.0 book, need to use SVN, It will be downloaded to the 8.0 folder in the current directory.

sudo apt install subversionCopy the code

download

SVN co svn://svn.linuxfromscratch.org/LFS/tags/8.0Copy the code

Go to 8.0 and change the MD5 value of lfs-bootscripts-20150222.tar.bz2 in the packes. ent file

   7ee67b16b345b43cdIt is wrong to 34 ed481792169ed is amended as: 3 cb3d36089f2d6ab19c7c0f3282de1c5Copy the code

Prepare directories and configurations

Create a directory

sudo mkdir /mnt/lfs
Copy the code

($LFS variable does not need to be set)

Create a jhalfs account as user root

groupadd jhalfs
useradd -s /bin/bash -g jhalfs -m -k /dev/null jhalfs
Copy the code

Set the password to jhalfs as user root

passwd jhalfs
Copy the code

Edit /etc/sudoers as user root

nano /etc/sudoersCopy the code

Add jhalfs ALL=(ALL:ALL) ALL

Decompress the Jhalfs script

The tar xf jhalfs - 2.4. Tar. XzCopy the code

The configuration script

cdJhalfs - 2.4 makeCopy the code

If Unable to find the ncurses libraries fails, install libnCurses5-dev

sudo apt install libncurses5-dev
Copy the code

Reconfigure the script

make clean
makeCopy the code

Configuration is basically

LFS compile directory Time zone set to Asia/Shanghai Select Installthe Full set of Locales

Everything else can be done by default. Kernel and fstab will be manually configured later

Xsltproc needs to be installed

sudo apt install xsltproc
Copy the code

Re-make, load the saved configuration, exit, type yes to confirm the configuration and then find a source folder in the LFS compilation directory. Unpack the LFS package into it

Start automatic compilation

Start automatic compilation

Enter the jhalfs user

sudo su jhalfs
Copy the code

Compile (I set the compile directory to be/MNT/LFS)

cd /mnt/lfs
make -C /mnt/lfs/jhalfs
Copy the code

Then start compiling here and start seeing that the script seems to need a password, so go change /etc/sudoers

Change jhalfs ALL=(ALL:ALL) ALL to jhalfs ALL=(ALL)NOPASSWD:ALL

And then let it compile and wait and hope it doesn’t break.


Ok, the terminal displays the following message, no error

-------------------------------------------------------------------------------- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Finished the build of 8.0 -------------------------------------------------------------------------------- W A R N I N G -------------------------------------------------------------------------------- To be able to boot your new system you need to follow the next steps: - Mount the virtual kernel file systems. - Enter to the chroot using thecommand found
        in the section -Entering the Chroot Environment-
        except if building CLFS with METHOD=boot.

        - Set a password for the root user.

        - Edit or create /etc/fstab,
                         /etc/hosts,
                         /etc/sysconfig/clock,
                         /etc/sysconfig/console,
                         /etc/sysconfig/network,
                         /etc/sysconfig/ifconfig.eth0,
                         /etc/resolv.conf
        and any other configuration file required to suit your needs.

        - Set-up the boot loader, except if building CLFS with METHOD=boot.

        You can set-up the new boot-loader installed on the new system
        or the host bootloader.

        If the last, it is better to exit first from the chroot.

        - Exit from the chroot and umount the filesystems.

If you are an experienced LFS user, several of those steps can be
skipped or done in a different way. But then. that is something that you already know and there is no need to discuss it here. -------------------------------------------------------------------------------- Have a nice day :-) -------------------------------------------------------------------------------- make: Leaving directory'/mnt/lfs/jhalfs'
Copy the code

subsequent

After compiling, you need to copy the compiled system files to the new system partition. In addition, you can also make a copy of the system file as a backup, so as not to compile later, after all, the compilation will take a long time

cdCompile directory cp -r bin new partition cp -r dev new partition cp -r etc new partition cp -r lib new partition cp -r lib64 new partition cp -r media new partition cp -r MNT new partition cp -r opt new partition Cp -r proc New partition cp -r TMP new partition cp -r root new partition cp -r run new partition cp -r sbin new partition cp -r SRV new partition cp -r sys new partition cp -r usr new partition cp -r var Indicates a new partitionCopy the code

The new partition directory is displayed

cdNew partition directoryCopy the code

Mount and activate /dev

sudo mount -v --bind /dev ./dev
Copy the code

Mount a virtual file system

sudo mount -vt devpts devpts ./dev/pts -ogid=5,mode=620 sudo mount -vt proc proc ./proc sudo mount -vt sysfs sysfs ./sys  sudo mount -vt tmpfs tmpfs ./runCopy the code

Chroot to new partition

chroot ./ /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
Copy the code

And then I realized I couldn’t change my password, and I didn’t even enter it, and it just showed up for no reason

Root :/# passwd root Changing the password for root Please enter a new password (minimum of 5 characters) Use uppercase and lowercase letters and digits. Wrong password: too short. Warning: Weak password (reenter it to force it). Passwd: the password has been changed

According to the big god (cool you can table so call me/squint smile), is the problem of shadow, according to the 8.2 book recompile is good (originally 8.0, but 8.0 May be supernatural problems) can directly copy the following command, also can go to the official website to see, address

sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;
sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
       -e 's@/var/spool/mail@/var/mail@' etc/login.defs
sed -i 's/1000/999/' etc/useradd
./configure --sysconfdir=/etc --with-group-name-max-length=32
make
make install
mv -v /usr/bin/passwd /bin
pwconv
grpconv
Copy the code

Then you can happily change your password

Root :~# passwd root Changing the password for root Please enter a new password. The password must contain at least five characters. Use uppercase letters and digits. New password: Please enter a new password: passwd: the password has been changed.

You can copy the fstab file in the /boot directory of Debian by copying the grub and kernel

The UUID corresponding to GRUB and fstab needs to be changed. Run the following command to check the disk UUID

 ls -l /dev/disk/by-uuid
 vi /etc/fstab
 vi /boot/grub/grub.cfgCopy the code

So we have the Debian kernel and boot

Setting the host Name

echo "LFS" > /etc/hostname
Copy the code

Start the

Now the parent system can be shut down because it is a direct copy of Debian boot, so you can’t distinguish between hard drives. You need to remove the hard drive where the LFS is and create a new VM with the same configuration as the parent system, mainly UEFI boot

Finally, the startup fails. GG Smida (Gurb is deadly, no solution can be found for now)


Reprinted from https://www.lengqing.org/archives/37/ {lengqingzhuangbikuang_hhh ~}

(눈_눈)