igloo

Installation d'une Gentoo sur un FitLet2 Compulab

mise à jour: 05/2024

Celeron J3455
8Go DDR3
250Go eMMC

La machine boot sur un Linux Live Gentoo

Si vous avez besoin d'effectuer l'installation via ssh (par exemple, pour profiter de votre clavier bépo ou pour faire facilement des copier/coller) :

# passwd
# rc-service sshd start
# ip -c a

On y coupera pas, on utilise l'UEFI
Table de partition utilisée :

/efi1Govfat
swap8Gosw
/reste du disqueext4

Préparation du disque :

# fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: TS240GMTS420S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 62158EE5-EA10-48EA-8A34-9626AF32BEB0

Command (m for help): n
Partition number (1-128, default 1):
First sector (34-468862094, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-468862094, default 468860927): +1G

Created a new partition 1 of type 'Linux filesystem' and of size 1 GiB.
Partition #1 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): t
Selected partition 1
Partition type or alias (type L to list all): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Command (m for help): n
Partition number (2-128, default 2):
First sector (2099200-468862094, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-468862094, default 468860927): +8G

Created a new partition 2 of type 'Linux filesystem' and of size 8 GiB.

Command (m for help): t
Partition number (1,2, default 2):
Partition type or alias (type L to list all): 19

Changed type of partition 'Linux filesystem' to 'Linux swap'.

Command (m for help): n
Partition number (3-128, default 3):
First sector (18876416-468862094, default 18876416):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (18876416-468862094, default 468860927):

Created a new partition 3 of type 'Linux filesystem' and of size 214.6 GiB.

Command (m for help): t
Partition number (1-3, default 3):
Partition type or alias (type L to list all): 23

Changed type of partition 'Linux filesystem' to 'Linux root (x86-64)'.

Command (m for help): p
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: TS240GMTS420S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 62158EE5-EA10-48EA-8A34-9626AF32BEB0

Device Start End Sectors Size Type
/dev/sda1 2048 2099199 2097152 1G EFI System
/dev/sda2 2099200 18876415 16777216 8G Linux swap
/dev/sda3 18876416 468860927 449984512 214.6G Linux root (x86-64)

Filesystem/RAID signature on partition 1 will be wiped.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

# mkfs.fat -F 32 /dev/sda1
# mkfs.ext4 /dev/sda3
# mkswap /dev/sda2

Installation du sytème de base

-Si vous devez reprendre votre installation, repartez d'ici (sans recréer les points de montage)

# swapon /dev/sda2

On note les ID des partitions, on va en avoir besoin pour la configuration du noyau et la création du fichier fstab, on met le système à l'heure, on créé les points de montage et on monte les partitions:

# blkid
# date
# chronyd -q
# mkdir --parents /mnt/gentoo
# mkdir --parents /mnt/gentoo/efi
# mount /dev/sda3 /mnt/gentoo
# cd /mnt/gentoo

Choissez l'archive sur la page suivante (j'utilise la version 'hardened' pour ce tuto) et copiez le lien :

https://www.gentoo.org/downloads/#other-arches

Téléchargez l'archive et décompressez-la :

# wget <PASTED_STAGE_URL>
# tar xpvf stage3-*.tar.bz2 --xattrs-include='*.*' --numeric-owner

On édite le fichier make.conf

# emacs /mnt/gentoo/etc/portage/make.conf

COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
MAKEOPTS="-j4 -l4"

On sélectionne des miroirs dans la liste (je prends tous les français)

# mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf

On monte quelques systèmes de fichier nécessaire à Gentoo

# cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
# mount --types proc /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# mount --bind /run /mnt/gentoo/run
# mount --make-slave /mnt/gentoo/run

On entre dans la nouvelle Gentoo

# chroot /mnt/gentoo /bin/bash
# source /etc/profile
# export PS1="(chroot) ${PS1}"
# mkdir /efi
# mount /dev/sda1 /efi
# mkdir --parents /etc/portage/repos.conf
# cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf

On la met à jour, on lit les nouvelles et on choisi son profil (comme j'ai téléchargé l'archive 'hardened', le profil 'hardened' est déjà sélectionné).

# emerge-webrsync
# eselect news read
# eselect profile list
# emerge --ask --verbose --update --deep --newuse @world

La variable USE, dans le fichier make.conf, permet de sculpter votre Gentoo selon vos besoin. Liste des valeurs disponibles :
https://www.gentoo.org/support/use-flags/#global

Si vous utilisez emacs, il faut l'installer dans votre nouvel environnement

# emerge -a emacs
# emacs /etc/portage/make.conf

Je n'utilise ni l'interface graphique, ni le son, ni la wifi ni le serveur d'impression

USE="-X -alsa -bluetooth -cups hardened lm_sensors -sound -wifi"

# emerge --ask --oneshot app-portage/cpuid2cpuflags
# cpuid2cpuflags
# echo "*/* $(cpuid2cpuflags)" > /etc/portage/package.use/00cpu-flags
# emerge -uaDN world
# emerge -ac

Un peu de localisation

# echo "Europe/Paris" > /etc/timezone
# emerge --config sys-libs/timezone-data
# emacs /etc/locale.gen

