notes and some scripts to build Linux From Scratch 12
To you get started depending on your OS follow one of these guides:
- NixOS (or any other Linux with nix package manager) - README-nix.md
- OpenSUSE - README-opensuse.md
- RHEL, Fedora, Alma Linux - README-beret.md
And run this script to verify:
./check-versions.sh
set environment variables (if you are using the nix-shell you don't need to do this):
export LC_ALL=POSIX
export LFS=/mnt/lfs
export LFS_TGT=$(uname -m)-lfs-linux-gnu
export CONFIG_SITE=$LFS/usr/share/config.site
export PATH=$LFS/tools/bin:$PATH
export NPROC=$(nproc)
export MAKEFLAGS="-j$NPROC"
umask 022
prepare.sh
is going to download packages from wget-list-sysv and store them in ./sources
folder to be re-used in later executions.
Delete the folder if you change the list of packages.
Sources are basically LFS 12 wget-list-sysv + sudo
and curl
# defaults
# LFS_DISK_IMAGE=lfs.img
# LFS_DISK_SIZE_GB=50
LFS_DISK_IMAGE=/mnt/storage/lfs-my-image.img \
LFS_DISK_SIZE_GB=100 \
./prepare.sh
You can follow README-manual.md to execute the commands one by one (note that the instructions are less complete and you are going to have to improvise at the end to get it all working)
..or you can run the scripts that automate this process:
./install.sh
and verify the compiler it's working:
echo 'int main(){}' | $LFS_TGT-gcc -xc -
readelf -l a.out | grep ld-linux
#cleanup
rm -v a.out
it if all looks good, execute the second step:
./install2.sh
Copy config files:
cp ./etc/* $LFS/etc/
Set permissions and mount directories to host
sudo chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,tools,lib64}
sudo mkdir -pv $LFS/{dev,proc,sys,run,tmp}
./chroot-mount.sh
Copy install scripts in the new fs:
mkdir $LFS/opt
cp install3.sh $LFS/opt
cp install4.sh $LFS/opt
Enter chroot:
sudo mkdir -pv $LFS/root
sudo chroot "$LFS" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS="-j${NPROC}" \
/bin/bash --login
run install script 3:
/opt/install3.sh
and when successful run install 4
/opt/install4.sh
sudo
is configured to allow access to all users in the wheel
group so if you need new user
mkdir -pv /home/myuser
useradd -d /home/myuser
usermod -a -G wheel myuser
if the host is connected to the internet, you should just configure DNS for the chrooted environment
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
# End /etc/resolv.conf
EOF
echo "bilfs" > /etc/hostname
Root SSL certificates are not installed so if you want to use curl for https links, you would need to run
echo "--insecure" >> ~/.curlrc
to turn off SSL checks
exit the chroot and umount
./chroot-umount.sh
delete your disk
rm lfs.img
remove sources
rm -rf ./sources