Ebben a post-ban különböző Ubuntu telepítő eszközöket, valamint az Ubuntu 22.04 (Jammy) telepítési módjait szeretném bemutatni kiszolgálóra és asztali gépre.
Feltételezem, hogy működő DHCP, TFTP, HTTP kiszolgálód van.
Az alábbi példa azt mutatja be, hogy lehet ISC DHCP kiszolgálót úgy beállítani, hogy elindítson egy gépet TFTP-ről.
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;
}
Töltsd le a telepítő ISO-t és másold a következő grub állományokat ki belőle a TFTP könyvtárába.
Jammy ISO: /boot/fonts/unicode.pf2 /EFI/boot/bootx64.efi /EFI/boot/grubx64.efi
Töltsd le a pxelinux csomagokat és tömörítsd ki a következő állományokat a TFTP könyvtárába.
$ 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
A következő állomány-szerkezet használható a TFTP kiszolgálón.
. ├── 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
Példa grub beállítások a grub.cfg-ben.
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
}
Példa konfiguráció a pxelinux.cfg/default fájlban.
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
Legalább két állományt kell a webkiszolgálóra elhelyezni.
Bár a Canonical az autoinstall programot szerver telepítőnek hirdeti, használható mind szerver, mind asztali gép telepítésére.
Két fontos eltérés a Debian Installer-től (d-i):
Könnyű módja egy működő user-data autoinstall konfiguráció szerzésének a kézi telepítés. Majd pedig a /var/log/installer/autoinstall-user-data fájl kimásolása a webszerverre és a testreszabása.
A következő konfigurációs példák egy QEMU virtuális gépben születtek:
Kernel paraméterek
A partíciós példák UEFI-vel készültek, lásd BIOS boot disk layout, ha BIOS-od van.
#cloud-config
autoinstall:
identity:
hostname: jammy-minimal
password: $6$gnqbMUzHhQzpDEw.$.cCNVVDsDfj5Feebh.5O4VbOmib7tyjmeI2ZsFP7VK2kWwgJFbfjvXo3chpeAqCgXWVIW9oNQ/Ag85PR0IsKD/
username: ubuntu
version: 1
A jelszó ubuntu. A következő paranccsal állítható elő.
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
Az LVM-nek szánt partíció és a root LV mérete egyaránt -1, ami szerint a telepítő az összes szabad helyet elhasználja. A size: -1 méretű partíció vagy kötet a konfigurációban a legutolsó kell, legyen. A példában: a telepítő az utolsó partíciót az összes szabadon maradt helyre hozza létre és az utoljára megadott logikai kötet a kötetcsoport összes szabad helyét elhasználja.
#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
A DM crypt kulcs ubuntu és szabadszöveges.
#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
Egy SSH publikus kulcs felmásolható a frissen telepített gépre. Mindössze cseréld le a <SSH KEY> szöveget az SSH publikus kulcsoddal (például a cat ~/.ssh/id_rsa.pub kimenetével). A jelszavas SSH hitelesítés le van tiltva.
Ez a példa swap-nek logikai kötetet használ swapfájl helyett.
#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
A GRUB mindkét lemezre telepítődik és a két EFI partíció is felcsatolódik a /boot alá.
Egy-egy MD RAID1 kötet beállításra kerül a boot partíció és az LVM számára.
#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
Egy komplett két hálózati kártyás netplan konfiguráció található ebben az autoinstall példában.
A partíciók felépítését meg kell változtatni, amikor a rendszer firmware BIOS. A tábla GPT marad, de az első partíció egy speciális BIOS boot partíció.
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
A chpasswd és ssh_authorized_keys cloud-init modulok állítják be az installer titkait. Fontos, hogy a chpasswd, ssh_authorized_keys és autoinstall ugyanazon a szinten vannak. A jelsző ubuntu.