Tested with Debian 10 Buster.
This project is based on the Official LFS 10.0 Book
https://www.linuxfromscratch.org/lfs/view/10.0-systemd/index.html
Add the following packages
sudo apt install build-essential bison gawk git htop texinfo
Set these Enviornment Variables
export LFS=/mnt/lfs
export ALFS=/mnt/lfs/alfs
Create a new ext4 parition /dev/sdb1 (option n) and make it bootable (option a)
sudo fdisk /dev/sdb
Mount new ext4 partition
sudo mkdir $LFS
sudo mount -t ext4 /dev/sdb1 $LFS
Grab the alfs project files
sudo git clone https://github.com/Netetra/alfs-v10-systemd $ALFS
cd $ALFS
Verify required programs
sudo $ALFS/version_check.sh
Download toolchain source code from wget-list
sudo -E $ALFS/get_packages.sh
Setup the LFS user environment
sudo -E $ALFS/useradd_lfs.sh
These scripts are required to run as the new lfs user
sudo su lfs
$ALFS/scripts/build_toolchain.sh
$ALFS/scripts/build_temp-toolchain.sh
exit
Run as root with environment variables set earlier
sudo -E $ALFS/scripts/build_lfs.sh
Below the warning is how I installed grub while inside the chrooted LFS system
Consider reading the LFS book for backing up your bootloader.
https://www.linuxfromscratch.org/lfs/view/10.0-systemd//chapter10/grub.html
grub-install --root-directory=/ /dev/sdb
grub-mkconfig -o /boot/grub/grub.cfg
Updating grub defaults
vi /etc/default/grub
Get friendly eth0 network names and qemu console on boot.
GRUB_TERMINAL=console
GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0"
Remember to run grub-mkconfig to apply new grub default settings.
grub-mkconfig
Confirm that LFS and ALFS environment variables are both set and LFS partition is mounted.
Re-enter chroot and pass partition
sudo -E $ALFS/extras/chroot.sh /dev/sdb1
Emulate the LFS system with qemu (pass drive)
sudo -E $ALFS/extras/qemu.sh /dev/sdb
The root password in the LFS chrooted system is root.
The lfs user on the host system can be deleted with sudo deluser lfs
the lfs user /home/lfs folder can also be removed. It is only required to build the first toolchain.
This can happen if you are trying to boot from qemu and the entry for root=/dev/??? is not sda
Simply edit vi /boot/grub/grub.cfg
and change root references to sda1
root=/dev/sda1
When I am booting from my physical server I had to set it back to sdb1, because sda is my primary Debian installation.
root=/dev/sdb1
Linux From Scratch 10 Book
https://www.linuxfromscratch.org/lfs/view/10.0-systemd/
Beyond Linux From Scrach 10 Book
https://www.linuxfromscratch.org/blfs/view/10.0-systemd/
Added compressed single page versions to the books directory