Le but de ce blogpost est de présenter des outils installateur Ubuntu différent et de décrire une méthode installation Ubuntu 22.04 (Jammy) pour bureau et serveur.
Je suppose que vous avez un serveur DHCP, TFTP, HTTP fonctionnel.
Cet exemple montre comment configurer le serveur ISC DHCP pour démarrer une machine à l'aide d'un serveur TFTP.
allow booting;
allow bootp;
option arch code 93 = unsigned integer 16;
host ubuntu {
hardware ethernet xx:xx:xx:xx:xx:xx;
if option arch = 00:07 {
filename "boot/bootx64.efi";
} else {
filename "boot/pxelinux.0";
}
next-server x.x.x.x;
fixed-address x.x.x.x;
}
Obtenez le fichier installateur ISO et copiez les fichier grub suivants dans le répertoire TFTP.
Jammy ISO: /boot/fonts/unicode.pf2 /EFI/boot/bootx64.efi /EFI/boot/grubx64.efi
Télécharger les paquets pxelinux et extraire les fichiers suivants dans le répertoire TFTP.
$ apt download pxelinux syslinux-common pxelinux: /usr/lib/PXELINUX/pxelinux.0 syslinux-common: /usr/lib/syslinux/modules/bios/ldlinux.c32 /usr/lib/syslinux/modules/bios/libutil.c32 /usr/lib/syslinux/modules/bios/menu.c32
Vous pouvez organiser les fichier sur le serveur TFTP selon l'exemple suivant.
. ├── boot │ ├── bootx64.efi │ ├── grubx64.efi │ ├── grub │ │ ├── font.pf2 │ │ ├── grub.cfg │ │ └── x86_64-efi │ │ ├── command.lst │ │ ├── crypto.lst │ │ ├── fs.lst │ │ └── terminal.lst │ ├── jammy │ │ ├── initrd │ │ └── vmlinuz │ ├── ldlinux.c32 -> syslinux/bios/ldlinux.c32 | ├── libutil.c32 -> syslinux/bios/libutil.c32 | ├── menu.c32 -> syslinux/bios/menu.c32 │ ├── pxelinux.cfg │ │ └── default │ ├── pxelinux.0 | └── syslinux | └── bios │ ├── ldlinux.c32 │ ├── libutil.c32 │ └── menu.c32 └── grub -> boot/grub
Exemple de configuration pour grub dans grub.cfg.
set timeout=30
loadfont unicode
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry "Install Ubuntu Jammy (22.04)" {
set gfxpayload=keep
linux /boot/jammy/vmlinuz ip=dhcp cloud-config-url=/dev/null url=http://x.x.x.x/jammy-live-server-amd64.iso autoinstall ds="nocloud-net;s=http://x.x.x.x/jammy/" --- # Don't forget the slash at the end.
initrd /boot/jammy/initrd
}
Exemple de configuration dans pxelinux.cfg/default.
default menu.c32
menu title Ubuntu installer
label jammy
menu label Install Ubuntu J^ammy (22.04)
menu default
kernel jammy/vmlinuz
initrd jammy/initrd
append ip=dhcp cloud-config-url=/dev/null url=http://x.x.x.x/jammy-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://x.x.x.x/jammy/ # Don't forget the slash at the end.
prompt 0
timeout 300
Au moins deux fichiers doivent être placés sur le serveur web.
Même Canonical annonce autoinstall comme programme d'installation pour les serveur, cela peut être utilisé pour des système serveurs et bureau aussi.
Deux différence importantes par rapport à Debian Installer (d-i):
Une méthode facile pour obtenir un bon fichier configuration autoinstall user-data est d'installer une machine à la main. Apres, copiez le fichier /var/log/installer/autoinstall-user-data vers le serveur web et personnalisez-le.
Les exemples suivants sont crées en utilisant des machines virtuelles QEMU:
Paramètres noyeau Linux
Ces exemples de partitionnement sont préparés avec UEFI, voir BIOS boot disk layout si tu a un BIOS.
#cloud-config
autoinstall:
identity:
hostname: jammy-minimal
password: $6$gnqbMUzHhQzpDEw.$.cCNVVDsDfj5Feebh.5O4VbOmib7tyjmeI2ZsFP7VK2kWwgJFbfjvXo3chpeAqCgXWVIW9oNQ/Ag85PR0IsKD/
username: ubuntu
version: 1
Le mot de passe est ubuntu. Et cela peut être génerer en utilisant la commande suivante.
mkpasswd --method=sha-512 ubuntu
#cloud-config
autoinstall:
identity:
hostname: jammy-desktop
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
keyboard:
layout: hu
toggle: null
variant: ''
locale: hu_HU.UTF-8
storage:
config:
# Partition table
- { ptable: gpt, path: /dev/vda, wipe: superblock, preserve: false, name: '', grub_device: false, type: disk, id: disk-vda }
# EFI boot partition
- { device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-0 }
- { fstype: fat32, volume: partition-0, preserve: false, type: format, id: format-0 }
# Linux boot partition
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
- { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1 }
# Partition for LVM, VG
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
- { name: ubuntu-vg, devices: [ partition-2 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
# LV for root
- { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: -1, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2 }
# Mount points
- { path: /, device: format-2, type: mount, id: mount-2 }
- { path: /boot, device: format-1, type: mount, id: mount-1 }
- { path: /boot/efi, device: format-0, type: mount, id: mount-0 }
# Swapfile on root volume
swap:
swap: 1G
late-commands:
- 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
- chmod 440 /target/etc/sudoers.d/ubuntu-nopw
- curtin in-target --target=/target -- sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=""/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/' /etc/default/grub
- curtin in-target --target=/target -- apt-get install -y ubuntu-desktop plymouth-theme-ubuntu-logo grub-gfxpayload-lists
version: 1
La taille de la partition pour LVM et LV root est -1 qui dit au programme d'installation d'utiliser toute l'espace qui reste sur le disque. Une partition ou volume avec la taille size: -1 doit être le dernier dans la configuration. Dans l'exemple au dessus: l'installateur crée la dernière partition sur toute l'espace qui est disponible et crée le dernier volume logique sur toute l'espace qui est disponible dans le group de volume.
#cloud-config
autoinstall:
identity:
hostname: jammy-desktop-crypt
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
keyboard:
layout: hu
toggle: null
variant: ''
locale: hu_HU.UTF-8
storage:
config:
- { ptable: gpt, path: /dev/vda, wipe: superblock, preserve: false, name: '', grub_device: false, type: disk, id: disk-vda }
- { device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-0 }
- { fstype: fat32, volume: partition-0, preserve: false, type: format, id: format-0 }
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
- { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1 }
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
# DM crypt
- { volume: partition-2, key: ubuntu, preserve: false, type: dm_crypt, id: dm_crypt-0 }
- { name: ubuntu-vg, devices: [ dm_crypt-0 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: -1, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2 }
- { path: /, device: format-2, type: mount, id: mount-2 }
- { path: /boot, device: format-1, type: mount, id: mount-1 }
- { path: /boot/efi, device: format-0, type: mount, id: mount-0 }
swap:
swap: 1G
late-commands:
- 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
- chmod 440 /target/etc/sudoers.d/ubuntu-nopw
- curtin in-target --target=/target -- sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=""/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/' /etc/default/grub
- curtin in-target --target=/target -- apt-get install -y ubuntu-desktop plymouth-theme-ubuntu-logo grub-gfxpayload-lists
version: 1
Le clé DM crypt est ubuntu au format texte clair.
#cloud-config
autoinstall:
identity:
hostname: jammy-server
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
keyboard:
layout: hu
toggle: null
variant: ''
locale: hu_HU.UTF-8
ssh:
allow-pw: false
authorized-keys: [ '<SSH KEY>' ]
install-server: true
storage:
config:
- { ptable: gpt, path: /dev/vda, wipe: superblock, preserve: false, name: '', grub_device: false, type: disk, id: disk-vda }
- { device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-0 }
- { fstype: fat32, volume: partition-0, preserve: false, type: format, id: format-0 }
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
- { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1 }
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
- { name: ubuntu-vg, devices: [ partition-2 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 10G, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2 }
- { path: /, device: format-2, type: mount, id: mount-2 }
- { path: /boot, device: format-1, type: mount, id: mount-1 }
- { path: /boot/efi, device: format-0, type: mount, id: mount-0 }
# Swap LV
- { name: swap, volgroup: lvm_volgroup-0, size: 1073741824B, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-1 }
- { fstype: swap, volume: lvm_partition-1, preserve: false, type: format, id: format-3 }
- { path: '', device: format-3, type: mount, id: mount-3 }
late-commands:
- 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
- chmod 440 /target/etc/sudoers.d/ubuntu-nopw
version: 1
Une clé SSH peut être copier dans la machine toute récemment installée. Juste remplacez <SSH KEY> avec votre clé SSH publique (par exemple avec le sortie de cat ~/.ssh/id_rsa.pub). Authentification mot de passe SSH est interdit.
Cet exemple décrit le mis en oeuvre d'un LV au lieu d'une fichier d'échange sur le volume root.
#cloud-config
autoinstall:
identity:
hostname: jammy-server-raid
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
keyboard:
layout: hu
toggle: null
variant: ''
locale: hu_HU.UTF-8
ssh:
allow-pw: false
authorized-keys: [ '<SSH KEY>' ]
install-server: true
storage:
config:
# Partition table of two disks
- { ptable: gpt, path: /dev/vda, wipe: superblock-recursive, preserve: false, name: '', grub_device: false, type: disk, id: disk-vda }
- { ptable: gpt, path: /dev/vdb, wipe: superblock-recursive, preserve: false, name: '', grub_device: false, type: disk, id: disk-vdb }
# Install GRUB on first disk
- { device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-3 }
- { fstype: fat32, volume: partition-3, preserve: false, type: format, id: format-2 }
# Install GRUB on second disk
- { device: disk-vdb, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-8 }
- { fstype: fat32, volume: partition-8, preserve: false, type: format, id: format-5 }
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-9 }
- { device: disk-vdb, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-10 }
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-11 }
- { device: disk-vdb, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-12 }
# RAID1 for boot partition and root volume
- { name: md0, raidlevel: raid1, devices: [ partition-10, partition-9 ], spare_devices: [], preserve: false, wipe: superblock, type: raid, id: raid-0 }
- { name: md1, raidlevel: raid1, devices: [ partition-11, partition-12 ], spare_devices: [], preserve: false, wipe: superblock, type: raid, id: raid-1 }
# An ext4 boot filesystem on MD
- { fstype: ext4, volume: raid-0, preserve: false, type: format, id: format-3 }
# LVM on MD
- { name: vg0, devices: [ raid-1 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- { name: lv-0, volgroup: lvm_volgroup-0, size: 10737418240B, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-4 }
- { path: /, device: format-4, type: mount, id: mount-4 }
- { path: /boot, device: format-3, type: mount, id: mount-3 }
# Install GRUB on both disks
- { path: /boot/efi, device: format-2, type: mount, id: mount-2 }
- { path: /boot/efi2, device: format-5, type: mount, id: mount-5 }
# Swap
- { name: swap, volgroup: lvm_volgroup-0, size: 1073741824B, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-1 }
- { fstype: swap, volume: lvm_partition-1, preserve: false, type: format, id: format-6 }
- { path: '', device: format-6, type: mount, id: mount-6 }
late-commands:
- 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
- chmod 440 /target/etc/sudoers.d/ubuntu-nopw
version: 1
GRUB est installé sur toutes les disques et les deux partitions EFI sont montés sous /boot.
Un MD RAID1 est configuré pour boot et un autre pour LVM.
#cloud-config
autoinstall:
identity:
hostname: jammy-server-raid-bond
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
keyboard:
layout: hu
toggle: null
variant: ''
locale: hu_HU.UTF-8
network:
bonds:
bond0:
addresses:
- 192.168.1.5/24
gateway4: 192.168.1.1
interfaces:
- ens10
- ens3
nameservers:
addresses:
- 192.168.1.2
search:
- example.com
parameters:
mode: balance-rr
ethernets:
ens10: {}
ens3: {}
version: 2
ssh:
allow-pw: false
authorized-keys: [ '<SSH KEY>' ]
install-server: true
storage:
config:
- { ptable: gpt, path: /dev/vda, wipe: superblock-recursive, preserve: false, name: '', grub_device: false, type: disk, id: disk-vda }
- { ptable: gpt, path: /dev/vdb, wipe: superblock-recursive, preserve: false, name: '', grub_device: false, type: disk, id: disk-vdb }
- { device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-3 }
- { fstype: fat32, volume: partition-3, preserve: false, type: format, id: format-2 }
- { device: disk-vdb, size: 536870912, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-8 }
- { fstype: fat32, volume: partition-8, preserve: false, type: format, id: format-5 }
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-9 }
- { device: disk-vdb, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-10 }
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-11 }
- { device: disk-vdb, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-12 }
- { name: md0, raidlevel: raid1, devices: [ partition-10, partition-9 ], spare_devices: [], preserve: false, wipe: superblock, type: raid, id: raid-0 }
- { name: md1, raidlevel: raid1, devices: [ partition-11, partition-12 ], spare_devices: [], preserve: false, wipe: superblock, type: raid, id: raid-1 }
- { fstype: ext4, volume: raid-0, preserve: false, type: format, id: format-3 }
- { name: vg0, devices: [ raid-1 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- { name: lv-0, volgroup: lvm_volgroup-0, size: 10737418240B, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-4 }
- { path: /, device: format-4, type: mount, id: mount-4 }
- { path: /boot, device: format-3, type: mount, id: mount-3 }
- { path: /boot/efi, device: format-2, type: mount, id: mount-2 }
- { path: /boot/efi2, device: format-5, type: mount, id: mount-5 }
- { name: swap, volgroup: lvm_volgroup-0, size: 1073741824B, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-1 }
- { fstype: swap, volume: lvm_partition-1, preserve: false, type: format, id: format-6 }
- { path: '', device: format-6, type: mount, id: mount-6 }
late-commands:
- 'echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/ubuntu-nopw'
- chmod 440 /target/etc/sudoers.d/ubuntu-nopw
version: 1
Une configuration complète netplan se trouve dans cet exemple autoinstall avec deux cartes réseaux regroupés (bond).
La disposition de partitionnement doit être changée quand le micrologiciel du système est BIOS. Le type reste GPT, mais la première partition est une partition spéciale BIOS boot.
storage:
config:
# Install GRUB in MBR
- { ptable: gpt, path: /dev/vda, wipe: superblock, preserve: false, name: '', grub_device: true, type: disk, id: disk-vda }
# BIOS boot partition
- { device: disk-vda, size: 1048576, flag: bios_grub, number: 1, preserve: false, grub_device: false, type: partition, id: partition-0 }
# boot
- { device: disk-vda, size: 1073741824, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
- { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1 }
- { device: disk-vda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
- { name: ubuntu-vg, devices: [ partition-2 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: -1, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 }
- { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2 }
- { path: /, device: format-2, type: mount, id: mount-2 }
- { path: /boot, device: format-1, type: mount, id: mount-1 }
#cloud-config
chpasswd:
list:
- installer:$6$gnqbMUzHhQzpDEw.$.cCNVVDsDfj5Feebh.5O4VbOmib7tyjmeI2ZsFP7VK2kWwgJFbfjvXo3chpeAqCgXWVIW9oNQ/Ag85PR0IsKD/
ssh_authorized_keys:
- <SSH KEY>
autoinstall:
identity:
hostname: jammy-minimal
password: $6$gnqbMUzHhQzpDEw.$.cCNVVDsDfj5Feebh.5O4VbOmib7tyjmeI2ZsFP7VK2kWwgJFbfjvXo3chpeAqCgXWVIW9oNQ/Ag85PR0IsKD/
username: ubuntu
version: 1
Les modules cloud-init chpasswd et ssh_authorized_keys configure l'utilisateur installer. Attention, chpasswd, ssh_authorized_keys et autoinstall sont sur le même niveau. Mot de passe est ubuntu.
Installer Ubuntu sur des portables Acer Aspire peut être problèmatique mais pas impossible.
Mettre en marche configuration IP statique, serveur DNS et Open vSwitch sous Ubuntu 18.04: netplan, ifupdown, systemd-networkd.