fr_FR.UTF-8 UTF-8
fr_FR ISO-8859-1
fr_FR@euro ISO-8859-15

# locale-gen
# eselect locale list

Sélectionnez l'UTF-8

# eselect locale set 7
# env-update && source /etc/profile && export PS1="(chroot) $PS1"

Installation des sources et compilation du noyau

# emerge --ask sys-kernel/installkernel
# emerge --ask sys-kernel/gentoo-sources

Installez pciutils pour avoir des informations sur votre configuration matériel grâce à la commande 'lspci -k', ces informations seront nécessaire pour la configuration du noyau.

# emerge --ask sys-apps/pciutils
# lspci -k

Configurons le noyau:

# cd /usr/src/linux
# make menuconfig ou "make localmodconfig"

General setup --->
(IG-88) Default hostname
Preemption Model (No Forced Preemption (Server)) --->

-*- Enable the block layer --->
Partition Types --->
[*] Advanced partition selection
[*] EFI GUID Partition support

Processor type and features --->
[ ] Linux guest support ----
[*] Symmetric multi-processing support
[*] Intel Low Power Subsystem Support
Processor family (Intel Atom) --->
( ) Opteron/Athlon64/Hammer/K8
( ) Intel P4 / older Netburst based Xeon
( ) Core 2/newer Xeon
(X) Intel Atom
( ) Generic-x86-64
[X] Machine Check / overheating reporting
[X] Intel MCE Features
[ ] AMD MCE Features
[*] EFI runtime service support
[*] EFI mixed-mode support
[*] EFI stub support

Executable file formats / Emulations --->
[*] IA32 Emulation

[*] Networking support --->
Networking options --->
[*] Network packet filtering framework (Netfilter) --->

Device Drivers --->
Generic Driver Options --->
[*] Maintain a devtmpfs filesystem to mount at /dev
[ ] Automount devtmpfs at /dev, after the kernel mounted the rootfs
NVME Support --->
<*> NVM Express block device
[*] NVMe multipath support
[ ] NVMe verbose error reporting (NEW)
[*] NVMe hardware monitoring
<M> NVM Express over Fabrics FC host driver
<M> NVM Express over Fabrics TCP host driver
[*] NVM Express over Fabrics In-Band Authentication
SCSI device support --->
<*> SCSI disk support
[*] Network device support --→
[*] Ethernet driver support --->
[*] Intel devices
<*> Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support
[*] Intel(R) PCI-Express Gigabit adapters HWMON support
-*- Hardware Monitoring support --->
<*> Intel Core/Core2/Atom temperature sensor
HID support --->
-*- HID bus support
<*> Generic HID driver
[*] Battery level reporting for HID devices
USB HID support --->
<*> USB HID transport layer
[*] USB support --->
<*> xHCI HCD (USB 3.0) support
<*> EHCI HCD (USB 2.0) support
<*> OHCI HCD (USB 1.1) support
<*> MMC/SD/SDIO card support --->
<*>     SDHCI support on PCI bus

Firmware Drivers --->
EFI (Extensible Firmware Interface) Support --->
<*> EFI Variable Support via sysfs

File systems --->
<*> The Extended 4 (ext4) filesystem
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
Native Language support --->
[*] NLS ISO 8859-1 (Latin 1; Western European Languages)
Pseudo Filesystems --->
[*] /proc file system support
[*] Tmpfs virtual memory file system support (former shm fs)

Compilation et installation du noyau :

# make -j4 && make modules_install
# make install

Configuration du système (nom d'hôte, config réseau, mot de passe root, disposition du clavier) :

# emacs /etc/fstab

UUID=6472-9F0C/efivfatumask=00770 2
UUID=61f2ab02-4055-463f-9331-db046af0ba19noneswapsw0 0
UUID=deefc02d-376e-43fd-a0f0-fde3e4a6c89c/ext4defaults,noatime0 1

# echo IG-88 > /etc/hostname

# emacs /etc/conf.d/net

config_eno1="192.168.0.6/24"
routes_eno1="default via 192.168.0.1"

config_enp1s0="10.0.0.1/24"

# cd /etc/init.d
# ln -s net.lo net.eno1
# ln -s net.lo net.enp1s0
# rc-update add net.eno1 default
# rc-update add net.enp1s0 default
# passwd
# emacs /etc/conf.d/keymaps

Installation d'outils système :

# emerge --ask app-admin/sysklogd
# rc-update add sysklogd default
# emerge --ask sys-process/cronie
# rc-update add cronie default
# emerge --ask sys-apps/mlocate
# rc-update add sshd default
# emerge -a bash-completion
# emerge -a chrony
# rc-update add chonyd default

Installation de GRUB 2 :

# echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
# emerge --ask --verbose sys-boot/grub
# grub-install --efi-directory=/efi
# grub-mkconfig -o /boot/grub/grub.cfg

L'installation est terminée :

# exit
# cd
# umount -l /mnt/gentoo/dev{/shm,/pts,}
# umount -R /mnt/gentoo
# reboot

Ajout d'un utilistateur :

# useradd -m -G users,wheel -s /bin/bash rod
# passwd rod