Salta al contenuto principale

Build Debian live CD and USB with live-build

Build a Debian live CD or a live USB with live-build. We will go through three steps: creating a Git repository to track all code modifications, installing live-build on our Debian distribution, and configuring and building the .iso file.

Create Git Repository

We can use an online repository, such as GitLab.
Create a new project, for example, "Fabian-os," and a quick for the project home.
It is necessary to add the SSH public keys to the project settings to have full access to the repository.

Clone the repository. You can find the clone button on the home page with two options: HTTPS or SSH.
In this case, we use SSH to be able to push commits with the new code.

$ git clone [email protected]:undj/fabian-os.git

The repository directory will be where we work and store all the live-build configurations.
Since our Git repository doesn't need to include all files downloaded by live-build, we should exclude them using the .gitignore provided in our repo.

Install live-build

The live-build package can be found and installed directly from the Debian repository, in all branches from Debian stable to sid.
Install live-build with:

$ sudo apt install live-build

Using live-build

The live-build package provides the executable lb, used to create the environment, build the live distribution, and clean up.

Configure the Environment with lb config

We configure the environment of our live CD using lb config inside the Git directory:

$ sudo lb config

This command will download and create the configuration files necessary to build the distribution.
We can add and push the files to Git to keep track of the first default configuration.

$ git add .
$ git commit -m "first configuration"
$ git push

Configuration Files

The main configuration is auto/config:

$ cat auto/config
set -e
lb config noauto \
    --mode debian \
    --architectures amd64 \
    --debian-installer live \
    --archive-areas "main contrib non-free" \
    --apt-indices false \
    --memtest none \
    -d buster \
    --compression lzip \
    --system live \
    --backports true \
    --bootappend-live "boot=live components locales=it_IT.UTF-8 keyboard-layouts=it splash" \
    --mirror-bootstrap \
    --mirror-binary \

Let's see the definitions in the script:

-d|--distribution CODENAME
    defines the distribution of the resulting live system
--compression bzip2|gzip|lzip|none
    defines the compression program to be used to compress tarballs.
--mode debian|progress|ubuntu
    defines a global mode to load project-specific defaults.
-a|--architectures ARCHITECTURE
    defines the architecture of the to-be-built image.
    defines which package archive areas of a Debian package archive should be used for configured Debian package mirrors.
--system live|normal
    defines if the resulting system image should be a live system or a normal, non-live system.

The full manual can be found on the lb config Debian man pages.

We can add some packages by creating a list in the package-list directory:

$ nano config/package-lists/

Execute scripts in the live CD chroot by adding them to this directory:

$ nano config/hooks/live/

It is possible to include files in the chroot using the same directory tree as the one desired in the live CD by adding them to this directory:


Build Debian live CD with lb build

We can now build the live CD with live-build. This will download all the packages from the mirror and create the .iso file of the distribution:

$ sudo lb build

After the completion of the process or to build a new version, we need to clean up the environment from the previous build:

$ sudo lb clean

Final Credits

This work has been done in collaboration with the Cagliari's Fablab, to create the custom distribution Fabian. Many thanks for the opportunity!

Aggiungi un commento

Text Only

  • Nessun tag HTML consentito.