Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).


L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT → ODT PDF Export

preseed debian

  • Objet : Installation automatisée de debian avec un preseed
  • Niveau requis :
  • Commentaires : Permet de personnaliser l'installation de debian au point de ne plus avoir besoin d'y toucher.
  • Suivi :
    • Création par Thuban le 18/11/2014
    • Testé par <…> le <…>
  • Commentaires sur le forum : Lien vers le forum concernant ce tuto 1)

Installer debian sans écran automatiquement

Vous souhaitez installer debian sur une machine. Cependant, vous ne disposez pas d'écran, vous n'avez que l'unité centrale (Ben oui, maintenant que vous utilisez un portable).

Ou bien c'est d'un clavier que vous n'avez pas. Ou encore vous voulez installer debian sur plusieurs machines à la suite et avez la flemme (*du travail à faire).

Pour ma part, je me suis servi de ce principe pour installer debian automatiquement, ainsi que le paquet openssh-server. Comme ça, à distance, j'ai pu ensuite personnaliser l'installation via ssh.

Cette page présente comment résoudre ce problème grâce au preseed.

Personnaliser une iso de debian

Tout d'abord, récupérez une image d'installation de debian. Une image netinstall devrait suffire.
Ensuite, on va créer deux répertoires :

  1. isoorig : il contiendra le contenu de l'image d'origine
  2. isonew : il contiendra le contenu de votre image personnalisée

On monte ensuite l'iso téléchargée dans isoorig, puis on copie son contenu dans isonew.

mkdir isoorig isonew
mount -o loop -t iso9660 debian-version-netinst.iso isoorig
rsync -a -Hexclude=TRANS.TBL isoorig/ isonew

Les modifications suivantes seront à réaliser dans le dossier isonew.

  • On va maintenant faire en sorte que l'installateur se charge automatiquement.
    Pour ça, on modifie le fichier isolinux/txt.cfg ainsi :
isolinux/txt.cfg
default install
  label install
      menu label ^Install
      menu default
      kernel /install.amd/vmlinuz
      append auto=true vga=normal file=/cdrom/preseed.cfg initrd=/install.amd/initrd.gz

Veillez à adapter install.amd/initrd.gz selon l'architecture utilisée. En cas de doute, regardez ce qu'il y a dans le dossier isoorig.

Ensuite, éditez isolinux/isolinux.cfg et isolinux/prompt.cfg et changez timeout 0 en timeout 4 par exemple.

Le fichier preseed.cfg

C'est là que ça devient intéressant. Nous allons créer un fichier preseed.cfg dans le dossier isonew. Dans ce fichier, on y mettra toutes les instructions dont l'installateur a besoin, comme ça, pas besoin d'utiliser le clavier.

Quelques lignes intéressantes :

  • Pour installer des paquets supplémentaires d-i pkgsel/include string openssh-server lftp fluxbox iceweasel
  • Pour définir le mot de passe de root : d-i passwd/root-password password password
  • Pour créer un utilisateur normal et définir son mot de passe.
extrait de preseed.cfg
 # To create a normal user account.
 d-i passwd/user-fullname string Player
 d-i passwd/username string player
 # Normal user's password, either in clear text
 d-i passwd/user-password password player
 d-i passwd/user-password-again password player

Je vous copie ci-dessous un preseed.cfg qui installe automatiquement debian (accès ethernet requis) avec / et/home séparés. ATTENTION, cela supprime donc tout ce qu'il y a sur le disque dur de l'ordinateur cible.

Le preseed.cfg :

fichier preseed.cfg
#### Contents of the preconfiguration file (for wheezy)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string fr_FR
d-i keymap select fr
 
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
 
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string preseeddebian
d-i netcfg/get_domain string preseeddebian
 
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
d-i hw-detect/load_firmware boolean false
 
### Network console
# Use the following settings if you wish to make use of the network-console
# component for remote installation over SSH. This only makes sense if you
# intend to perform the remainder of the installation manually.
#d-i anna/choose_modules string network-console
#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key
#d-i network-console/password password r00tme
#d-i network-console/password-again password r00tme
 
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.fr.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
 
# Suite to install.
d-i mirror/suite string stable
 
### Account setup
# Root password, either in clear text
d-i passwd/root-password password password
d-i passwd/root-password-again password password
 
