Debian live personnalisée - Configuration par défaut

Debian live personnalisée - Configuration par défaut

Mise à jour : Debian 10.5 / Buster

L'objectif est ici de construire une image iso Debian live personnalisée. La construction s'effectue à partir d'un système linux opérationnel, avec l'assistance du paquet live-build.

Cette première partie décrit l'utilisation de live-build avec la configuration par défaut

L'utilisation d'une configuration personnalisée est décrite dans une deuxième partie : Debian live personnalisée - Configuration avancée

Références :

   Commandes porcelaine principales
lb config(1)
creates configuration for live-build

lb bootstrap(1)
executes the first build stage, creating (bootstraping) a basic Debian root fi‐
lesystem

lb chroot(1)
executes the second build stage, building the live OS filesystem

lb installer(1)
executes the third build stage, obtaining installer components (optional)

lb binary(1)
executes the fourth build stage, generating a binary image

lb source(1)
executes the fifth build stage, generating a source image (optional)

lb clean(1)
cleans up system build directories

Sommaire

1 - Installation

$ sudo aptitude install live-build
$ man lb_config
$ man live-config
$ man lb_build
$ man lb_clean
$ mkdir debian_live && cd debian_live
$ mkdir auto
$ cp /usr/share/doc/live-build/examples/auto/* auto/

2 - Utilisation

2.1 - Principe

La construction d'une image Debian live s'effectue en deux grandes étapes : la configuration et la construction de l'image

La configuration consiste à

Une fois le système configuré, la construction de l'image est automatique et comprend

2.2 - Utilisation

$ lb  config
$ sudo lb build

2.2.1 Configuration

$ lb config        # Attention lancer la commande avec les droits utilisateurs
$ lb config
[2020-08-31 22:51:15] lb config
P: Executing auto/config script.
[2020-08-31 22:51:15] lb config noauto
P: Updating config tree for a debian/stretch/amd64 system
P: Symlinking hooks...
$ cat config/bootstrap |grep -i Distribution
# $LB_DISTRIBUTION: select distribution to use
LB_DISTRIBUTION="stretch"
# $LB_PARENT_DISTRIBUTION: select parent distribution to use
LB_PARENT_DISTRIBUTION="stretch"
# $LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION: select parent distribution for debian-installer to use
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="stretch
$ cat config/chroot |grep updates
# $LB_SECURITY: enable security updates
# $LB_UPDATES: enable updates updates
# $LB_BACKPORTS: enable backports updates
$ cat config/binary |grep UEFI
# $LB_UEFI_SECURE_BOOT: enable/disable UEFI secure boot
LB_UEFI_SECURE_BOOT="auto"

$ cat config/binary |grep -i firmware
# $LB_FIRMWARE_BINARY: include firmware packages in debian-installer
LB_FIRMWARE_BINARY="true"
# $LB_FIRMWARE_CHROOT: include firmware packages in debian-installer
LB_FIRMWARE_CHROOT="true"
$ cat config/source |grep -i source
# config/source - options for live-build(7), source stage
# $LB_SOURCE: set source option
LB_SOURCE="false"
# $LB_SOURCE_IMAGES: set image type
LB_SOURCE_IMAGES="tar"
$ cat config/common |grep -i source
# $LB_APT_SOURCE_ARCHIVES: set apt/aptitude source entries in sources.list
LB_APT_SOURCE_ARCHIVES="true"

2.2.2 Recherche et vérification des paramètres de configuration

--distribution "buster"
$ for i in config/{bootstrap,chroot,binary,common} ; \
do echo $i ; cat $i | grep -a1 -i "buster" ; done
$ for i in config/{bootstrap,chroot,binary,common} ; \
do echo $i ; cat $i | grep -a1 -i "buster" ; done
config/bootstrap
# $LB_DISTRIBUTION: select distribution to use
# (Default: buster)
LB_DISTRIBUTION="buster"

# $LB_PARENT_DISTRIBUTION: select parent distribution to use
# (Default: buster)
LB_PARENT_DISTRIBUTION="buster"

# $LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION: select parent distribution for debian-installer to use
# (Default: buster)
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="buster"

config/chroot
config/binary
# (Default: empty)
LB_DEBIAN_INSTALLER_DISTRIBUTION="buster"

--
# $LB_ISO_VOLUME: set iso volume (max 32 chars)
# (Default: Debian buster $(date +%Y%m%d-%H:%M))
LB_ISO_VOLUME="Debian buster $(date +%Y%m%d-%H:%M)"

config/common

2.2.3 Construction

$ sudo lb build    # Attention : lancer la commande avec les droits super-utilisateur
  création d'une image iso
.......
......
$ ls *.iso
live-image-amd64.hybrid.iso
$ cat build.log
$ grep W: build.log 
W: UEFI Secure Boot disabled due to missing signed Grub/Shim.
$ ls binary

3 - Test de l'image

3.1 - Caractéristiques de l'image

Avec la configuration par défaut, les caractéristiques principales de l'image sont :

3.2 - Test sous émulateur

$ qemu-system-x86_64 -enable-kvm -cpu host -m 2048 -smp 4 \
-drive media=cdrom,format=raw,file=live-image-amd64.hybrid.iso -boot d
$ qemu-system-x86_64 -enable-kvm -cpu host -m 2048 -smp 4 \
-drive media=cdrom,format=raw,file=live-image-amd64.hybrid.iso -boot d \ -bios /usr/share/ovmf/OVMF.fd \
-vga virtio
$ cp /opt/suze/ovmf/OVMF_CODE.secboot.fd ./ && cp /opt/suze/ovmf/OVMF_VARS.secboot.fd ./

$ qemu-system-x86_64 -enable-kvm -cpu host -m 2048 -smp 4 \
-machine pc-q35-2.5 \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd \
-drive format=raw,media=cdrom,file=live-image-amd64.hybrid.iso -boot d \
-vga virtio

debian-live-personnalisé

locales=fr_FR.UTF-8 keyboard-layouts=fr
$ sudo apt install console-setup
$ sudo dpkg-reconfigure console-setup
$ sudo dpkg-reconfigure keyboard-configuration
$ sudo dpkg-reconfigure locales

3.3 - Utilisation depuis une clé

$ sudo dd if=live-image-amd64.hybrid.iso of=/dev/sdb bs=4M conv=fsync

Annexe - Contenu du répertoire de travail

1 - Fichiers et dossiers relatifs à la configuration

$ ls auto
build clean config
$ ls config/
apt build hooks includes.chroot packages rootfs
archives chroot includes includes.installer packages.binary source
binary common includes.binary includes.source packages.chroot
bootstrap debian-installer includes.bootstrap package-lists preseed
config/boostrap
config/chroot
config/common
config/source
config/binary

2 - Cache des paquets téléchargés

$ ls -l cache
total 36
drwxr-xr-x 17 root root 4096 août 31 11:01 bootstrap
drwxr-xr-x 2 root root 4096 août 31 11:01 contents.chroot
drwxr-xr-x 2 root root 12288 août 31 11:05 packages.binary
drwxr-xr-x 2 root root 12288 août 31 11:00 packages.bootstrap
drwxr-xr-x 2 root root 4096 août 31 11:02 packages.chroot
$ ls -l cache/packages.bootstrap |grep wget
-rw-r--r-- 1 root root 799516 août 31 18:13 wget_1.18-5+deb9u3_amd64.deb
$ ls -l cache/packages.chroot/ |grep linux-image
-rw-r--r-- 1 root root 39307534 juil. 6 19:00 linux-image-4.9.0-13-amd64_4.9.228-1_amd64.deb
-rw-r--r-- 1 root root 7182 juil. 6 23:27 linux-image-amd64_4.9+80+deb9u11_amd64.deb
$ ls -l cache/packages.binary |grep xorriso
-rw-r--r-- 1 root root 299252 oct. 11 2016 xorriso_1.4.6-1+b1_amd64.deb

3 - Système chooté et fichiers relatifs au chroot

ls -l ./ |grep chroot
drwxr-xr-x 17 root root 4096 août 31 11:05 chrootchro
-rw-r--r-- 1 root root 1098104 août 31 11:02 chroot.files
-rw-r--r-- 1 root root 4986 août 31 11:02 chroot.packages.install
-rw-r--r-- 1 root root 4986 août 31 11:02 chroot.packages.live
$ cat chroot/etc/debian_version
$ cat chroot/etc/apt/sources.list

4 - Fichiers relatifs à l'image finale

Les dossiers et fichiers relatifs à l'image finale :
$ ls binary
boot EFI efi.img isolinux live md5sum.txt
live-image-amd64.hybrid.iso  # Image iso
live-image-amd64.hybrid.iso.zsync # ?
$ cat live-image-amd64.files
.:
total 76
drwxr-xr-x 2 root root 4096 Aug 26 08:41 bin
drwxr-xr-x 2 root root 4096 Aug 26 08:41 boot
drwxr-xr-x 4 root root 4096 Aug 26 08:34 dev
drwxr-xr-x 57 root root 4096 Aug 26 08:41 etc
drwxr-xr-x 2 root root 4096 Jul 13 13:04 home
lrwxrwxrwx 1 root root 29 Aug 26 08:41 initrd.img -> boot/initrd.img-4.9.0-3-amd64
lrwxrwxrwx 1 root root 29 Aug 26 08:41 initrd.img.old -> boot/initrd.img-4.9.0-3-amd64
......
$ cat live-image-amd64.contents 

/boot
.....
/live/filesystem.squashfs
/live/initrd.img
/live/initrd.img-4.9.0-3-amd64
/live/vmlinuz
/live/vmlinuz-4.9.0-3-amd64
....
$ cat live-image-amd64.packages 

aptitude-common 0.8.7-1
base-files 9.9+deb9u1
base-passwd 3.5.43
........

5 - Divers

$ cat build.log

$ grep W build.log