Debian From Scratch (DFS) is a project that enables users to build a custom Debian operating system from the ground up, involving compilation of the kernel, system components, and software packages from source code. This process provides deep control over system configuration but requires intermediate to advanced Linux knowledge. Below is a structured guide based on available documentation and community practices.
Before starting, ensure your system meets the following requirements:
sudo apt install build-essential debootstrap pbuilder git make debhelper libncurses-dev bison flex libssl-dev. These tools are critical for compiling the kernel and system packages.The DFS process can be divided into key phases:
Create a dedicated working directory (e.g., ~/dfs) and navigate into it. Set environment variables (e.g., export DEBEMAIL="your@email.com", export DEBFULLNAME="Your Name") to avoid prompts during package builds.
Use debootstrap to fetch a minimal Debian base system. For example, to create a stretch (oldstable) base in ~/dfs/chroot:
sudo debootstrap stretch ~/dfs/chroot http://deb.debian.org/debian/
This downloads the core system files (kernel, libraries, utilities) needed to boot and configure the system.
Obtain the Debian kernel source (e.g., linux-source-6.1) via apt source linux-source-6.1. Configure the kernel by copying the current system’s config (cp /boot/config-$(uname -r) .config) and adjusting settings via make menuconfig (enable/disable drivers/features as needed). Compile the kernel using make-kpkg (Debian’s tool for creating .deb packages):
sudo make-kpkg --append-to-version=-custom --revision=1.0 kernel_image
Install the resulting .deb package (e.g., linux-image-6.1.0-custom_1.0_amd64.deb) with sudo dpkg -i.
For each desired package (e.g., coreutils, bash), download the source (via apt source package-name), install dependencies (sudo apt build-dep ./), and compile using dpkg-buildpackage -us -uc. Resolve dependency issues manually if prompted.
Mount an empty directory (e.g., ~/dfs/rootfs) as a loopback device and copy compiled binaries, libraries, and configuration files into it. Use chroot to enter the new filesystem and configure basic settings (see Configuration section below).
Key configuration steps include:
/etc/network/interfaces for static/DHCP settings (see Network Configuration below) or use NetworkManager for GUI management.dpkg-reconfigure tzdata and dpkg-reconfigure locales to set timezone and language preferences.adduser username and grant sudo privileges via usermod -aG sudo username.After configuring the system, perform these final tasks:
sudo apt install firefox vim) to meet your needs.sudo apt update && sudo apt upgrade to ensure all packages are current.genisoimage or mkisofs to convert the root filesystem into a bootable ISO for distribution/installation.DFS uses standard Debian networking tools. For wired connections, edit /etc/network/interfaces with static IP details:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
For DHCP, use:
auto eth0
iface eth0 inet dhcp
Restart networking with sudo systemctl restart networking. For wireless, install wpasupplicant and configure /etc/wpa_supplicant/wpa_supplicant.conf with your SSID and password.
For detailed guidance, refer to:
DFS is a complex but rewarding process for advanced users seeking a tailored Debian system. Always back up data before making changes and test configurations in a virtualized environment before deployment.