Archives par étiquette : preseed

Debian – Installation automatisée

Un petit memo pour faire une image (ISO) d’installation automatisée d’une Debian, ici c’est pour une Squeeze, mais la méthode est valable pour les autres versions.

Il faut disposer d’un fichier de preseed, des droits root et d’une image du CD d’installation.

On commence par créer un fichier de preseed, c’est un fichier texte qui contient les réponses aux questions posées durant l’installation.
Voici un fichier d’exemple où il faut juste donner les informations réseau et de partitionnement :

# Locales
d-i debian-installer/language string en
d-i debian-installer/country string FR
d-i debian-installer/locale string en_US.UTF-8

d-i debian-installer/fallbacklocale select fr_FR.UTF-8
d-i debian-installer/locale select en_US.UTF-8

# Keyboard
d-i console-keymaps-at/keymap select fr-latin9
d-i debian-installer/keymap string fr-latin9

# Network
d-i netcfg/choose_interface select auto
d-i netcfg/disable_dhcp boolean false
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/confirm_static boolean true
d-i netcfg/wireless_wep string
d-i hw-detect/load_firmware boolean true

# Users
d-i passwd/root-login boolean true
d-i passwd/root-password password passwordRootTemporaire
d-i passwd/root-password-again password passwordRootTemporaire
d-i passwd/make-user boolean false

# Clock
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Paris
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string mon.serveur.ntp

# Miroirs
d-i mirror/country string manual
d-i mirror/http/hostname string mon.miroir.debian:8080
d-i mirror/http/directory string /debian
d-i mirror/suite string squeeze
d-i mirror/http/proxy string
d-i mirror/protocol select http
d-i mirror/codename string squeeze
d-i mirror/http/mirror select mon.miroir.debian:8080

# APT
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
d-i apt-setup/services-select multiselect
popularity-contest popularity-contest/participate boolean false
# Update
d-i pkgsel/upgrade select full-upgrade

# Paquets : on ajoute le serveur SSH
tasksel tasksel/first multiselect none
d-i pkgsel/include string openssh-server

# Grub
d-i grub-installer/only_debian boolean true

# Reboot automatically
d-i finish-install/reboot_in_progress note

On passe root :

su -<br>

Puis on créé une arborescence dans TMP :

rm -rf /tmp/preseed && mkdir -p /tmp/preseed/tmp && cd /tmp/preseed/tmp<br>

On copie l’ISO et le fichier de preseed dans le dossier /tmp/preseed.
Selon l’architecture, on déclare quelques variables :
La version utilisée :
export VERSION=6.0.1a
En 32bits :

export ARCH=i386
export sARCH=386

En 64bits :

export ARCH=amd64
export sARCH=amd

Puis on fabrique l’image :

mkdir debian-$VERSION-$ARCH initrd &&
bsdtar -C ./debian-$VERSION-$ARCH -xf ../debian-$VERSION-$ARCH-netinst-non-free.iso &&
cd initrd/ &&
gunzip -c ../debian-$VERSION-$ARCH/install.$sARCH/initrd.gz | cpio -id &&
cp ../../preseed.cfg . &&
find . | cpio --create --format='newc' | gzip > ../initrd.gz &&
cd .. &&
chmod u+w debian-$VERSION-$ARCH/install.$sARCH &&
cp initrd.gz debian-$VERSION-$ARCH/install.$sARCH/initrd.gz &&
chmod u-w debian-$VERSION-$ARCH/install.$sARCH &&
cd debian-$VERSION-$ARCH/ &&
md5sum `find ! -name "md5sum.txt" ! -path "./isolinux/*" ! -name "debian" -follow -type f` > ./md5sum.txt &&
cd .. &&
genisoimage -o ./debian-$VERSION-$ARCH-preseed.iso -V di`date -u +%m%d%H%M%S` -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ./debian-$VERSION-$ARCH &&
rm -rf debian-$VERSION-$ARCH initrd initrd.gz

Vous avez maintenant une ISO toute fraiche.

sources :