Making LFS simple (mini-Debian)
For a while now, I’ve been wanting to make an LFS system, but I’ve always seen it as a hard guide to follow. I use Linux, sure, but I’m not that advanced yet, but I wanted to try LFS. Because I see LFS like that, I’ve found a solution, by using a small Debian system. I’ve added commands so you can follow along. The requirements are as follows:
- a Debian/Debian-based system
- a few GBs of disk space
debootstrap
If you don’t have debootstrap:
sudo apt update
sudo apt install debootstrap
1. Let’s make a root directory for DFS#
Let’s make a directory for DFS. I’ll call mine “dfs” in /mnt.
sudo mkdir -p /mnt/dfs
2. Let’s bootstrap a small Debian System#
Remember we installed debootstrap? Let’s use that to create a small Debian
system. I’ll make a Debian 13 system, amd64 and using the Debian repositories:
sudo debootstrap --arch=amd64 trixie /mnt/dfs http://deb.debian.org/debian
3. Let’s chroot into it#
First, we need to mount some essential folders (/dev, /proc, /sys), which
our minimal system does not have. Let’s mount those now:
sudo mount --bind /dev /mnt/dfs/dev
sudo mount --bind /proc /mnt/dfs/proc
sudo mount --bind /sys /mnt/dfs/sys
Okay, now that we’ve done that, let’s chroot into it:
sudo chroot /mnt/dfs /bin/bash
4. Let’s set some basic configuration#
I’m assuming you want to use this in a container, so I will not be covering
fstab. There are a lot of better guides than this one that show you exactly
how to set up fstab. Let’s set up the hostname:
echo "mini-debian" > /etc/hostname
apt sources:
cat > /etc/apt/sources.list <<EOF
deb http://deb.debian.org/debian trixie main
deb http://deb.debian.org/debian trixie-updates main
deb http://security.debian.org/debian-security trixie-security main
EOF
Add a user:
adduser lfs
usermod -aG sudo lfs
5. We’re done!#
You can now exit chroot and use this small Debian system!