# To create a normal user account.
d-i passwd/user-fullname string Player
d-i passwd/username string player
# Normal user's password, either in clear text
d-i passwd/user-password password player
d-i passwd/user-password-again password player
 
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
 
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Europe/Paris
 
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
 
# Alternatively, you may specify a disk to partition. If the system has only
# one disk the installer will default to using that, but otherwise the device
# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
# /dev/sda, and not e.g. /dev/discs/disc0/disc).
# For example, to use the first SCSI/SATA hard disk:
#d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm:     use LVM to partition the disk
# - crypto:  use LVM within an encrypted partition
d-i partman-auto/method string regular
 
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
 
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home:   separate /home partition
# - multi:  separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select home
 
# Or provide a recipe of your own...
# If you have a way to get a recipe file into the d-i environment, you can
# just point at it.
#d-i partman-auto/expert_recipe_file string /hd-media/recipe
 
# If not, you can put an entire recipe into the preconfiguration file in one
# (logical) line. This example creates a small /boot partition, suitable
# swap, and uses the rest of the space for the root partition:
#d-i partman-auto/expert_recipe string                         \
#      boot-root ::                                            \
#              40 50 100 ext3                                  \
#                      $primary{ } $bootable{ }                \
#                      method{ format } format{ }              \
#                      use_filesystem{ } filesystem{ ext3 }    \
#                      mountpoint{ /boot }                     \
#              .                                               \
#              500 10000 1000000000 ext3                       \
#                      method{ format } format{ }              \
#                      use_filesystem{ } filesystem{ ext3 }    \
#                      mountpoint{ / }                         \
#              .                                               \
#              64 512 300% linux-swap                          \
#                      method{ swap } format{ }                \
#              .
 
# The full recipe format is documented in the file partman-auto-recipe.txt
# included in the 'debian-installer' package or available from D-I source
# repository. This also documents how to specify settings such as file
# system labels, volume group names and which physical devices to include
# in a volume group.
 
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
 
# The kernel image (meta) package to be installed; "none" can be used if no
# kernel is to be installed.
d-i base-installer/kernel/image string linux-image-amd64
 
### Apt setup
# You can choose to install non-free and contrib software.
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
# Uncomment this if you don't want to use a network mirror.
#d-i apt-setup/use_mirror boolean false
# Select which update services to use; define the mirrors to be used.
# Values shown below are the normal defaults.
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/security_host string security.debian.org
 
### Package selection
tasksel tasksel/first multiselect standard
 
# Individual additional packages to install
d-i pkgsel/include string openssh-server 
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none
 
# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
# popular and include it on CDs.
popularity-contest popularity-contest/participate boolean false
 
## Grub
d-i grub-installer/only_debian boolean true
 
### Finishing up the installation
# During installations from serial console, the regular virtual consoles
# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next
# line to prevent this.
#d-i finish-install/keep-consoles boolean true
 
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
 
# This will prevent the installer from ejecting the CD during the reboot,
# which is useful in some situations.
#d-i cdrom-detect/eject boolean false
 
# This is how to make the installer shutdown when finished, but not
# reboot into the installed system.
#d-i debian-installer/exit/halt boolean true
# This will power off the machine instead of just halting it.
#d-i debian-installer/exit/poweroff boolean true
 
### Preseeding other packages
# Depending on what software you choose to install, or if things go wrong
# during the installation process, it's possible that other questions may
# be asked. You can preseed those too, of course. To get a list of every
# possible question that could be asked during an install, do an
# installation, and then run these commands:
#   debconf-get-selections --installer > file
#   debconf-get-selections >> file
 
 
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.
 
# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
#d-i partman/early_command \
#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh

Reconstruire l'iso

Une fois les modifications terminées, reconstruisez l'iso ainsi :

cd isonew
md5sum `find -follow -type f` > md5sum.txt
genisoimage -o ../custom_install.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ../isonew

Plus qu'à graver/copier sur usb et démarrer sur l'ordinateur où debian devra être installée.

Notez que cela fonctionne toutefois si le bios va chercher un cd sur lequel démarrer…

Ressources

1) N'hésitez pas à y faire part de vos remarques, succès, améliorations ou échecs !
doc/install/preseed.txt · Dernière modification: 26/11/2015 18:43 par milou

Pied de page des forums

Propulsé par FluxBB