Manuale amd64 di Gentoo Linux: Installare Gentoo

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:AMD64/Full/Installation and the translation is 100% complete.


Introduzione

Benvenuto

Prima di tutto, benvenuto su Gentoo! Stai per entrare nel mondo delle scelte e delle prestazioni. Durante l'installazione di Gentoo, ciò risulterà chiaro in molte occasioni - gli utenti possono scegliere quanto e cosa compilare sulla loro macchina, come installare Gentoo, quale system logger usare, ecc.

Openness

Gentoo's premier tools are built from simple programming languages. Portage, Gentoo's package maintenance system, is written in Python. Ebuilds, which provide package definitions for Portage are written in bash. Our users are encouraged to review, modify, and enhance the source code for all parts of Gentoo.

By default, packages are only patched when necessary to fix bugs or provide interoperability within Gentoo. They are installed to the system by compiling source code provided by upstream projects into binary format (although support for precompiled binary packages is included too). Configuring Gentoo happens through text files.

For the above reasons and others: openness is built-in as a design principle.

Choice

Gentoo è una meta-distribuzione veloce e moderna con un design pulito e flessibile. Gentoo è costruita sull'ecosistema del software libero e non nasconde ai suoi utenti quel che sta sotto il cofano. Portage, il sistema di gestione dei pacchetti che usa Gentoo, è scritto in Python: ciò significa che l'utente ne può facilmente visualizzare e modificare il codice sorgente. Il sistema di impacchettamento di Gentoo usa codice sorgente (sebbene il supporto ai pacchetti precompilati sia disponibile) e la configurazione di Gentoo avviene attraverso semplici file di testo. In altre parole, apertura su tutti i fronti.

When installing Gentoo, choice is made clear throughout the Handbook. System administrators can choose two fully supported init systems (Gentoo's own OpenRC and Freedesktop.org's systemd), partition structure for storage disk(s), what file systems to use on the disk(s), a target system profile, remove or add features on a global (system-wide) or package specific level via USE flags, bootloader, network management utility, and much, much more.

As a development philosophy, Gentoo's authors try to avoid forcing users onto a specific system profile or desktop environment. If something is offered in the GNU/Linux ecosystem, it's likely available in Gentoo. If not, then we'd love to see it so. For new package requests please file a bug report or create your own ebuild repository.

Power

Being a source-based operating system allows Gentoo to be ported onto new computer instruction set architectures and also allows all installed packages to be tuned. This strength surfaces another Gentoo design principal: power.

A system administrator who has successfully installed and customized Gentoo has compiled a tailored operating system from source code. The entire operating system can be tuned at a binary level via the mechanisms included in Portage's make.conf file. If so desired, adjustments can be made on a per-package basis, or a package group basis. In fact, entire sets of functionality can be added or removed using USE flags.

È molto importante che ciascuno comprenda che sono le scelte ciò che permettono a Gentoo di esistere. Proviamo a non forzare nessuno verso qualcosa che non piace. Se qualcuno crede che non sia così, per favore mandi un rapporto bug.

Come è strutturata l'installazione

L'installazione di Gentoo può essere vista come una procedura in 10 passi, corrispondenti ai relativi capitoli. Ogni passo si conclude con una determinata situazione:

Passo Situazione
1 L'utente è in un ambiente di lavoro pronto per l'installazione di Gentoo.
2 La connessione ad Internet è pronta per poter installare Gentoo.
3 I dischi rigidi sono stati inizializzati per ospitare l'installazione di Gentoo.
4 L'ambiente di installazione è stato preparato e l'utente è pronto per fare chroot (cambiare radice) sul nuovo ambiente.
5 I pacchetti fondamentali, gli stessi per tutte le installazioni di Gentoo, sono stati installati.
6 Il kernel Linux è stato installato.
7 La maggior parte dei file di configurazione di Gentoo sono creati.
8 Gli strumenti di sistema necessari sono stati installati.
9 Un appropriato avviatore (bootloader) è stato installato e configurato.
10 L'ambiente Gentoo Linux appena installato è pronto per essere esplorato.

Ogni qualvolta viene presentata una scelta, il manuale cercherà di esporne i pro e i contro. Sebbene il testo continui con la scelta predefinita (identificabile nel titolo con "Predefinito: "), saranno documentate anche le altre possibilità (identificabili nel titolo con "Alternativa: "). La scelta predefinita non deve essere intesa come la scelta raccomandata da Gentoo. Tuttavia, è la scelta che Gentoo ritiene più frequente per la maggior parte degli utenti.

Talvolta si potrà seguire un passo facoltativo. Tali passi sono contrassegnati con "Opzionale: " e quindi non sono necessari per installare Gentoo. Tuttavia, alcuni passi facoltativi sono dipendenti dalle scelte fatte in precedenza. Il manuale informerà il lettore al verificarsi di questa situazione, sia nel momento in cui si compie la scelta, sia giustamente prima che il passo facoltativo sia esposto.

Opzioni di installazione per Gentoo

Gentoo può essere installato in diversi modi. Può essere scaricato e installato dal supporto di installazione ufficiale di Gentoo come le nostre immagini ISO avviabili. Il mezzo di installazione può essere caricato su chiavetta USB o vi si può accedere tramite un ambiente dotato di rete. In alternativa, Gentoo può essere installato da un mezzo non ufficiale, come per esempio una distribuzione già pronta od un disco di avvio non-Gentoo (come Knoppix).

Questo documento affronta l'installazione in riferimento ad un mezzo di installazione ufficiale di Gentoo o, in qualche caso, tramite avvio da rete.

Nota
Per l'assistenza agli altri approcci d'installazione, incluso l'utilizzo di supporto di avvio non-Gentoo, si consiglia di leggere la nostra Guida all'installazione alternativa.

Forniamo anche un documento di consigli e trucchi per l'installazione di Gentoo che potrebbero anch'essi risultare utili.

Problemi

Se venisse trovato un problema nell'installazione (o nella documentazione dell'installazione), si consiglia di visitare il nostro sistema di tracciamento dei bug e di controllare se l'errore è noto. Se non lo è, è consigliabile creare un rapporto bug per esso così potremo occuparcene. Non aver paura degli sviluppatori a cui vengono assegnati i bug - loro (generalmente) non mangiano le persone.

Sebbene questo sia un documento specifico per un'architettura, potrebbe contenere riferimenti anche ad altre architetture, dato che grandi parti del manuale usano del testo comune a tutte le architetture (per evitare la duplicazione degli sforzi). Tali riferimenti sono stati mantenuti al minimo per evitare confusione.

Se c'è qualche dubbio sul fatto che un problema sia o meno strettamente legato all'utente (alcuni errori si possono compiere nonostante un'attenta lettura della documentazione) o se sia un problema del software (alcuni errori possono capitare nonostante un'accurato test dell'installazione e della documentazione), tutti sono invitati ad unirsi al canale #gentoo (webchat) su irc.libera.chat. Naturalmente, chiunque è benvenuto poiché il nostro canale copre l'intero spettro di Gentoo.

A proposito, se ci fossero altre domande riguardo Gentoo, si consiglia di controllare le Domande frequenti. Ci sono anche le FAQ sul Forum di Gentoo.




Requisiti Hardware

Prima di cominciare, elenchiamo i requisiti hardware necessari per installare correttamente Gentoo su un'architettura amd64.


AMD64 livedisk hardware requirements
Minimal CD LiveDVD
CPU Any x86-64 CPU, both AMD64 and Intel 64
Memory 2 GB
Disk space 8 GB (excluding swap space)
Swap space At least 2 GB

The AMD64 project is a good place to be for more information about Gentoo's amd64 support.


Mezzo di installazione di Gentoo Linux

Suggerimento
While it's recommended to use the official Gentoo boot media when installing, it's possible to use other installation environments. However, there is no guarantee they will contain required components. If an alternate install environment is used, skip to Preparing the disks.

CD d'installazione minimale

Il CD di installazione minimale è un'immagine avviabile: contenente un ambiente Gentoo auto-sostenuto. Permette agli utenti di avviare Linux dal CD o da altri mezzi di installazione. Durante il processo di avvio viene rilevato l'hardware e vengono caricati i driver necessari. L'immagine è mantenuta dagli sviluppatori di Gentoo e consente a chiunque di installarlo purché sia disponibile una connessione ad Internet.

Il CD di installazione minimale è chiamato install-amd64-minimal-<release>.iso.

Il LiveDVD occasionale di Gentoo

Saltuariamente, viene creato una speciale immagine DVD che può essere usato per installare Gentoo. Le istruzioni in questo capitolo riguardano il CD di installazione minimale, pertanto potrebbero risultare un po' differenti rispetto quando si avvia da LiveDVD. Comunque, il LiveDVD (o qualsiasi altro ambiente Linux avviabile) supporta l'elevazione ad amministratore (root) invocando sudo su - oppure sudo -i da terminale.

Gli archivi stage per l'installazione

Un tarball stage3 è un archivio contenente un ambiente Gentoo minimo specifico per il profilo. I tarball Stage3 sono adatti per continuare l'installazione di Gentoo usando le istruzioni in questo manuale. In precedenza, il manuale descriveva l'installazione utilizzando uno dei tre stage tarball. Gentoo non offre più tarball stage1 e stage2 per il download poiché questi sono principalmente per uso interno e per il bootstrap di Gentoo su nuove architetture.

Gli archivi stage3 si possono trovare seguendo il percorso releases/amd64/autobuilds/ su uno dei mirror di Gentoo ufficiali. I file stage vengono aggiornati frequentemente e non sono inclusi nell'immagine ufficiale per l'installazione.

Suggerimento
For now, stage files can be ignored. They will be described in greater detail later when they are needed
Nota
Historically, the handbook described installation steps for stage files with versions lower than 3. These stages contained environments unsuitable for typical installations, and are no longer covered in the handbook.

Download

Scaricare il supporto

I mezzi di installazione predefiniti utilizzati da Gentoo Linux sono i CD minimali di installazione, che ospitano un ambiente Gentoo Linux avviabile e molto piccolo. Questo ambiente contiene tutti gli strumenti appropriati per installare Gentoo. Le stesse immagini dei CD si possono scaricare dalla pagina dei download (raccomandata) o navigando autonomamente fino alla posizione del file ISO su uno dei tanti mirror disponibili.

Navigating Gentoo mirrors

Se si scarica da un mirror, il CD di installazione minimale si potrà trovare così:

  1. Entrare nella cartella releases/.
  2. Scegliere la cartella relativa alla propria architettura (come amd64/).
  3. Scegliere la cartella autobuilds/.
  4. Per le architetture amd64 e x86 scegliere rispettivamente la cartella current-install-amd64-minimal/ o la cartella current-install-x86-minimal/. Per tutte le altre architetture entrare nella cartella current-iso/.
Nota
Alcune architetture come arm, mips, e s390 non hanno un CD d'installazione minimale. Al momento il Progetto ingegneristico di rilasci di Gentoo non supporta la creazione di file .iso per queste architetture.

All'interno di quest'ultima cartella, il file immagine per l'installazione è quello con il suffisso .iso. Per esempio, si dia un'occhiata alla seguente lista:

CODE Lista d'esempio dei file scaricabili su releases/amd64/autobuilds/current-iso/
[DIR] hardened/                                          05-Dec-2014 01:42    -   
[   ] install-amd64-minimal-20141204.iso                 04-Dec-2014 21:04  208M  
[   ] install-amd64-minimal-20141204.iso.CONTENTS        04-Dec-2014 21:04  3.0K  
[   ] install-amd64-minimal-20141204.iso.DIGESTS         04-Dec-2014 21:04  740   
[TXT] install-amd64-minimal-20141204.iso.DIGESTS.asc     05-Dec-2014 01:42  1.6K  
[   ] stage3-amd64-20141204.tar.bz2                      04-Dec-2014 21:04  198M  
[   ] stage3-amd64-20141204.tar.bz2.CONTENTS             04-Dec-2014 21:04  4.6M  
[   ] stage3-amd64-20141204.tar.bz2.DIGESTS              04-Dec-2014 21:04  720   
[TXT] stage3-amd64-20141204.tar.bz2.DIGESTS.asc          05-Dec-2014 01:42  1.5K

Nell'esempio soprastante, il file install-amd64-minimal-20141204.iso è proprio il CD di installazione minimale. Ma come si può osservare, esistono anche altri file:

  • Un file .CONTENTS che contiene una lista di tutti i file disponibili nel supporto di installazione. Può essere molto utile per verificare se sono inclusi alcuni driver senza dover scaricare l'immagine ISO.
  • Un file .DIGESTS che contiene i checksum delle varie immagini ISO, in vari algoritmi. Può essere utilizzato per verificare l'integrità dell'immagine ISO scaricata.
  • Un file .DIGESTS.asc che contiene, oltre ai checksum delle immagini ISO (come nel file .DIGESTS), anche la firma crittografica dei file. Può essere usato, oltre che per verificare l'integrità, per verificare che l'immagine ISO provenga effettivamente dal team di Gentoo e che non sia stata modificata.

Si ignorino per ora gli altri file disponibili in questa posizione - quelli verranno indicati con il procedere dell'installazione. Scaricare il file .iso e, se si desidera la verifica di quanto scaricato, scaricare anche il file .DIGESTS.asc relativo al file .iso. Non è necessario scaricare anche il file .CONTENTS, in quanto queste istruzioni di installazione non vi si riferiranno più, ed il file .DIGESTS dovrebbe contenere le stesse informazioni di .DIGESTS.asc, a parte una firma che quest'ultimo file contiene all'inizio.

Suggerimento
The .DIGESTS file is only needed if the signature in the .iso.asc file is not verified.

Verificare i file scaricati

Nota
Questo è un passaggio facoltativo e non è necessario per l'installazione di Gentoo Linux. Tuttavia, è raccomandato assicurarsi che il file scaricato non sia corrotto e sia effettivamente fornito dalla squadra dell'infrastruttura di Gentoo.
  1. Per prima cosa, viene convalidata la firma crittografica per assicurarsi che il file di installazione sia fornito proprio dalla squadra ingegneristica di rilasci Gentoo
  2. Se la firma crittografica viene validata, si verifica che la somma di controllo (checksum) del file scaricato non sia corrotta

Verifica su un sistema Microsoft Windows

Per verificare prima la firma crittografica, è possibile utilizzare strumenti come GPG4Win. Dopo l'installazione, è necessario importare le chiavi pubbliche della squadra Gentoo Release Engineering. L'elenco delle chiavi è disponibile nella pagina delle firme. Una volta importate, l'utente potrà così verificare la firma del file .DIGESTS.asc.

Verifica su un sistema Linux

Su un sistema Linux, il metodo più comune per verificare la firma crittografica consiste nell'usare app-crypt/gnupg. Con questo pacchetto installato, possono essere usati i seguenti comandi per verificare la firma del file .DIGESTS.asc.

Suggerimento
When importing Gentoo keys, verify that the fingerprint (BB572E0E2D182910) matches.

Per prima cosa, si scarichi il giusto insieme di chiavi rese disponibili sulla pagina delle firme (signature):

user $gpg --keyserver hkps://keys.gentoo.org --recv-keys 0xBB572E0E2D182910
gpg: requesting key 0xBB572E0E2D182910 from hkp server pool.sks-keyservers.net
gpg: key 0xBB572E0E2D182910: "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>" 1 new signature
gpg: 3 marginal(s) needed, 1 complete(s) needed, classic trust model
gpg: depth: 0  valid:   3  signed:  20  trust: 0-, 0q, 0n, 0m, 0f, 3u
gpg: depth: 1  valid:  20  signed:  12  trust: 9-, 0q, 0n, 9m, 2f, 0u
gpg: next trustdb check due at 2018-09-15
gpg: Total number processed: 1
gpg:         new signatures: 1

In alternativa puoi usare invece WKD per scaricare la chiave:

--2019-04-19 20:46:32--  https://gentoo.org/.well-known/openpgpkey/hu/wtktzo4gyuhzu8a4z5fdj3fgmr1u6tob?l=releng
Resolving gentoo.org (gentoo.org)... 89.16.167.134
Connecting to gentoo.org (gentoo.org)|89.16.167.134|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35444 (35K) [application/octet-stream]
Saving to: 'STDOUT'
 
     0K .......... .......... .......... ....                 100% 11.9M=0.003s
 
2019-04-19 20:46:32 (11.9 MB/s) - written to stdout [35444/35444]
 
gpg: key 9E6438C817072058: 84 signatures not checked due to missing keys
gpg: /tmp/test2/trustdb.gpg: trustdb created
gpg: key 9E6438C817072058: public key "Gentoo Linux Release Engineering (Gentoo Linux Release Signing Key) <releng@gentoo.org>" imported
gpg: key BB572E0E2D182910: 12 signatures not checked due to missing keys
gpg: key BB572E0E2D182910: 1 bad signature
gpg: key BB572E0E2D182910: public key "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>" imported
gpg: Total number processed: 2
gpg:               imported: 2
gpg: no ultimately trusted keys found

Or if using official Gentoo release media, import the key from /usr/share/openpgp-keys/gentoo-release.asc (provided by sec-keys/openpgp-keys-gentoo-release):

user $gpg --import /usr/share/openpgp-keys/gentoo-release.asc
gpg: directory '/home/larry/.gnupg' created
gpg: keybox '/home/larry/.gnupg/pubring.kbx' created
gpg: key DB6B8C1F96D8BF6D: 2 signatures not checked due to missing keys
gpg: /home/larry/.gnupg/trustdb.gpg: trustdb created
gpg: key DB6B8C1F96D8BF6D: public key "Gentoo ebuild repository signing key (Automated Signing Key) <infrastructure@gentoo.org>" imported
gpg: key 9E6438C817072058: 3 signatures not checked due to missing keys
gpg: key 9E6438C817072058: public key "Gentoo Linux Release Engineering (Gentoo Linux Release Signing Key) <releng@gentoo.org>" imported
gpg: key BB572E0E2D182910: 1 signature not checked due to a missing key
gpg: key BB572E0E2D182910: public key "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>" imported
gpg: key A13D0EF1914E7A72: 1 signature not checked due to a missing key
gpg: key A13D0EF1914E7A72: public key "Gentoo repository mirrors (automated git signing key) <repomirrorci@gentoo.org>" imported
gpg: Total number processed: 4
gpg:               imported: 4
gpg: no ultimately trusted keys found

Poi si verifichi la firma crittografica del file .DIGESTS.asc:

user $gpg --verify install-amd64-minimal-20141204.iso.DIGESTS.asc
gpg: Signature made (firma realizzata il) Fri 05 Dec 2014 02:42:44 AM CET
gpg:                using (utilizzando) RSA key 0xBB572E0E2D182910
gpg: Good signature from (firma valida di) "Gentoo Linux Release Engineering (Automated Weekly Release Key) (Chiave a rilascio settimanale automatico) <releng@gentoo.org>" [unknown]
gpg: WARNING (ATTENZIONE): This key is not certified with a trusted signature! (Chiave non certificata con una firma affidabile)
gpg:          There is no indication that the signature belongs to the owner. (Non c'è indicazione che la firma sia stata posta dai suoi proprietari)
Primary key fingerprint (Impronta digitale primaria): 13EB BDBE DE7A 1277 5DFD  B1BA BB57 2E0E 2D18 2910

Per essere assolutamente certi che ogni cosa sia valida, si confronti l'impronta alfanumerica mostrata con l'impronta sulla pagina delle firme di Gentoo.

Nota
It's generally good practice to mark an imported key as trusted, once it's certain the key is trustworthy. When trusted keys are verified, gpg will not say unknown and warn about the signature being untrusted.

Writing the boot media

Naturalmente, con il solo file ISO scaricato, l'installazione di Gentoo Linux non può iniziare. Il file ISO deve essere masterizzato su un CD così da potersi avviare tramite esso, ed in un modo tale che il contenuto del file sia scritto sul CD, non solamente il file stesso. Segue qualche metodo che si avvale di pochi comandi - un insieme più elaborato di istruzioni lo si può trovare su [posso masterizzare un file ISO?].

Writing a bootable USB

Most modern systems support booting from a USB device.

Writing with Linux

dd is typically available on most Linux distros, and can be used to write the Gentoo boot media to a USB drive.

Determining the USB device path

Before writing, the path to the desired storage device must be determined.

dmesg will display detailed information describing the storage device as it is added to the system:

root #dmesg
[268385.319745] sd 19:0:0:0: [sdd] 60628992 512-byte logical blocks: (31.0 GB/28.9 GiB)

Alternatively, lsblk can be used to display available storage devices:

root #lsblk
sdd           8:48   1  28.9G  0 disk
├─sdd1        8:49   1   246K  0 part
├─sdd2        8:50   1   2.8M  0 part
├─sdd3        8:51   1 463.5M  0 part
└─sdd4        8:52   1   300K  0 part

Once the device name has been determined, this can be added to the path prefix /dev/ to get the device path /dev/sdd.

Suggerimento
Using the base device path, ie. sdd opposed to sdd1, is recommend as the Gentoo boot media contains a full GPT partition scheme.
Writing with dd
Attenzione
Be sure to check the target (of=target) path before executing dd, as it will be overwritten.

With the device path (/dev/sdd) and boot media install-amd64-minimal-<release timestamp>.iso ready:

root #dd if=install-amd64-minimal-<release timestamp>.iso of=/dev/sdd bs=4096 status=progress && sync
Nota
if= specifies the input file, of= specifies the output file, which in this case, is a device.
Suggerimento
bs=4096 is used as it speeds up transfers in most cases, status=progress displays transfers stats.

Scrivere su disco

See also
A more elaborate set of instructions can be found in CD/DVD/BD_writing#Image_writing.

Masterizzare con Microsoft Windows

Le versioni di Microsoft Windows 7 e successive possono montare e masterizzare immagini ISO su supporti ottici senza la necessità di software di terze parti. Basta inserire un disco masterizzabile, cercare i file ISO scaricati, fare clic con il pulsante destro del mouse sul file in Esplora risorse e selezionare "Masterizza immagine disco".

Masterizzare con Linux

L'utilità cdrecord dal pacchetto app-cdr/cdrtools può masterizzare immagini ISO su Linux.

Per masterizzare il file ISO sul CD raggiungibile con /dev/sr0 (corrisponde al primo masterizzatore CD nel sistema - sostituirlo con il dispositivo corretto se necessario):

user $cdrecord dev=/dev/sr0 install-amd64-minimal-20141204.iso

Gli utenti che preferiscono un'interfaccia grafica possono usare K3B, incluso nel pacchetto kde-apps/k3b. In K3B, andare su Strumenti e scegliere Masterizza immagine CD.

Avvio


Avviare il supporto di installazione

Una volta che il supporto di installazione è pronto, è il momento di avviarlo. Inserirlo nel sistema, riavviare ed entrare nell'interfaccia del firmware della scheda madre. Di solito è possibile farlo premendo un tasto come DEL, F1, F10, o ESC durante l'auto test all'avvio (POST: Power-On Self-test). Il tasto di accesso cambia in base al sistema ed alla scheda madre. Se non risulta ovvio, si usi un motore di ricerca su Internet e si compiano alcune ricerche utilizzando il modello della scheda madre come parola chiave per la ricerca. I risultati saranno facili da valutare. Una volta all'interno del menu del firmware della scheda madre, modificare l'ordine di avvio in modo che i supporti di avvio esterni (dischi CD/DVD o unità USB) siano controllati prima dei dischi interni. Senza questa modifica, il sistema molto probabilmente si avvierà dal disco interno ignorando il supporto di avvio esterno.

Importante
Quando si installa Gentoo con l'intento di usare l'interfaccia UEFI anziché il BIOS, è raccomandato avviare fin da subito con UEFI. In caso contrario, potrebbe essere necessario creare un dispositivo USB (o altri supporti) avviabile con UEFI una volta terminata l'installazione di Gentoo Linux.

Se ancora non è stato fatto, assicurarsi che il supporto di installazione sia inserito o collegato al sistema e riavviare. Una schermata con una richiesta inerente la modalità di avvio dovrebbe mostrarsi. Qui, con Enter verrà avviato il supporto con le opzioni predefinite. Per avviare il supporto di installazione con delle opzioni di avvio personalizzate, specificare un kernel seguito dalle opzioni di avvio e poi premere Enter.

Nota
In all likelihood, the default gentoo kernel, as mentioned above, without specifying any of the optional parameters will work just fine. For boot troubleshooting and expert options, continue on with this section. Otherwise, just press Enter and skip ahead to Extra hardware configuration.

Alla schermata inerente la modalità di avvio, gli utenti possono visualizzare i kernel disponibili con F1 e le opzioni di avvio con F2. Se nessuna scelta viene effettuata entro 15 secondi (né la visualizzazione di informazioni, né l'utilizzo di un kernel), allora il supporto di installazione passerà ad avviare dal disco interno. Ciò permette alle installazioni di riavviarsi e provare il proprio ambiente installato senza dover rimuovere il CD dal lettore (la qual cosa è molto apprezzata nelle installazioni in remoto).

Riguardo la specificazione di un kernel. Sul supporto di installazione minimale sono disponibili solo due opzioni di avvio pre-impostate. L'opzione predefinita è gentoo. L'altra è la variante -nofb; questa disabilita il supporto al framebuffer del kernel.

La sezione seguente mostra una breve panoramica dei kernel disponibili con una loro descrizione:

Scelte del kernel

gentoo
Kernel predefinito con il supporto per le CPU K8 (incluso il supporto NUMA) e le CPU EM64T.
gentoo-nofb
Come la scelta gentoo ma senza il supporto al framebuffer.
memtest86
Test della RAM locale per verificare eventuali errori.

Insieme al kernel, le opzioni di avvio aiutano a definire ulteriormente il processo di avvio.

Opzioni hardware

acpi=on
Carica il supporto ACPI e comporta inoltre l'avvio del demone acpid dal CD. È necessario solo se il sistema richiede che ACPI funzioni correttamente. E non è necessario per avere il supporto all'hyperthreading.
acpi=off
Disabilita completamente ACPI. È utile in alcuni sistemi più datati ed è anche un requisito per l'utilizzo di APM. Ciò disabiliterà il supporto all'hyperthreading del processore.
console=X
Questa opzione imposta l'accesso al CD tramite console seriale. Il primo parametro riguarda il dispositivo, solitamente ttyS0 su x86, seguito da tutti i parametri di connessione da separare con virgole. I parametri predefiniti sono: 9600,8,n,1.
dmraid=X
Consente di passare dei parametri al sottosistema di mappatura del dispositivo RAID. I parametri devono essere racchiusi tra virgolette.
doapm
Carica il supporto al driver APM. Questo richiede anche l'opzione acpi=off.
dopcmcia
Carica il supporto per l'hardware PCMCIA e Cardbus e comporta anche il lancio, all'avvio da CD, del gestore della scheda pcmcia. Ciò è necessario soltanto quando si avvia dai dispositivi PCMCIA/Cardbus.
doscsi
Carica il supporto per la maggior parte dei controller SCSI. È anche un requisito per l'avvio di più dispositivi USB, in quanto utilizzano il sottosistema SCSI core.
sda=stroke
Consente all'utente di partizionare l'intero disco rigido, anche quando il BIOS non è in grado di gestire grandi dischi. Opzione utilizzata solo su vecchie macchine BIOS. Sostituire sda con il dispositivo che richiede questa opzione.
ide=nodma
Forza la disabilitazione di DMA nel kernel. È necessario per diversi chipset IDE ed anche alcuni drive CDROM. Se il sistema sta avendo problemi con la lettura da CDROM IDE, si provi questa opzione. Disattiva anche le impostazioni hdparm predefinite da eseguire.
noapic
Disattiva l'Advanced Programmed Interrupt Controller (APIC) presente sulle schede madri moderne. È noto che APIC causa qualche problema con l'hardware più vecchio.
nodetect
Disabilita tutti gli auto-rilevamenti eseguiti da CD, tra cui il rilevamento delle periferiche e il DHCP. Ciò è utile per fare il debug di un CD o un driver che falliscono.
nodhcp
Disattiva DHCP sulle schede di rete che sono state rilevate. È utile per le reti che utilizzano solo indirizzi IP statici.
nodmraid
Disattiva il supporto per il mappatore del dispositivo RAID, ad esempio quello utilizzato nei controller RAID IDE/SATA incorporati nella scheda di sistema.
nofirewire
Disattiva il caricamento dei moduli Firewire. Ciò dovrebbe essere necessario solo se l'hardware Firewire sta causando un problema durante l'avvio da CD.
nogpm
Disattiva il supporto gpm per il mouse sulla console.
nohotplug
Disattiva il caricamento degli script di avviamento hotplug e coldplug all'avvio. Ciò è utile per fare il debug di un CD o un driver che falliscono.
nokeymap
Disabilita la selezione della mappa tasti della tastiera per le tastiere non statunitensi (USA).
nolapic
Disabilita l'APIC locale sui kernel a singolo processore.
nosata
Disattiva il caricamento dei moduli Serial ATA. Questo viene utilizzato quando il sistema ha problemi con il sottosistema SATA.
nosmp
Disattiva SMP, o Multiprocessamento simmetrico, sui kernel con SMP abilitato. Ciò è utile per eseguire il debug di problemi relativi a SMP che sorgono con alcuni driver o schede madri.
nosound
Disattiva il supporto audio e le impostazioni del volume. È utile per i sistemi in cui il supporto audio causa problemi.
nousb
Disattiva il caricamento automatico dei moduli USB. È utile per fare il debug in caso di problemi con USB.
slowusb
Aggiunge alcune pause supplementari nel processo di avvio per i CDROM USB lenti, come sull'IBM BladeCenter.

Gestione dei volumi e dei dispositivi logici

dolvm
Abilita il supporto per la gestione dei volumi logici (LVM) su Linux.

Altre opzioni

debug
Abilita il codice di debug. Ciò può creare confusione perché mostra molti dati sullo schermo.
docache
Comporta la generazione sulla RAM di una cache per l'intera porzione di CD in via di esecuzione, ciò permette all'utente di smontare /mnt/cdrom e montare un altro CDROM. Questa opzione richiede almeno il doppio di capacità RAM rispetto alla dimensione del CD.
doload=X
Implica il caricamente sull'iniziale ramdisk di qualsiasi modulo elencato, come anche le sue dipendenze. Sostituire X con il nome del modulo. Moduli multipli si possono specificare separandoli con una virgola.
dosshd
Esegue sshd all'avvio, utile per le installazioni senza sorveglianza.
passwd=foo
Imposta ciò che viene dopo l'uguale come password di root, ciò è richiesto con dosshd poiché la password di root è offuscata per impostazione predefinita.
noload=X
Implica l'esclusione dall'iniziale ramdisk di un modulo specifico che potrebbe causare un problema. La sintassi è la stessa di doload.
nonfs
Disabilita l'esecuzione di portmap/nfsmount all'avvio.
nox
Su un LiveCD con X Window System (o X11 o X) non verrà automaticamente avviata l'interfaccia visuale X, ma passerà ad un'interfaccia a riga di comando.
scandelay
Inserisce una pausa di circa 10 secondi durante alcune parti del processo di avvio da CD, così da rendere possibile l'inizializzazione di certi dispositivi lenti e permettere che risultino pronti all'uso.
scandelay=X
Consente all'utente di specificare un ritardo personalizzato in secondi che viene aggiunto ad alcune parti del processo di avvio per consentire l'inizializzazione dei dispositivi lenti affinché risultino pronti all'uso. Sostituire X con il numero di secondi da aspettare durante la pausa.
Nota
I supporti di avvio controlleranno le opzioni no* prima delle opzioni do*, salvo questo, le opzioni saranno eventualmente sovrascritte in base all'ordine esatto con cui sono state specificate.

Ora si avvii il supporto di installazione, si selezioni un kernel (qualora il kernel predefinito gentoo non risulti soddisfacente) e le opzioni di avvio. A titolo di esempio, avviamo il kernel gentoo con dopcmcia come parametro per il kernel:

boot:gentoo dopcmcia

In seguito, l'utente è accolto da una schermata di avvio ed una barra di avanzamento. Se l'installazione viene eseguita su un sistema con una tastiera diversa da quella statunitense, assicurarsi di premere Alt+F1 il prima possibile per passare alla modalità dettagliata e soddisfare le richieste di istruzione. Se non viene effettuata alcuna scelta entro 10 secondi, sarà considerato il valore predefinito (tastiera statunitense) e la fase di avvio proseguirà. Una volta completato il processo di avvio, l'utente si ritroverà automaticamente nell'ambiente Gentoo Linux "Live" come utente root, il superutente. La console aperta sarà in attesa di comandi dall'utente root ed è possibile passare ad altre console premendo Alt+F2, Alt+F3 o Alt+F4. Per tornare alla prima console si prema Alt+F1.


Configurazione hardware extra

Quando il supporto di installazione viene avviato, vengono rilevati tutti i dispositivi hardware e caricati i moduli del kernel appropriati per supportare quell'hardware. Nella maggior parte dei casi fa un ottimo lavoro. Tuttavia, in alcuni casi, può non caricare automaticamente i moduli del kernel necessari al sistema. Se il rilevamento automatico delle periferiche PCI si perde qualche componente hardware, i moduli del kernel appropriati dovranno essere caricati manualmente.

Nel prossimo esempio viene caricato il modulo 8139too (che supporta certi tipi di interfacce di rete):

root #modprobe 8139too

Opzionale: Account utenti

Se altre persone hanno bisogno di accedere all'ambiente di installazione o c'è la necessità di avviare comandi come utenti non-root (ad esempio per chattare utilizzando irssi senza privilegi di root per ragioni di sicurezza), allora è necessario creare un account utente ed impostare una password di root complessa.

Per cambiare la password di root, usare il comando passwd:

root #passwd
New password: (Inserisci la nuova password)
Re-enter password: (Riscrivi la nuova password)

Per creare un account utente, prima si inseriscono le sue credenziali e poi la sua password. I comandi useradd e passwd servono per queste due operazioni.

Nel prossimo esempio, viene creato un utente chiamato "luca":

root #useradd -m -G users luca
root #passwd luca
New password: (Inserisci la password di Luca)
Re-enter password: (Riscrivi la password di Luca)

Per passare dall'attuale utente root a quello appena creato, usare il comando su:

root #su - luca

Opzionale: Consultare la documentazione durante l'installazione

Terminali

Per consultare la guida durante l'installazione, prima si crei un account utente come descritto sopra. Poi si prema Alt+F2 per passare ad un nuovo terminale.

Durante l'installazione, il comando links può essere usato per sfogliare la guida - naturalmente solo se la connessione Internet sta funzionando.

user $links https://wiki.gentoo.org/wiki/Handbook:AMD64/it

Per tornare al terminale di origine, premere Alt+F1.

Suggerimento
When booted to the Gentoo minimal or Gentoo admin environments, seven TTYs will be available. They can be switched by pressing Alt then a function key between F1-F7. It can be useful to switch to a new terminal when waiting for job to complete, to open documentation, etc.

GNU Screen

L'utilità Screen è preinstallata nel supporto di installazione ufficiale di Gentoo. Potrebbe risultare più efficiente per gli appassionati che hanno esperienza con Linux usare screen per visualizzare le istruzioni di installazione in più pannelli anziché con il metodo dei terminali multipli appena esposto.

Opzionale: Avviare il demone SSH

Per consentire ad altri utenti di accedere al sistema durante l'installazione (magari per essere aiutati durante l'installazione, o farsela fare a distanza), si deve creare un account utente (come descritto sopra) ed anche il processo SSH va avviato.

Per avviare il demone SSH su un init OpenRC, eseguire il comando seguente:

root #rc-service sshd start
Nota
Se gli utenti accedono al sistema, vedranno un messaggio che indica che è necessario confermare la chiave del computer host, attraverso la cosiddetta impronta digitale. Ciò è normale dato che si accede al sistema per la prima volta. Tuttavia, in seguito, quando il sistema sarà configurato e qualcuno accederà al sistema appena installato, il client SSH avviserà che il codice del computer host è cambiato. Ciò avviene perché l'utente che si connetterà dopo l'installazione di Gentoo, si troverà non più sull'ambiente di installazione, ma sul nuovo sistema appena installato. Seguire le istruzioni date per sostituire la chiave host sul sistema client.

Per poter usare sshd, la rete deve funzionare correttamente. Proseguire con il capitolo su come Configurare la rete.




Rilevamento automatico della rete

Può la rete funzionare fin da subito?

Se il sistema è connesso via ethernet ad una rete con un server DHCP, è molto probabile che la configurazione sia stata già fatta automaticamente. Se è così, molti comandi da CD che richiedono una connessione di rete funzioneranno immediatamente (es. ssh, scp, ping, irssi, wget e links).

Usare DHCP

DHCP (Dynamic Host Configuration Protocol) (Protocollo di Configurazione Dinamica degli Host) rende possibile ricevere automaticamente informazioni di rete (quali indirizzo IP, maschera di rete, indirizzo di broadcast, gateway, server DNS, ecc.). Ciò funziona solo se esiste un server DHCP nella rete (o se il provider fornisce un servizio DHCP). Per fornire automaticamente queste informazioni all'interfaccia di rete, usare dhcpcd:

DHCP requires that a server be running on the same Layer 2 (Ethernet) segment as the client requesting a lease. DHCP is often used on RFC1918 (private) networks, but is also used to acquire public IP information from ISPs.

Suggerimento
Official Gentoo boot media runs dhcpcd automatically at startup. This behavior can be disabled by adding the nodhcp argument to the boot media kernel commandline.

If it is not already running, dhcpcd can be started on enp1s0 with:

root #dhcpcd eth0

Alcuni amministratori di rete richiedono che l'hostname ed il domain name generati dal server DHCP vengano utilizzati dal sistema. In tal caso, usare:

root #dhcpcd -HD eth0

To stop dhcpcd, -x can be used:

root #dhcpcd -x
sending signal Term to pid 10831
waiting for pid 10831 to exit
See also
Dhcpcd usage

Testare la rete

A properly configured default route is a critical component of Internet connectivity, route configuration can be checked with:

root #ip route
default via 192.168.0.1 dev enp1s0

If no default route is defined, Internet connectivity is unavailable, and additional configuration is required.

Basic internet connectivity can be confirmed with a ping:

root #ping -c 3 1.1.1.1
Suggerimento
It's helpful to start by pinging a known IP address instead of a hostname. This can isolate DNS issues from basic Internet connectivity issues.

Outbound HTTPS access and DNS resolution can be confirmed with:

root #curl --location gentoo.org --output /dev/null

Se tutto funziona, il resto di questo capitolo può essere saltato, passando direttamente al prossimo capitolo (Preparare i dischi).

If curl reports an error, but Internet-bound pings work, DNS may need configuration.

If Internet connectivity has not been established, first interface information should be verified, then:

Determinare i nomi delle interfacce

If networking doesn't work out of the box, additional steps must be taken to enable Internet connectivity. Generally, the first step is to enumerate host network interfaces.

Alternativamente a ifconfig, per determinare i nomi delle interfacce si può utilizzare il comando ip. L'esempio seguente mostra l'output di ip addr (il risultato differisce dal precedente poiché eseguito su un sistema diverso):

The link argument can be used to display network interface links:

root #ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
4: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether e8:40:f2:ac:25:7a brd ff:ff:ff:ff:ff:ff

The address argument can be used to query device address information:

root #ip addr
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e8:40:f2:ac:25:7a brd ff:ff:ff:ff:ff:ff
    inet 10.0.20.77/22 brd 10.0.23.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::ea40:f2ff:feac:257a/64 scope link 
       valid_lft forever preferred_lft forever

The output of this command contains information for each network interface on the system. Entries begin with the device index, followed by the device name: enp1s0.

Suggerimento
Se usando il comando ifconfig non viene mostrata alcuna interfaccia, si può provare ad usare lo stesso comando con l'opzione -a. Questa opzione fa sì che vengano mostrate tutte le interfacce rilevate dal sistema, che esse siano abilitate o meno. Se ifconfig -a non mostra risultati, la scheda di rete potrebbe essere guasta o il relativo driver non caricato nel kernel. Queste situazioni vanno oltre lo scopo di questo manuale. Contattare #gentoo (webchat) per avere supporto tecnico.

Nella parte rimanente del documento, il manuale considererà che l'interfaccia di rete sia chiamata eth0.

Avendo adottato nomi che indicano il tipo di interfaccia, il nome dell'interfaccia di rete potrebbe essere abbastanza diverso dal classico eth0. I dischi di installazione recenti potrebbero riportare nomi come eno0, ens1, o enp5s0. Si cerchi con ifconfig l'interfaccia che ha un indirizzo IP correlato alla rete locale.

Optional: Application specific configuration

The following methods are not generally required, but may be helpful in situations where additional configuration is required for Internet connectivity.

Opzionale: Configurazione dei proxy

Se si accede ad Internet attraverso un proxy, è necessario impostarlo durante l'installazione. Configurare un proxy è molto facile: basta definire una variabile con le informazioni del server proxy.

Certain text-mode web browsers such as links can also make use of environment variables that define web proxy settings; in particular for the HTTPS access it also will require the https_proxy environment variable to be defined. While Portage will be influenced without passing extra run time parameters during invocation, links will require proxy settings to be set.

Nella maggior parte dei casi, è sufficiente definire la variabile con l'hostname del server. Per esempio, il proxy è chiamato proxy.gentoo.org e la porta è 8080.

Nota
The # symbol in the following commands is a comment. It has een added for clarity only and does not need to be typed when entering the commands.

Per impostare un proxy HTTP (per il traffico HTTP/HTTPS):

root #export http_proxy="http://proxy.gentoo.org:8080"

Se il proxy richiede nome utente e password, usare la seguente sintassi per la variabile:

CODE Aggiungere nome utente e password alla variabile del proxy
http://username:password@proxy.gentoo.org:8080

Start links using the following parameters for proxy support:

user $links -http-proxy ${http_proxy} -https-proxy ${https_proxy}

Per configurare un proxy FTP:

root #export ftp_proxy="ftp://proxy.gentoo.org:8080"

Start links using the following parameter for a FTP proxy:

user $links -ftp-proxy ${ftp_proxy}

Per configurare un proxy RSYNC:

root #export RSYNC_PROXY="proxy.gentoo.org:8080"

Alternativa: Usare PPP

If PPPoE is required for Internet access, the Gentoo boot media includes the pppoe-setup script to simplify ppp configuration.

During setup, pppoe-setup will ask for:

  • The name of the Ethernet interface connected to the ADSL modem.
  • The PPPoE username and password.
  • DNS server IPs.
  • Whether or not a firewall is needed.
root #pppoe-setup
root #pppoe-start

In the event of failure, credentials in /etc/ppp/pap-secrets or /etc/ppp/chap-secrets should be verified. If credentials are correct, PPPoE Ethernet interface selection should be checked.

Alternativa: Usare PPTP

Se è necessario il supporto PPTP, usare pptpclient fornito dai CD di installazione. Prima però ci si assicuri che la configurazione sia corretta, modificando /etc/ppp/pap-secrets o /etc/ppp/chap-secrets affinché contengano la giusta combinazione di nome utente e password:

Edit /etc/ppp/pap-secrets or /etc/ppp/chap-secrets so it contains the correct username/password combination:

root #nano -w /etc/ppp/chap-secrets

Poi, se necessario, modificare /etc/ppp/options.pptp:

root #nano -w /etc/ppp/options.pptp

Una volta fatto tutto ciò, si esegua pptp (insieme alle opzioni che non potevano essere impostate su options.pptp) per connettersi al server:

root #pptp <server ipv4 address>

Preparare l'accesso wireless

Attenzione
Do not use WEP unless it is the only option. WEP provides essentially no security over an open network.
Nota
Il supporto del comando iw potrebbe avere caratteristiche specifiche in base all'architettura. Se il comando non è disponibile, controllare che sia disponibile il pacchetto net-wireless/iw per l'architettura in uso. Il comando iw è disponibile solo se il pacchetto net-wireless/iw è installato.

Quando si utilizza una scheda wireless (802.11), è necessario configurare le impostazioni wireless prima di andare avanti. Per visualizzare le impostazioni della scheda wireless, è possibile utilizzare iw. L'esecuzione di iw potrebbe mostrare qualcosa di simile a questo:

root #iw dev wlp9s0 info
Interface wlp9s0
	ifindex 3
	wdev 0x1
	addr 00:00:00:00:00:00
	type managed
	wiphy 0
	channel 11 (2462 MHz), width: 20 MHz (no HT), center1: 2462 MHz
	txpower 30.00 dBm

Per controllare la connessione in corso:

root #iw dev wlp9s0 link
Not connected.

oppure

root #iw dev wlp9s0 link
Connected to 00:00:00:00:00:00 (on wlp9s0)
	SSID: GentooNode
	freq: 2462
	RX: 3279 bytes (25 packets)
	TX: 1049 bytes (7 packets)
	signal: -23 dBm
	tx bitrate: 1.0 MBit/s
Nota
Alcune schede wireless possono avere un nome di periferica tipo wlan0 o ra0 anziché wlp9s0. Eseguire ip link per stabilire il nome corretto del dispositivo.

Per la maggior parte degli utenti, sono necessarie solo due impostazioni per potersi connettere, l'ESSID (anche conosciuto come nome di rete wireless) e, opzionalmente, la chiave WEP.

  • Prima di tutto, assicurarsi che l'interfaccia sia attiva:
root #ip link set dev wlp9s0 up
  • Per connettersi ad una rete libera chiamata GentooNode:
root #iw dev wlp9s0 connect -w GentooNode
  • Per connettersi con una chiave WEP esadecimale, anteporre alla chiave il prefisso d::
root #iw dev wlp9s0 connect -w GentooNode key 0:d:1234123412341234abcd
  • Per connettersi con una chiave WEP ASCII:
root #iw dev wlp9s0 connect -w GentooNode key 0:una-certa-password
Nota
Se la rete wireless è configurata con WPA o WPA2, allora si deve usare wpa_supplicant. Per ulteriori informazioni sulla configurazione delle reti wireless in Gentoo Linux, leggere il Capitolo sulle reti wireless nel Manuale di Gentoo.

Confermare le impostazioni della rete wireless usando iw dev wlp9s0 link. Una volta che la rete wireless funziona, proseguire con la configurazione delle opzione di rete per il livello IP come descritto nella sezione successiva (Comprendere la terminologia delle reti) od usando lo strumento net-setup come descritto precedentemente.

Configurazione automatica della rete

In cases where automatic network configuration is unsuccessful, the Gentoo boot media provides scripts to aid in network configuration. net-setup can be used to configure wireless network information and static IPs.

root #net-setup eth0

net-setup chiederà alcune informazioni sull'ambiente di rete. Quando avrà concluso, la rete dovrebbe funzionare. Si provi la connessione di rete come precedentemente indicato. Se il test è positivo, congratulazioni! Saltare il resto di questa sezione e continuare con la Preparazione dei dischi.

Importante
Network status should be tested after any configuration steps are taken. In the event that configuration scripts do not work, manual network configuration is required.

Comprendere la terminologia delle reti

If all of the above fails, the network must be configured manually. This is not particularly difficult, but should be done with consideration. This section serves to clarify terminology and introduce users to basic networking concepts pertaining to manually configuring an Internet connection.

Suggerimento
Some CPE (Carrier Provided Equipment) combines the functions of a router, access point, modem, DHCP server, and DNS server into one unit. It's important to differentiate the functions of a device from the physical appliance.

Interfaces and addresses

Network interfaces are logical representations of network devices. An interface needs an address to communicate with other devices on the network. While only a single address is required, multiple addresses can be assigned to a single interface. This is especially useful for dual stack (IPv4 + IPv6) configurations.

For consistency, this primer will assume the interface enp1s0 will be using the address 192.168.0.2.

Importante
IP addresses can be set arbitrarily. As a result, it's possible for multiple devices to use the same IP address, resulting in an address conflict. Address conflicts should be avoided by using DHCP or SLAAC.
Suggerimento
IPv6 typically uses StateLess Address AutoConfiguration (SLAAC) for address configuration. In most cases, manually setting IPv6 addresses is a bad practice. If a specific address suffix is preferred, interface identification tokens can be used.

Networks and CIDR

Once an address is chosen, how does a device know how to talk to other devices?

IP addresses are associated with networks. IP networks are contiguous logical ranges of addresses.

Classless Inter-Domain Routing or CIDR notation is used to distinguish network sizes.

  • The CIDR value, often notated starting with a /, represents the size of the network.
    • The formula 2 ^ (32 - CIDR) can be used to calculate network size.
    • Once network size is calculated, usable node count must be reduced by 2.
      • The first IP in a network is the Network address, and the last is typically the Broadcast address. These addresses are special and cannot be used by normal hosts.
Suggerimento
The most common CIDR values are /24, and /32, representing 254 nodes and a single node respectively.

A CIDR of /24 is the de-facto default network size. This corresponds to a subnet mask of 255.255.255.0, where the last 8 bits are reserved for IP addresses for nodes on a network.

The notation: 192.168.0.2/24 can be interpreted as:

  • The address 192.168.0.2
  • On the network 192.168.0.0
  • With a size of 254 (2 ^ (32 - 24) - 2)
    • Usable IPs are in the range 192.168.0.1 - 192.168.0.254
  • With a broadcast address of 192.168.0.255
    • In most cases, the last address on a network is used as the broadcast address, but this can be changed.

Using this configuration, a device should be able to communicate with any host on the same network (192.168.0.0).

The Internet

Once a device is on a network, how does it know how to talk to devices on the Internet?

To communicate with devices outside of local networks, routing must be used. A router is simply a network device that forwards traffic for other devices. The term default route or gateway typically refers to whatever device on the current network is used for external network access.

Suggerimento
It's a standard practice to make the gateway the first or last IP on a network.

If an Internet-connected router is available at 192.168.0.1, it can be used as the default route, granting Internet access.

To summarize:

  • Interfaces must be configured with an address and network information, such as the CIDR value.
  • Local network access is used to access a router on the same network.
  • The default route is configured, so traffic destined for external networks is forwarded to the gateway, providing Internet access.

The Domain Name System

Remembering IPs is hard. The Domain Name System was created to allow mapping between Domain Names and IP addresses.

Linux systems use /etc/resolv.conf to define nameservers to be used for DNS resolution.

Suggerimento
Many routers can also function as a DNS server, and using a local DNS server can augment privacy and speed up queries through caching.

Many ISPs run a DNS server that is generally advertised to the gateway over DHCP. Using a local DNS server tends to improve query latency, but most public DNS servers will return the same results, so server usage is largely based on preference.

Configurazione manuale della rete

Interface address configuration

Importante
When manually configuring IP addresses, the local network topology must be considered. IP addresses can be set arbitrarily; conflicts may cause network disruption.

To configure enp1s0 with the address 192.168.0.2 and CIDR /24:

root #ip address add 192.168.0.2/24 dev enp1s0
Suggerimento
The start of this command can be shortened to ip a.

Default route configuration

Configuring address and network information for an interface will configure link routes, allowing communication with that network segment:

root #ip route
192.168.0.0/24 dev enp1s0 proto kernel scope link src 192.168.0.2
Suggerimento
This command can be shortened to ip r.

The default route can be set to 192.168.0.1 with:

root #ip route add default via 192.168.0.1

DNS configuration

Nameserver info is typically acquired using DHCP, but can be set manually by adding nameserver entries to /etc/resolv.conf.

Attenzione
If dhcpcd is running, changes to /etc/resolv.conf will not persist. Status can be checked with ps x | grep dhcpcd.

nano is included in Gentoo boot media and can be used to edit /etc/resolv.conf with:

root #nano -w /etc/resolv.conf

Lines containing the keyword nameserver followed by a DNS server IP address are queried in order of definition:

FILE /etc/resolv.confUse Quad9 DNS.
nameserver 9.9.9.9
nameserver 149.112.112.112
FILE /etc/resolv.confUse Cloudflare DNS.
nameserver 1.1.1.1
nameserver 1.0.0.1

DNS status can be checked by pinging a domain name:

root #ping -c 3 gentoo.org

Once connectivity has been verified, continue with Preparing the disks.




Introduzione ai dispositivi a blocchi

Dispositivi a blocchi

Approfondiamo ora gli aspetti relativi ai dischi di Gentoo Linux e Linux in generale, compresi i filesystem, le partizioni e i dispositivi a blocchi di Linux. Appena tutto sarà chiaro in merito ai filesystem, allora partizioni e filesystem potranno essere scelti per installare Gentoo Linux.

Per iniziare, diamo un'occhiata ai dispositivi a blocchi. Quello più noto è solitamente il primo disco in un sistema Linux, ovvero /dev/sda. I dischi SCSI e Serial ATA sono entrambi chiamati /dev/sd*; persino i dispositivi IDE sono etichettati /dev/sd* quando si usa il framework libata nel kernel. Invece, con il framework (libreria di codici) dei vecchi dispositivi, il primo disco IDE è /dev/hda.

The following table will help readers determine where to find a certain type of block device on the system:

Type of device Default device handle Editorial notes and considerations
IDE, SATA, SAS, SCSI, or USB flash /dev/sda Found on hardware from roughly 2007 until the present, this device handle is perhaps the most commonly used in Linux. These types of devices can be connected via the SATA bus, SCSI, USB bus as block storage. As example, the first partition on the first SATA device is called /dev/sda1.
NVM Express (NVMe) /dev/nvme0n1 The latest in solid state technology, NVMe drives are connected to the PCI Express bus and have the fastest transfer block speeds on the market. Systems from around 2014 and newer may have support for NVMe hardware. The first partition on the first NVMe device is called /dev/nvme0n1p1.
MMC, eMMC, and SD /dev/mmcblk0 embedded MMC devices, SD cards, and other types of memory cards can be useful for data storage. That said, many systems may not permit booting from these types of devices. It is suggested to not use these devices for active Linux installations; rather consider using them to transfer files, which is their typical design intention. Alternatively this storage type could be useful for short-term file backups or snapshots.

I dispositivi a blocchi di cui sopra rappresentano un'interfaccia astratta del disco. I programmi dell'utente possono usare questi dispositivi a blocchi per interagire col disco senza doversi preoccupare del fatto che i dischi siano IDE, SCSI o altro. Il programma può semplicemente indirizzare lo spazio sul disco come un insieme di blocchi da 512 byte contigui e accessibili in modo casuale.


Tabelle delle partizioni

Benché per ospitare un sistema Linux sia teoricamente possibile usare un disco grezzo e non partizionato (quando si crea un RAID btrfs per esempio), praticamente ciò non viene mai fatto. Piuttosto, i dischi vengono suddivisi in unità a blocchi più piccole e maneggevoli. Su sistemi amd64, esse sono chiamate partizioni. Attualmente sono standardizzate due tecnologie di partizionamento: MBR e GPT.

GPT

La configurazione tramite GPT (GUID Partition Table) usa identificatori a 64 bit per le partizioni. Lo spazio dove memorizza le informazioni sulle partizioni è molto più grande dei 512 byte dell'MBR, il ché significa che non c'è praticamente alcun limite alla quantità di partizioni definibili su un disco GPT. Inoltre, il limite per la dimensione massima di una partizione è di gran lunga maggiore (quasi 8 ZB - sì, zettabytes).

Quando l'interfaccia software del sistema, che si pone tra il sistema operativo e il firmware, è UEFI (anziché BIOS), GPT è quasi obbligatoria in quanto potrebbero sorgere problemi di compatibilità con MBR.

GPT trae anche vantaggio dalle somme di controllo (checksum) e dalla ridondanza. Porta il controllo CRC32 alla testata delle tabelle di partizione per rilevare errori ed offre un backup del segmento GPT alla fine del disco. Questo backup può essere usato per ripristinare i danni del segmento GPT corrente all'inizio del disco.

Importante
There are a few caveats regarding GPT:
  • Using GPT on a BIOS-based computer works, but then one cannot dual-boot with a Microsoft Windows operating system. The reason is that Microsoft Windows will boot in UEFI mode if it detects a GPT partition label.
  • Some buggy (old) motherboard firmware configured to boot in BIOS/CSM/legacy mode might also have problems with booting from GPT labeled disks.

MBR

La configurazione tramite MBR (Master Boot Record) usa identificatori a 32 bit per il settore di avvio e per stabilire la grandezza delle partizioni. Supporta tre tipi di partizione: primaria, estesa e logica. Le partizioni primarie memorizzano le loro informazioni nel master boot record stesso - uno spazio molto piccolo (solitamente 512 byte) all'inizio del disco. A causa del poco spazio, vengono supportate solo quattro partizioni primarie (per esempio, da /dev/sda1 a /dev/sda4).

Per supportare più partizioni, una delle partizioni primarie può essere definita come partizione estesa. Questa partizione può in tal caso contenere a sua volta delle partizioni logiche (partizioni all'interno di una partizione).

Importante
Although still supported by most motherboard manufacturers, MBR boot sectors and their associated partitioning limitations are considered legacy. Unless working with hardware that is pre-2010, it best to partition a disk with GUID Partition Table. Readers who must proceed with setup type should knowingly acknowledge the following information:
  • Most post-2010 motherboards consider using MBR boot sectors a legacy (supported, but not ideal) boot mode.
  • Due to using 32-bit identifiers, partition tables in the MBR cannot address storage space that is larger than 2 TiBs in size.
  • Unless an extended partition is created, MBR supports a maximum of four partitions.
  • This setup does not provide a backup boot sector, so if something overwrites the partition table, all partition information will be lost.
That said, MBR and legacy BIOS boot may still used in virtualized cloud environments such as AWS.

The Handbook authors suggest using GPT whenever possible for Gentoo installations.

Partizionamento avanzato

I CD di installazione amd64 forniscono supporto per il gestore dei volumi logici (LVM). LVM accresce la flessibilità offerta dalla configurazione di partizionamento. Le istruzioni di installazione riportate di seguito si concentrano su partizioni "regolari", ma è bene sapere che anche LVM è supportato se si desidera proseguire per quella strada. Leggere l'articolo LVM per ulteriori dettagli. I nuovi arrivati stiano attenti: benché LVM sia completamente supportato, va al di là dello scopo di questa guida.

Schema di partizionamento predefinito

Throughout the remainder of the handbook, we will discuss and explain two cases:

  1. UEFI firmware with GUID Partition Table (GPT) disk.
  2. MBR DOS/legacy BIOS firmware with a MBR partition table disk.

While it is possible to mix and match boot types with certain motherboard firmware, mixing goes beyond the intention of the handbook. As previously stated, it is strongly recommended for installations on modern hardware to use UEFI boot with a GPT disklabel disk.

Per tutto il resto del manuale, verrà usato il seguento schema di partizionamento come esempio semplice di configurazione:

Importante
The first row of the following table contains exclusive information for either a GPT disklabel or a MBR DOS/legacy BIOS disklabel. When in doubt, proceed with GPT, since amd64 machines manufactured after the year 2010 generally support UEFI firmware and GPT boot sector.
Partizione Filesystem Dimensione Descrizione
/dev/sda1 (bootloader) 2M Partizione di avvio BIOS
/dev/sda1 ext2 (o fat32 se si utilizza UEFI) 128M Partizione di sistema Boot/EFI
/dev/sda3 (swap) 512M o maggiore Partizione di swap
/dev/sda4 ext4 Spazio rimanente del disco Partizione radice (root)

Se ciò è sufficiente e il lettore ha scelto la configurazione GPT, si può proseguire con la sezione Predefinito: Uso di parted per partizionare il disco. Coloro che sono ancora interessati a MBR (ehi, capita!) e vogliono usare la configurazione d'esempio, possono proseguire con l'Alternativa: Uso di fdisk per partizionare il disco.

Sia fdisk che parted sono utilità di partizionamento. fdisk è ben noto, stabile, e raccomandato per la configurazione di partizionamento MBR, mentre parted è stata una delle prima utilità di gestione dei dispositivi a blocchi Linux a supportare le partizioni GPT. Coloro a cui piace l'interfaccia di fdisk possono usare gdisk (fdisk GPT) come alternativa a parted.

Prima di proseguire con le istruzioni di creazione, il primo insieme di sezioni descriverà con maggiori dettagli come si possono creare schemi di partizionamento e si menzioneranno alcune trappole comuni.

Progettazione di uno schema delle partizioni

Quante partizioni e quanto grandi?

Il numero di partizioni dipende fortemente dal tipo di ambiente. Per esempio, se sono previsti molti utenti, allora è consigliato avere la /home/ separata così da migliorare la sicurezza e rendere più facili i backup. Se Gentoo viene installato per fare da server di posta elettronica, allora /var/ è meglio che stia separata in quanto le email vengono memorizzate all'interno di /var/. Una buona scelta del filesystem massimizzerà le prestazioni. I server da gioco avranno /opt/ separata, in quando la maggior parte dei server da gioco sono installati lì. La ragione è simile al percorso /home/: sicurezza e backup. Nella maggior parte delle situazioni, /usr/ dovrà essere capiente: non solo contiene la maggior parte delle applicazioni, ma in genere ospita anche repository ebuild di Gentoo (solitamente su /usr/portage), che fin dall'inizio occupa già 650 MB. Questa stima dello spazio su disco esclude le cartelle packages/ e distfiles/ che sono generalmente memorizzate all'interno di questo archivio ebuild.

In most situations on Gentoo, /usr and /var should be kept relatively large in size. /usr hosts the majority of applications available on the system and the Linux kernel sources (under /usr/src). By default, /var hosts the Gentoo ebuild repository (located at /var/db/repos/gentoo) which, depending on the file system, generally consumes around 650 MiB of disk space. This space estimate excludes the /var/cache/distfiles and /var/cache/binpkgs directories, which will gradually fill with source files and (optionally) binary packages respectively as they are added to the system.

Molto dipende da ciò che desidera l'amministratore. Partizioni o volumi separati hanno i seguenti vantaggi:

  • Scelta del miglior filesystem per ciascuna partizione o volume.
  • L'intero sistema non esaurirà lo spazio, nel caso in cui uno strumento invalido continui a scrivere file su una partizione o un volume.
  • Se necessario, i controlli del filesystem impiegheranno meno tempo, in quanto possono essere fatti in parallelo (benché questo vantaggio sia maggiore con i dischi multipli piuttosto che con le sole partizioni multiple).
  • La sicurezza può essere migliorata montando alcune partizioni o volumi in modalità di sola lettura, nosuid (ignora i bit setuid), noexec (ignora i bit eseguibili), ecc.


Tuttavia, anche avere partizioni multiple presenta degli svantaggi. Se il sistema non viene appropriatamente configurato potrebbe avere molto spazio libero su una partizione e niente più spazio su un'altra. Un altro aspetto noioso è che partizioni separate - specialmente per i punti di montaggio importanti come /usr/ o /var/ - richiedono spesso che l'amministratore avvii il sistema con un initramfs per montare la partizione, prima che altri script all'avvio vengano eseguiti. Non sempre si verifica questo caso, quindi i risultati possono variare.

C'è anche un limite di 15 partizioni per SCSI e SATA a meno che il disco non usi una configurazione GPT.

Nota
Installations that intend to use systemd as the service and init system must have the /usr directory available at boot, either as part of the root filesystem or mounted via an initramfs.

Riguardo lo spazio di swap?

Non c'è un valore perfetto per la partizione di swap. Lo scopo dello spazio di swap è quello di fornire, tramite disco, memoria al kernel quando la memoria interna (RAM) è sotto pressione. Uno spazio di swap permette al kernel di spostare le pagine di memoria, che non verranno utilizzate entro breve tempo, sul disco (swap o spaginazione), liberando memoria. Ovviamente, se quella memoria torna improvvisamente necessaria, queste pagine vengono rimesse nella memoria (paginazione), ciò richiederà un po' di tempo (dato che i dischi sono molto lenti, se paragonati alla memoria interna).

Quando il sistema non esegue applicazioni che occupano molta memoria oppure se il sistema ha tantissima memoria disponibile, allora è probabile che non serva molto spazio di swap. Comunque, lo spazio di swap è usato anche per scriverci tutta la memoria in caso di ibernazione. Se il sistema deve andare in ibernazione, allora è richiesto uno spazio di swap più grande, spesso pari ad almeno la quantità di memoria installata sul sistema.


Uso di UEFI

Quando si installa Gentoo su un sistema che utilizza UEFI per avviare il sistema operativo (invece di BIOS), allora è importante creare una Partizione di Sistema EFI (ESP). Le istruzioni per parted di seguito contengono i puntatori necessari per gestire questa operazione correttamente.

La partizione ESP deve essere una variante di FAT (talvolta mostrata come vfat sui sistemi Linux). Le specifiche UEFI ufficiali dichiarano che i filesystem FAT12, 16 o 32 vengono riconosciuti dal firmware UEFI, benché sia raccomandato FAT32 per la ESP. Procedere con la formattazione della ESP in FAT32:

root #mkfs.fat -F 32 /dev/sda1
Importante
Se non viene usata una variante FAT per l'ESP, non è garantito che il firmware UEFI di sistema trovi il bootloader (o il kernel Linux) e probabilmente non sarà in grado di avviare il sistema!

Cos'è la partizione di avvio BIOS?

Una partizione di avvio BIOS è una partizione molto piccola (da 1 a 2 MB) in cui i bootloader come GRUB2 possono inserire dati aggiuntivi se non riescono a stare nello spazio allocato (poche centinaia di byte nel caso di MBR) e se non possono stare altrove.

Alternativa: Uso di fdisk per partizionare il disco

La seguente parte spiega come impostare le partizioni secondo l'esempio usando fdisk. Lo schema delle partizioni d'esempio menzionato prima:

Modificare lo schema di partizionamento in base alle proprie personali preferenze.

Partizione Descrizione
/dev/sda1 Partizione di avvio BIOS
/dev/sda1 Partizione di avvio
/dev/sda3 Partizione di swap
/dev/sda4 Partizione radice (root)

Visualizzare lo schema delle partizioni correnti con fdisk

fdisk è un famoso e potente strumento per dividere un disco in partizioni. Lanciare fdisk per il disco (nel nostro esempio usiamo /dev/sda):

root #fdisk /dev/sda

Usare il tasto p per visualizzare l'attuale configurazione delle partizioni sul disco:

Command (m for help):p
Disk /dev/sda: 240 heads, 63 sectors, 2184 cylinders
Units = cylinders of 15120 * 512 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        14    105808+  83  Linux
/dev/sda2            15        49    264600   82  Linux swap
/dev/sda3            50        70    158760   83  Linux
/dev/sda4            71      2184  15981840    5  Extended
/dev/sda5            71       209   1050808+  83  Linux
/dev/sda6           210       348   1050808+  83  Linux
/dev/sda7           349       626   2101648+  83  Linux
/dev/sda8           627       904   2101648+  83  Linux
/dev/sda9           905      2184   9676768+  83  Linux

Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G EFI System /dev/sda2 2099200 10487807 8388608 4G Linux swap /dev/sda3 10487808 1953523711 1943035904 926.5G Linux root (x86-64)

}}

Questo particolare disco è stato configurato per ospitare 7 filesystem Linux (ciascuno con una corrispondente partizione elencata come "Linux") e una partizione di swap (indicata con "Linux swap").

Rimuovere tutte le partizioni con fdisk

Pressing the g key will instantly remove all existing disk partitions and create a new GPT disklabel:

Command (m for help):g
Created a new GPT disklabel (GUID: 3E56EE74-0571-462B-A992-9872E3855D75).

Prima rimuovere tutte le partizioni esistenti dal disco. Digitare d per eliminare una partizione. Per esempio, per eliminare un'esistente /dev/sda1:

Command (m for help):d
Partition number (1-4): 1

La partizione è ora programmata per l'eliminazione. Non sarà più mostrata quando si richiede l'elenco delle partizioni (p), comunque non sarà effettivamente eliminata finché i cambiamenti non saranno salvati. Ciò permette agli utenti di annullare l'operazione se è stato commesso qualche errore - in tal caso, digitare subito q e premere Enter così la partizione non sarà eliminata.

Digitare nuovamente p per visualizzare un elenco delle partizioni e premere d seguito dal numero della partizione da eliminare. Alla fine, la tabella delle partizioni sarà vuota:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
Device Boot    Start       End    Blocks   Id  System

Ora che la tabella delle partizioni risulta vuota, anche se solo nella memoria, siamo pronti per creare le nuove partizioni.

Creare la partizione di avvio BIOS

Nota
A smaller ESP is possible but not recommended, especially given it may be shared with other OSes.

Per prima cosa si crei una piccola partizione di avvio per il BIOS. Digitare n per creare una nuova partizione, quindi p per selezionare una partizione primaria, seguito da 1 per selezionare la prima partizione primaria. Quando viene richiesto il settore di inizio, assicurarsi che inizi dal 2048 (necessario per il boot loader) e premere Enter. Quando viene richiesto il settore finale, digitare +2M per creare una partizione grande 2 MByte:

Command (m for help):n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (64-10486533532, default 64): 2048
Last sector, +sectors +size{M,K,G} (4096-10486533532, default 10486533532): +2M

Do you want to remove the signature? [Y]es/[N]o: Y The signature will be removed by a write command.

}}

Segnare la partizione per gli scopi di UEFI:

Command (m for help):t
Selected partition 1
Hex code (type L to list codes): 4
Changed system type of partition 1 to 4 (BIOS boot)

Optionally, to have the ESP conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Selected partition 1
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): c12a7328-f81f-11d2-ba4b-00a0c93ec93b
Partition UUID changed from 10293DC1-DF6C-4443-8ACF-C756B81B4767 to C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

Creare la partizione di swap

Per creare una partizione di swap: digitare n per creare una nuova partizione, poi p per dire a fdisk di creare una partizione primaria. Digitare 3 per creare una terza partizione primaria, /dev/sda3. Quando viene richiesto il settore di inizio, premere Enter. Quando viene richiesto il settore finale, digitare +512M (o qualsiasi altra grandezza sia necessaria per lo spazio di swap) così da creare una partizione grande 512 MB.

Creare la partizione di avvio

Fatto tutto questo, digitare t per impostare il tipo di partizione, 3 per selezionare la partizione appena creata e poi digitare 82 per impostare il tipo di partizione "Linux Swap".

Command (m for help):t
Partition number (1,2, default 2): 2
Partition type or alias (type L to list all): 19
 
Changed type of partition 'Linux filesystem' to 'Linux swap'.

Optionally, to have the swap partition conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Partition number (1,2, default 2): 2
Selected partition 2
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
Partition UUID changed from 7529CDF6-9482-4497-B021-576745648B2A to 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F..

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

Creare la partizione radice

Infine, per creare la partizione radice (root), digitare n per creare una nuova partizione, quindi p per indicare a fdisk di creare una partizione primaria. Poi digitare 4 per creare la quarta partizione primaria, /dev/sda4. Quando viene richiesto il settore di inizio, premere Enter. Quando viene richiesto il settore finale, premere Enter per creare una partizione che occupi il rimanente spazio su disco. Dopo aver completato questi passaggi, digitando p si dovrebbe vedere una tabella delle partizioni simile a questa:

Command (m for help):n
Partition number (3-128, default 3): 3
First sector (10487808-1953525134, default 10487808):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10487808-1953525134, default 1953523711):
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 3 of type 'Linux filesystem' and of size 926.5 GiB..
Nota
Setting the root partition's type to "Linux root (x86-64)" is not required and the system will function normally if it is set to the "Linux filesystem" type. This filesystem type is only necessary for cases where a bootloader that supports it (i.e. systemd-boot) is used and a fstab file is not wanted.

After creating the root partition, press t to set the partition type, 3 to select the partition just created, and then type in 23 to set the partition type to "Linux Root (x86-64)".

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

<div lang="en" dir="ltr" class="mw-content-ltr">
Changed type of partition 'Linux filesystem' to 'Linux root (x86-64)'

Optionally, to have the root partition conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Partition number (1-3, default 3): 3
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): 4f68bce3-e8cd-4db1-96e7-fbcaf984b709
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Partition UUID changed from 40465382-FA2A-4846-9827-640821CC001F to 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709.

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

After completing these steps, pressing p should display a partition table that looks similar to the following:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1         3      5198+  ef  EFI (FAT-12/16/32)
/dev/sda2   *         3        14    105808+  83  Linux
/dev/sda3            15        81    506520   82  Linux swap
/dev/sda4            82      3876  28690200   83  Linux

Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G Linux filesystem /dev/sda2 2099200 10487807 8388608 4G Linux swap /dev/sda3 10487808 1953523711 1943035904 926.5G Linux root (x86-64)

Filesystem/RAID signature on partition 1 will be wiped.

}}

Salvare lo schema delle partizioni

Per salvare la configurazione delle partizioni e uscire da fdisk, premere w.

Command (m for help):w

Ora che le partizioni sono state create, si deve procedere alla creazione di un filesystem su ciascuna di esse.

Partitioning the disk with MBR for BIOS / legacy boot

The following table provides a recommended partition layout for a trivial MBR DOS / legacy BIOS boot installation. Additional partitions can be added according to personal preference or system design goals.

Device path (sysfs) Mount point File system DPS UUID (PARTUUID) Description
/dev/sda1 /boot xfs N/A MBR DOS / legacy BIOS boot partition details.
/dev/sda2 N/A. Swap is not mounted to the filesystem like a device file. swap 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f Swap partition details.
/dev/sda3 / xfs 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 Root partition details.

Change the partition layout according to personal preference.

Viewing the current partition layout

Fire up fdisk against the disk (in our example, we use /dev/sda):

root #fdisk /dev/sda

Use the p key to display the disk's current partition configuration:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Device     Boot    Start        End    Sectors   Size Id Type
/dev/sda1  *        2048    2099199    2097152     1G 83 Linux
/dev/sda2        2099200   10487807    8388608     4G 82 Linux swap / Solaris
/dev/sda3       10487808 1953525167 1943037360 926.5G 83 Linux

This particular disk was until now configured to house two Linux filesystems (each with a corresponding partition listed as "Linux") as well as a swap partition (listed as "Linux swap"), using a GPT table.

Creating a new disklabel / removing all partitions

Pressing o will instantly remove all existing disk partitions and create a new MBR disklabel (also named DOS disklabel):

Command (m for help):o
Created a new DOS disklabel with disk identifier 0xf163b576.
The device contains 'gpt' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Alternatively, to keep an existing DOS disklabel (see the output of p above), consider removing the existing partitions one by one from the disk. Press d to delete a partition. For instance, to delete an existing /dev/sda1:

Command (m for help):d
Partition number (1-4): 1

The partition has now been scheduled for deletion. It will no longer show up when printing the list of partitions (p, but it will not be erased until the changes have been saved. This allows users to abort the operation if a mistake was made - in that case, type q immediately and hit Enter and the partition will not be deleted.

Repeatedly press p to print out a partition listing and then press d and the number of the partition to delete it. Eventually, the partition table will be empty:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576

The disk is now ready to create new partitions.

Creating the boot partition

First, create a small partition which will be mounted as /boot. Press n to create a new partition, followed by p for a primary partition and 1 to select the first primary partition. When prompted for the first sector, make sure it starts from 2048 (which may be needed for the boot loader) and press Enter. When prompted for the last sector, type +1G to create a partition 1 GB in size:

Command (m for help):n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1953525167, default 1953525167): +1G
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 1 of type 'Linux' and of size 1 GiB.

Mark the partition as bootable by pressing the a key and pressing Enter:

Command (m for help):a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Note: if more than one partition is available on the disk, then the partition to be flagged as bootable will have to be selected.

Creating the swap partition

Next, to create the swap partition, press n to create a new partition, then p, then type 2 to create the second primary partition, /dev/sda2. When prompted for the first sector, press Enter. When prompted for the last sector, type +4G (or any other size needed for the swap space) to create a partition 4GB in size.

Command (m for help):n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-1953525167, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-1953525167, default 1953525167): +4G
 
Created a new partition 2 of type 'Linux' and of size 4 GiB.

After all this is done, press t to set the partition type, 2 to select the partition just created and then type in 82 to set the partition type to "Linux Swap".

Command (m for help):t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 82
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Creating the root partition

Finally, to create the root partition, press n to create a new partition. Then press p and 3 to create the third primary partition, /dev/sda3. When prompted for the first sector, hit Enter. When prompted for the last sector, hit Enter to create a partition that takes up the rest of the remaining space on the disk:

Command (m for help):n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (10487808-1953525167, default 10487808):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10487808-1953525167, default 1953525167):
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 3 of type 'Linux' and of size 926.5 GiB.

After completing these steps, pressing p should display a partition table that looks similar to this:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Device     Boot    Start        End    Sectors   Size Id Type
/dev/sda1  *        2048    2099199    2097152     1G 83 Linux
/dev/sda2        2099200   10487807    8388608     4G 82 Linux swap / Solaris
/dev/sda3       10487808 1953525167 1943037360 926.5G 83 Linux

Saving the partition layout

Press w to write the partition layout and exit fdisk:

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

Now it is time to put filesystems on the partitions.


Creazione dei file system

Attenzione
When using SSD or NVMe drive, it is wise to check for firmware upgrades. Some Intel SSDs in particular (600p and 6000p) require a firmware upgrade for possible data corruption induced by XFS I/O usage patterns. The problem is at the firmware level and not any fault of the XFS filesystem. The smartctl utility can help check the device model and firmware version.

Introduzione

Una volta create le partizioni, è ora di inserirci un filesystem. Nella sezione successiva vengono descritti i file system supportati da Linux. I lettori che sanno già quale filesystem usare possono continuare con la sezione Applicare un filesystem ad una partizione. Gli altri lettori dovrebbero continuare a leggere per comprendere meglio i filesystem disponibili...

Filesystem

Sono disponibili numerosi filesystem. Alcuni di essi sono ritenuti stabili sull'architettura amd64 - è consigliabile informarsi sui filesystem e sul loro supporto, prima di selezionarne uno più sperimentale da usare su partizioni importanti.

btrfs
È un filesystem di nuova generazione che fornisce molte caratteristiche avanzate, come la possibilità di creare istantanee, l'auto-riparazione tramite checksum, la compressione trasparente, i sottovolumi e il RAID integrato. Alcune distribuzioni hanno iniziato ad offrirlo come opzione standard, ma non è pronto per la produzione. Sono frequenti i rapporti di corruzione del filesystem. I suoi sviluppatori spingono la gente ad utilizzare la versione più recente del kernel, perché quelle più vecchie è noto che causino problemi. Così è stato per anni ed è troppo presto per dire se le cose sono cambiate. Le correzioni dei problemi di corruzione raramente vengono trasferite sui kernel più vecchi. Si proceda con cautela quando si utilizza questo filesystem!
ext2
È l'effettivo e collaudato filesystem di Linux, ma non ha il journaling dei metadati, il ché significa che i controlli di routine del filesystem ext2 effettuati all'avvio possono richiedere molto tempo. Ormai esiste una scelta piuttosto ampia di filesystem con journaling, la cui consistenza può essere controllata molto velocemente e sono infatti generalmente preferiti rispetto alle controparti senza journaling. I filesystem con journaling prevengono lunghi ritardi qualora il sistema si avvii con il filesystem in uno stato inconsistente (errori di coerenza).
ext3
È la versione con journaling del filesystem ext2, che fornisce il journaling dei metadati per un ripristino veloce in aggiunta ad altre modalità migliorate di journaling come quello a dati completi e a dati ordinati. Usa un indice HTree che permette alte prestazioni in quasi tutte le situazioni. In breve, ext3 è un filesystem molto buono e affidabile.
ext4
Inizialmente creato come un derivato di ext3, ext4 porta nuove caratteristiche, miglioramenti delle prestazioni e rimozione dei limiti delle dimensioni con lievi modifiche al formato su disco. Può ospitare volumi fino a 1 EB e con una dimensione massima dei file di 16 TB. Invece della classica allocazione a blocchi bitmap di ext2-3, ext4 utilizza le estensioni, che migliorano le prestazioni con file grandi e riducono la frammentazione. Ext4 fornisce anche algoritmi di allocazione dei blocchi più sofisticati (allocazione ritardata e multiblocco) dando ai driver del filesystem più modi per ottimizzare la distribuzione dei dati su disco. Ext4 è il filesystem raccomandato per tutti gli utilizzi e per tutte le piattaforme.
f2fs
Il Flash-Friendly File System fu originariamente creato da Samsung per essere usato con la memoria flash NAND. Nel secondo quadrimestre del 2016, questo filesystem era considerato ancora immaturo, ma è una scelta decente quando si installa Gentoo su microSD, dischi USB, o altri dispositivi di memoria basati su flash.
JFS
È il filesystem ad alte prestazioni di IBM. JFS è un filesystem leggero, veloce e affidabile basato su B+tree con buone prestazioni in varie condizioni.
ReiserFS
È un filesystem con journaling basato su B+tree che ha delle buone prestazioni complessive, specialmente quando si ha a che fare con molti piccoli file al costo di più cicli di CPU. ReiserFS sembra essere meno mantenuto rispetto ad altri filesystem.
XFS
È un filesystem con journaling dei metadati che fornisce un robusto insieme di caratteristiche ed è ottimizzato per la scalabilità. XFS sembra essere meno indulgente in caso di vari problemi hardware.
vfat
Anche conosciuto come FAT32, è supportato da Linux ma non supporta alcuna configurazione dei permessi. È principalmente usato per interoperabilità con altri sistemi operativi (principalmente Microsoft Windows) ma è anche una necessità per alcuni firmware di sistema (come UEFI).
NTFS
Il filesystem "New Technology" è quello principale su Microsoft Windows. Analogamente a vfat, non memorizza le impostazioni dei permessi o gli attributi estesi necessari ai sistemi BSD o Linux affinché funzionino correttamente, di conseguenza non può essere usato come filesystem radice (root). Dovrebbe essere usato solamente per l'interoperabilità con i sistemi Microsoft Windows (si noti l'enfasi su solamente).

More extensive information on filesystems can be found in the community maintained Filesystem article.

Applicare un filesystem ad una partizione

Nota
Please make sure to emerge the relevant user space utilities package for the chosen filesystem before rebooting. There will be a reminder to do so near the end of the installation process.

Per creare un filesystem su una partizione o su un volume, ci sono strumenti avviabili dallo spazio utente per ogni possibile filesystem. Cliccare sul nome del filesystem nella tabella sottostante per informazioni aggiuntive su ciascun filesystem:

Filesystem Comando di creazione Sul CD minimale? Pacchetto
btrfs mkfs.btrfs sys-fs/btrfs-progs
ext2 mkfs.ext2 sys-fs/e2fsprogs
ext3 mkfs.ext3 sys-fs/e2fsprogs
ext4 mkfs.ext4 sys-fs/e2fsprogs
f2fs mkfs.f2fs sys-fs/f2fs-tools
jfs mkfs.jfs sys-fs/jfsutils
reiserfs mkfs.reiserfs sys-fs/reiserfsprogs
xfs mkfs.xfs sys-fs/xfsprogs
vfat mkfs.vfat sys-fs/dosfstools
NTFS mkfs.ntfs sys-fs/ntfs3g
Importante
The handbook recommends new partitions as part of the installation process, but it is important to note running any mkfs command will erase any data contained within the partition. When necessary, ensure any data that exists within is appropriately backed up before creating a few filesystem.

Per esempio, per avere la partizione boot (/dev/sda1) in ext2 e la partizione root (/dev/sda3) in ext4 come nello schema delle partizioni d'esempio, si devono usare i seguenti comandi:

root #mkfs.ext4 /dev/sda3

EFI system partition filesystem

The EFI system partition (/dev/sda1) must be formatted as FAT32:

root #mkfs.ext2 /dev/sda1

Legacy BIOS boot partition filesystem

Systems booting via legacy BIOS with a MBR/DOS disklabel can use any filesystem format supported by the bootloader.

For example, to format with XFS:

root #mkfs.xfs /dev/sda1

Small ext4 partitions

Quando si usa ext2, ext3 o ext4 su una piccola partizione (minore di 8GB), allora il filesystem deve essere creato con le opzioni appropriate per riservare abbastanza inode. L'applicazione mke2fs mkfs.ext2 usa l'impostazione "bytes-per-inode" per calcolare quanti inode dovrebbe avere un filesystem. Su partizioni più piccole, è consigliato aumentare il numero di inode calcolati.

root #mkfs.ext2 -T small /dev/<dispositivo>

Questa scelta generalmente quadruplica il numero di inode per un certo filesystem poiché i suoi "bytes-per-inode" anziché uno ogni 16kB diventano uno ogni 4kB. Ciò può essere ulteriormente modificato specificando la proporzione:

Attivazione della partizione di swap

mkswap è il comando che viene usato per inizializzare la partizione di swap:

root #mkswap /dev/sda2

Per attivare la partizione di swap, usare swapon:

root #swapon /dev/sda2

This 'activation' step is only necessary because the swap partition is newly created within the live environment. Once the system has been rebooted, as long as the swap partition is properly defined within fstab or other mount mechanism, swap space will activate automatically.

Montaggio della partizione di root

Nota
Installations which were previously started, but did not finish the installation process can resume the installation from this point in the handbook. Use this link as the permalink: Resumed installations start here.

Certain live environments may be missing the suggested mount point for Gentoo's root partition (/mnt/gentoo), or mount points for additional partitions created in the partitioning section:

root #mkdir --parents /mnt/gentoo

For EFI installs only, the ESP should be mounted under the root partition location:

root #mkdir --parents /mnt/gentoo/efi

Continue creating additional mount points necessary for any additional (custom) partition(s) created during previous steps by using the mkdir command.

Ora che le partizioni sono inizializzate ed ospitano un filesystem, è tempo di montare quelle partizioni. Usare il comando mount, ma non dimenticarsi di creare le directory (cartelle) di montaggio necessarie su cui montare ogni partizione creata. Nell'esempio è riportato come montare la partizione di root:

Mount the root partition:

root #mount /dev/sda3 /mnt/gentoo

Continue mounting additional (custom) partitions as necessary using the mount command.

Nota
Se è necessario che /tmp/ risieda su una partizione separata, assicurarsi di cambiare i suoi permessi dopo averla montata:
root #chmod 1777 /mnt/gentoo/tmp
Ciò è valido anche per /var/tmp.

Più avanti nel manuale, il filesystem proc (un'interfaccia virtuale fornita dal kernel) ed altri pseudo-filesystem del kernel verranno montati. Però prima è necessario Installare i file di installazione di Gentoo.




Scegliere uno stage tarball

Suggerimento
On supported architectures, it is recommended for users targeting a desktop (graphical) operating system environment to use a stage file with the term desktop within the name. These files include packages such as sys-devel/llvm and dev-lang/rust-bin and USE flag tuning which will greatly improve install time.

The stage file acts as the seed of a Gentoo install. Stage files are generated with Catalyst by the Release Engineering Team. Stage files are based on specific profiles, and contain an almost-complete system.

When choosing a stage file, it's important to pick one with profile targets corresponding to the desired system type.

Importante
While it's possible to make major profile changes after an installation has been established, switching requires substantial effort and consideration, and is outside the scope of this installation manual. Switching init systems is difficult, but switching from no-multilib to multilib requires extensive Gentoo and low-level toolchain knowledge.

La maggior parte degli utenti non dovrebbe usare le opzioni 'avanzate' dei tarball; infatti queste riguardano specifiche configurazioni software o hardware.

OpenRC

OpenRC is a dependency-based init system (responsible for starting up system services once the kernel has booted) that maintains compatibility with the system provided init program, normally located in /sbin/init. It is Gentoo's native and original init system, but is also deployed by a few other Linux distributions and BSD systems.

OpenRC does not function as a replacement for the /sbin/init file by default and is 100% compatible with Gentoo init scripts. This means a solution can be found to run the dozens of daemons in the Gentoo ebuild repository.

systemd

systemd is a modern SysV-style init and rc replacement for Linux systems. It is used as the primary init system by a majority of Linux distributions. systemd is fully supported in Gentoo and works for its intended purpose. If something seems lacking in the Handbook for a systemd install path, review the systemd article before asking for support.

Multilib (32 e 64 bit)

Nota
Not every architecture has a multilib option. Many only run with native code. Multilib is most commonly applied to amd64.

Scegliere un tarball base per il sistema fa risparmiare una quantità considerevole di tempo lungo il processo di installazione, in particolare quando si dovrà scegliere un profilo corretto. La selezione di uno stage tarball avrà implicazioni dirette sulla configurazione del futuro sistema e può anche prevenire possibili problemi futuri. Il tarball multilib usa librerie a 64 bit ogni volta che è possibile, mentre solo per ragioni di compatibilità passa ai 32 bit. Questa è un'eccellente scelta per la maggior parte delle installazioni, dato che offre grande flessibilità per una personalizzazione futura. Per coloro che desiderano che il loro sistema sia in grado di passare facilmente da un profilo all'altro dovrebbero scegliere un tarbal multilib in relazione all'architettura del loro processore.

Suggerimento
Using multilib targets makes it easier to switch profiles later, compared to no-multilib

Non multilib (64 bit puro)

Attenzione
Siate consapevoli che migrare da un sistema no-multilib ad uno multilib richiede una conoscenza di Gentoo molto collaudata, oltre ad una serie di strumenti di basso livello (ciò potrebbe far preoccupare persino i nostri sviluppatori di strumenti (toolchain)). Non è per i deboli di cuore e va oltre lo scopo di questa guida.

Scegliere un tarball non multilib come base per il sistema offre un ambiente completamente a 64 bit. Ciò rende improbabile il passaggio ad un profilo multilib, seppur possibile. Coloro che cominciano ad usare Gentoo non dovrebbero scegliere un tarball no-multilib a meno che non sia assolutamente necessario.

Scaricamento dello stage tarball

Impostare data e ora

Stage archives are generally obtained using HTTPS which requires relatively accurate system time. Clock skew can prevent downloads from working, and can cause unpredictable errors if the system time is adjusted by any considerable amount after installation.

Verificare data e ora eseguendo il comando date:

root #date
Lun 3 Ott 13:16:22 CET 2016

Se la data/ora mostrata è sbagliata, correggerla usando uno dei seguenti metodi.

Automatico

Using NTP to correct clock skew is typically easier and more reliable than manually setting the system clock.

chronyd, part of net-misc/chrony can be used to update the system clock to UTC with:

root #ntpd -q -g
Importante
Systems without a functioning Real-Time Clock (RTC) must sync the system clock at every system start, and on regular intervals thereafter. This is also beneficial for systems with a RTC, as the battery could fail, and clock skew can accumulate.
Attenzione
Standard NTP traffic not authenticated, it is important to verify time data obtained from the network.

Manuale

When NTP access is unavailable, date can be used to manually set the system clock.

L'orario UTC è raccomandato su tutti i sistemi Linux. Successivamente, durante l'installazione, verrà definito un fuso orario. Ciò modificherà il modo in cui viene mostrata l'ora in base all'ora locale.

Il comando date può essere usato anche per effettuare un'impostazione manuale dell'orologio di sistema. Usare la sintassi MMGGoommAAAA (Mese, Giorno, ora, minuti e anno).

Per esempio, per impostare la data sul 3 ottobre, 13:16 nell'anno 2016:

root #date 100313162016

Spostarsi sulla cartella dove è stato montato il filesystem radice di Gentoo (molto probabilmente /mnt/gentoo):

root #cd /mnt/gentoo

Browser grafici

Coloro che usano ambienti con browser di rete completamente grafici non avranno problemi a copiare l'URL del file stage dalla sezione di download del sito principale. Semplicemente selezionare la scheda appropriata, cliccare con il tasto destro del mouse sul collegamento al file stage, poi Copiare l'indirizzo (su Firefox) o Copiare la posizione (su Chromium) per copiare l'indirizzo negli appunti, incollare poi il collegamento all'utilità wget da linea di comando così da scaricare lo stage tarball:

root #wget <URL_STAGE_INCOLLATO>

Browser a linea di comando

I lettori più tradizionali o gli utenti Gentoo di 'vecchia data', lavorando esclusivamente da linea di comando, potrebbero preferire l'uso di links, un browser senza grafica e basato sui menu. Per scaricare uno stage, navigare fino alla lista di distributori (mirror) di Gentoo come di seguito:

root #links https://www.gentoo.org/downloads/mirrors/

Per usare un proxy HTTP con links, passare l'URL con l'opzione -http-proxy:

root #links -http-proxy proxy.server.com:8080 https://www.gentoo.org/downloads/mirrors/

Oltre a links esiste anche il browser lynx. Come links, si tratta di un browser privo di grafica ma non basato sui menu.

root #lynx https://www.gentoo.org/downloads/mirrors/

Se è necessario definire un proxy, esportare le variabili http_proxy e/o ftp_proxy:

root #export http_proxy="http://proxy.server.com:port"
root #export ftp_proxy="http://proxy.server.com:port"

Nella lista dei distributori (mirror), selezionarne uno vicino. Solitamente vanno bene i mirror HTTP, ma sono disponibili anche altri protocolli. Spostarsi nella cartella releases/amd64/autobuilds/. Qui sono elencati tutti i file stage disponibili (potrebbero essere posti in sottocartelle nominate con il nome delle singole sotto architetture). Selezionarne uno e premere d per scaricarlo.

Appena lo scaricamento del file stage è completato, è possibile verificare l'integrità e validare i contenuti dello stage tarball. Coloro che lo desiderano dovrebbero leggere la successiva sezione.

Coloro che non sono interessati alla verifica e alla validazione del file stage possono chiudere il browser a linea di comando premendo q e possono proseguire alla sezione di estrazione dello stage tarball.

Verifica e validazione

Nota
Most stages are now explicitly suffixed with the init system type (openrc or systemd), although some architectures may still be missing these for now.

Come con i CD di installazione minimali, anche ora sono disponibili file aggiuntivi per verificare e validare il file stage. Sebbene questi passi possano essere saltati, questi file sono forniti per gli utenti che tengono alla legittimità dei file da essi scaricati.

root #wget https://distfiles.gentoo.org/releases/
  • Un file .CONTENTS che contiene un elenco di tutti i file all'interno del tarball stage.
  • Un file .DIGESTS che contiene i checksum (somme di controllo) del file stage, in base a diversi algoritmi.
  • Un file .DIGESTS.asc che, come il file .DIGESTS, contiene i checksum del file stage secondo diversi algoritmi, ma è anche firmato crittograficamente per assicurarsi che sia fornito dal progetto Gentoo.

Usare openssl e confrontare il suo risultato con le somme di controllo fornite dal file .DIGESTS o .DIGESTS.asc.

Per esempio, per validare con il checksum SHA512:

root #openssl dgst -r -sha512 stage3-amd64-<release>.tar.bz2

dgst instructs the openssl command to use the Message Digest sub-command, -r prints the digest output in coreutils format, and -sha512 selects the SHA512 digest.

Per validare con il checksum Whirlpool:

root #openssl dgst -r -whirlpool stage3-amd64-<release>.tar.bz2

Confrontare il risultato di questi comandi con il valore registrato nei file .DIGESTS(.asc). I valori devono corrispondere, altrimenti il file scaricato potrebbe essere corrotto (oppure è corrotto il file digests).

Un altro modo è usare il comando sha512sum:

root #sha512sum stage3-amd64-<release>.tar.bz2

The --check option instructs sha256sum to read a list of expected files and associated hashes, and then print an associated "OK" for each file that calculates correctly or a "FAILED" for files that do not.

Così come per il file ISO, è possibile verificare anche la firma crittografica del file .DIGESTS.asc usando gpg per essere sicuri che le somme di controllo non siano state manomesse:

For official Gentoo live images, the sec-keys/openpgp-keys-gentoo-release package provides PGP signing keys for automated releases. The keys must first be imported into the user's session in order to be used for verification:

root #gpg --import /usr/share/openpgp-keys/gentoo-release.asc

For all non-official live images which offer gpg and wget in the live environment, a bundle containing Gentoo keys can be fetched and imported:

root #wget -O - https://qa-reports.gentoo.org/output/service-keys.gpg | gpg --import

Verify the signature of the tarball and, optionally, associated checksum files:

root #gpg --verify stage3-amd64-<release>.tar.bz2.DIGESTS.asc

If verification succeeds, "Good signature from" will be in the output of the previous command(s).

The fingerprints of the OpenPGP keys used for signing release media can be found on the release media signatures page.

Installare uno stage tarball

Ora scompattare lo stage scaricato nel sistema. Useremo tar per procedere:

root #tar xvjpf stage3-*.tar.bz2 --xattrs --numeric-owner

Assicurarsi di usare le stesse opzioni (xvjpf e --xattrs). La x sta per Estrai, la v sta per Verboso per vedere cosa succede durante il processo di estrazione (opzionale), la j sta per Decomprimi con bzip2, la p sta per Preserva i permessi e la f indica che si vuole estrarre un File, l'input non è standard. --xattrs serve per includere gli attributi estesi memorizzati nell'archivio. Infine, --numeric-owner viene usato per assicurarsi che gli ID di utenti e gruppi dei file estratti dal tarball rimangano uguali a quelli pensati dalla squadra ingegneristica dei rilasci di Gentoo, anche per gli utenti avventurosi che non stanno usando mezzi di installazione ufficiali di Gentoo.

  • x extract, instructs tar to extract the contents of the archive.
  • p preserve permissions.
  • v verbose output.
  • f file, provides tar with the name of the input archive.
  • --xattrs-include='*.*' Preserves extended attributes in all namespaces stored in the archive.
  • --numeric-owner Ensure that the user and group IDs of files being extracted from the tarball remain the same as Gentoo's release engineering team intended (even if adventurous users are not using official Gentoo live environments for the installation process).

Una volta che il file stage è stato installato, si continui con la Configurazione delle opzioni di compilazione.

Configurazione delle opzioni di compilazione

Introduzione

Per ottimizzare Gentoo, è possibile impostare un paio di variabili che influenzeranno il comportamento di Portage, il gestore di pacchetti di Gentoo ufficialmente supportato. Tutte quelle variabili possono essere impostate come variabili d'ambiente (usando export) però l'effetto non sarà permanente. Per conservare le impostazioni, Portage legge nel file /etc/portage/make.conf, un file di configurazione di Portage.

Nota
Technically variables can be exported via the shell's profile or rc files, however that is not best practice for basic system administration.

Portage reads in the make.conf file when it runs, which will change runtime behavior depending on the values saved in the file. make.conf can be considered the primary configuration file for Portage, so treat its content carefully.

Nota
Si può trovare un elenco commentato di tutte le variabili possibili nel file /mnt/gentoo/usr/share/portage/config/make.conf.example. Per completare un'installazione, è necessario impostare solo le variabili menzionate di seguito.

For a successful Gentoo installation only the variables that are mentioned below need to be set.}}

Si apra un editor (in questa guida useremo nano) per modificare le variabili di ottimizzazione che discuteremo in seguito.

root #nano -w /mnt/gentoo/etc/portage/make.conf

Dal file make.conf.example si comprende come questo debba essere strutturato: le linee commentate iniziano con "#", le altre linee definiscono le variabili usando la sintassi VARIABILE="contenuto". Molte di queste variabili sono discusse in seguito.

CFLAGS e CXXFLAGS

Le variabili CFLAGS e CXXFLAGS definiscono rispettivamente le opzioni di ottimizzazioni per i compilatori GCC C e C++. Benché siano definite in maniera generale qui, per ottenere le migliori prestazioni si dovrebbero ottimizzare quelle opzioni separatamente per ogni programma. Dato che ciascun programma è diverso. Tuttavia, ciò non è gestibile, per cui si utilizza la definizione di queste variabili (flag) nel file make.conf.

Nel file make.conf si dovrebbero definire le opzioni di ottimizzazione che renderanno il sistema indicativamente più performante possibile. Non si usino impostazioni sperimentali in questa variabile; troppe ottimizzazioni possono addirittura peggiorare il comportamento dei programmi (blocchi, o anche peggio, malfunzionamenti).

Non spiegheremo tutte le opzioni di ottimizzazione possibili. Per comprenderle tutte, si legga il Manuale GNU Online o la pagina di informazioni di gcc (info gcc - funziona solo su sistemi Linux in esecuzione). Il file make.conf.example stesso contiene tantissimi esempi ed informazioni; non si dimentichi di leggerlo.

Una prima impostazione è l'opzione -march= o -mtune=, che specifica il nome dell'architettura di destinazione. Nel file make.conf.example sono descritte le possibili opzioni (attraverso commenti). Un valore comunemente usato è native che indica al compilatore di usare come architettura di destinazione quella del sistema in uso (quella su cui gli utenti stanno installando Gentoo).

Un'altra opzione è -O (O maiuscola, non zero), che specifica la classe di ottimizzazione di gcc. Possibili classi sono s (per ottimizzare le dimensioni), 0 (zero - per non ottimizzare affatto), 1, 2 o persino 3 per ottimizzare la velocità (ogni classe ha le stesse opzioni della precedente, più alcune aggiuntive). -O2 è l'opzione predefinita raccomandata. È noto che -O3 causa problemi se usata per l'intero sistema, quindi raccomandiamo di attenersi a -O2.

Un'altra opzione di ottimizzazione popolare è -pipe (usa le pipe - passaggio dati - invece di file temporanei per la comunicazione durante i vari passi della compilazione). Non ha alcun impatto sul codice generato, ma usa più memoria. Su sistemi con poca memoria, gcc potrebbe essere interrotto. In tal caso, non si usi questa opzione.

Usare -fomit-frame-pointer (che non conserva il frame pointer nel registro per le funzioni che non se ne servono) potrebbe avere serie ripercussioni sul debug delle applicazioni.

Quando vengono definite le variabili CFLAGS e CXXFLAGS, si combinino le varie opzioni di ottimizzazione in un'unica stringa. I valori predefiniti contenuti nell'archivio stage3 scompattato dovrebbero essere abbastanza buoni. Quello di seguito è solo un esempio:

CODE Esempi delle variabili CFLAGS e CXXFLAGS
CFLAGS="-march=native -O2 -pipe"
# Usare le stesse impostazioni per ambo le variabili
CXXFLAGS="${CFLAGS}"
Suggerimento
Benché l'articolo relativo all'ottimizzazione GCC abbia più informazioni su come le varie opzioni di compilazione possano influenzare un sistema, l'articolo CFLAGS sicure dovrebbe essere un posto più pratico per i principianti per iniziare ad ottimizzare i loro sistemi.

MAKEOPTS

La variabile MAKEOPTS definisce quante compilazioni parallele dovrebbero avvenire quando si installa un pacchetto. Una buona scelta è il numero di CPU (o core di CPU) nel sistema più uno, ma questa linea guida non è sempre perfetta.

Further, as of Portage 3.0.53[1], if left undefined, Portage's default behavior is to set the MAKEOPTS load-average value to the same number of threads returned by nproc.

A good choice is the smaller of: the number of threads the CPU has, or the total amount of system RAM divided by 2 GiB.

Attenzione
Using a large number of jobs can significantly impact memory consumption. A good recommendation is to have at least 2 GiB of RAM for every job specified (so, e.g. -j6 requires at least 12 GiB). To avoid running out of memory, lower the number of jobs to fit the available memory.
Suggerimento
When using parallel emerges (--jobs), the effective number of jobs run can grow exponentially (up to make jobs multiplied by emerge jobs). This can be worked around by running a localhost-only distcc configuration that will limit the number of compiler instances per host.
CODE Esempio di dichiarazione di MAKEOPTS nel file make.conf
MAKEOPTS="-j2"

Search for MAKEOPTS in man 5 make.conf for more details.

Pronti, attenti, via!

Aggiornare il file /mnt/gentoo/etc/portage/make.conf in base alle preferenze personali e salvarlo (gli utenti di nano devono usare Ctrl+X).




Effettuare chroot

Copiare le informazioni del DNS

Rimane da fare ancora una cosa prima di entrare nel nuovo ambiente, ovvero copiare le informazioni del DNS nel file /etc/resolv.conf. Ciò va fatto per assicurarsi che la rete funzioni anche dopo essere entrati nel nuovo ambiente. /etc/resolv.conf contiene i name server per la rete.

Per copiare queste informazioni, si raccomanda di passare l'opzione --dereference al comando cp. Ciò garantisce che, se /etc/resolv.conf è un collegamento simbolico, venga copiato il file indicato dal collegamento invece del collegamento simbolico stesso. Altrimenti, nel nuovo ambiente, il collegamento simbolico punterebbe ad un file non esistente (in quanto ciò che ora indica il collegamento non sarà disponibile nel nuovo ambiente).

root #cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

Montaggio dei fileystem necessari

A breve, la radice (root) di Linux sarà cambiata con quella della nuova ubicazione. Per essere sicuri che il nuovo ambiente funzioni correttamente, alcuni filesystem devono essere disponibili fin d'ora.

I filesystem da rendere disponibili sono:

  • /proc/ che è uno pseudo filesystem (appare come fossero file ordinari, ma in realtà è generato in tempo reale) tramite il quale il kernel Linux mostra informazioni a tutto l'ambiente
  • /sys/ che è uno pseudo filesystem, come /proc/ che una volta si pensava l'avrebbe sostituito, ed è più strutturato di /proc/
  • /dev/ è un filesystem normale, parzialmente gestito dal gestore dei dispositivi di Linux (solitamente udev), il quale contiene un file per ciascun dispositivo
  • /run/ è un filesystem temporaneo utilizzato per i file generati in fase di esecuzione, come i file PID o il locks

Il percorso /proc/ sarà montato su /mnt/gentoo/proc/ mentre gli altri saranno montati congiuntamente. Ciò significa che, ad esempio, /mnt/gentoo/sys/ sarà effettivamente /sys/ (è solo un secondo punto di accesso allo stesso filesystem) mentre /mnt/gentoo/proc/ è un nuovo montaggio (un'istanza per così dire) del filesystem.

Suggerimento
If using Gentoo's install media, this step can be replaced with simply: arch-chroot /mnt/gentoo.
root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
root #mount --bind /run /mnt/gentoo/run
root #mount --make-slave /mnt/gentoo/run
Nota
Le operazioni --make-rslave sono necessarie per il supporto di systemd più avanti nell'installazione.
Attenzione
Quando si usano mezzi di installazione non-Gentoo, quanto detto potrebbe risultare insufficiente. Alcune distribuzioni creano un link simbolico di /dev/shm su /run/shm/ che, dopo chroot, risulta non valido. Facendo un corretto montaggio tmpfs di /dev/shm/ può risolvere questo problema:
root #test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
root #mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm

Ci si assicuri anche che la modalità 1777 sia impostata:

root # chmod 1777 /dev/shm /run/shm

Entrare nel nuovo ambiente

Ora che tutte le partizioni sono state inizializzate e l'ambiente base installato, è tempo di entrare nel nuovo ambiente attraverso chroot. Ciò significa che la sessione cambierà la sua radice (la posizione di livello più alto alla quale si può fare accesso) da quella dell'attuale ambiente di installazione (del CD o di un altro mezzo di installazione) a quella del sistema installato (ovvero le partizioni inizializzate). Da cui il nome, change root (cambiare radice) o chroot.

Questo cambio di radice può esser fatto in tre passaggi:

  1. La posizione radice (root) è modificata da / (sul mezzo di installazione) a /mnt/gentoo/ sulle partizioni usando chroot
  2. Alcune impostazioni (quelle su /etc/profile) sono caricate nella memoria usando il comando source
  3. L'attesa comandi (prompt) primaria è modificata per ricordarci che questa sessione avviene in un ambiente chroot
root #chroot /mnt/gentoo /bin/bash
root #source /etc/profile
root #export PS1="(chroot) ${PS1}"

Da questo momento, tutte le azioni sono direttamente eseguite nel nuovo ambiente Gentoo Linux. Certamente si è ancora lontani dalla conclusione, per questo motivo l'installazione ha ancora alcune sezioni!

Suggerimento
Se l'installazione di Gentoo viene interrotta in qualsiasi momento da questo punto, dovrebbe essere possibile riprenderla a partire da questo passaggio. Non c'è necessità di ripartizionare il disco nuovamente! Montare la partizione radice ed eseguire i passi qui sopra iniziando con la copia delle informazioni DNS per rientrare nell'ambiente funzionante. Questo è utile anche per correggere alcuni problemi con i bootloader (selettori di avvio). Ulteriori informazioni si possono trovare nell'articolo chroot.

Preparing for a bootloader

Now that the new environment has been entered, it is necessary to prepare the new environment for the bootloader. It will be important to have the correct partition mounted when it is time to install the bootloader.

UEFI systems

For UEFI systems, /dev/sda1 was formatted with the FAT32 filesystem and will be used as the EFI System Partition (ESP). Create a new /efi directory (if not yet created), and then mount ESP there:

root #mkdir /efi # May have been created in a previous step
root #mount /dev/sda1 /efi

DOS/Legacy BIOS systems

For DOS/Legacy BIOS systems, the bootloader will be installed into the /boot directory, therefore mount as follows:

root #mount /dev/sda1 /boot

Configurare Portage

Repositorio ebuild di Gentoo

Un altro importante passo durante la selezione dei mirror è la configurazione dei repositori delle ebuild di Gentoo tramite il file /etc/portage/repos.conf/gentoo.conf. Questo file contiene le informazioni di sincronizzazione necessarie per aggiornare il repositorio dei pacchetti (la raccolta di ebuild e di file correlati contenenti tutte le informazioni di cui Portage ha bisogno per scaricare ed installare i pacchetti software).

La configurazione del repositorio può essere fatta in pochi semplici passi. Prima, se non esiste, creare il percorso repos.conf:

root #mkdir --parents /mnt/gentoo/etc/portage/repos.conf

Successivamente, copiare il file di configurazione dei repositori di Gentoo, fornito da Portage, nella cartella (appena creata) repos.conf:

root #cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

Si dia un'occhiata con un editor di testo o utilizzando il comando cat. Il contenuto del file dovrebbe essere in formato .ini e somigliare a questo:

FILE /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
[DEFAULT]
main-repo = gentoo
 
[gentoo]
location = /var/db/repos/gentoo
sync-type = rsync
sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4

Il valore predefinito della variabile sync-uri sopra elencato comporta un posizionamento dei mirror basato sulla rotazione. Ciò ottimizzerà il carico sulla banda dell'infrastruttura di Gentoo e fornirà una soluzione di ripiego in caso uno specifico mirror risulti non in linea. Si raccomanda di mantenere l'URI predefinito a meno che non venga usato un mirror di Portage locale e privato.

Suggerimento
Per coloro che sono interessati, le specifiche ufficiali per le API di sincronizzazione del plug-in di Portage possono essere consultate nell' Articolo sulla sincronizzazione del progetto Portage.

Installare un'istantanea del repository ebuild Gentoo dal web

Il prossimo passo consiste nell'installare un'istantanea del repository ebuild di Gentoo. Questa istantanea contiene una collezione di file che informano Portage riguardo i titoli di software disponibili (per l'installazione), quali profili può selezionare l'amministratore del sistema, elementi notizia specifici su pacchetti o profili, ecc.

L'uso di emerge-webrsync è raccomandato per chi si trova dietro un firewall restrittivo (usa i protocolli HTTP/FTP per scaricare l'istantanea) e vuole risparmiare la banda. I lettori che non hanno restrizioni di rete o di banda possono felicemente saltare fino alla fine di questa sezione.

Questo preleverà l'ultima istantanea (la quale è rilasciata giorno per giorno) da uno dei distributori (mirror) di Gentoo e la installerà nel sistema:

root #emerge-webrsync
Nota
Durante questa operazione, emerge-webrsync potrebbe lamentarsi riguardo una posizione /var/db/repos/gentoo mancante. Questo deve essere atteso e non destare preoccupazioni - lo strumento creerà la posizione.

Da questo momento in avanti, Portage potrebbe menzionare che certi aggiornamenti è raccomandato eseguirli. Ciò avviene perché i pacchetti di sistema installati attraverso il file stage potrebbero avere disponibili delle versioni più recenti; Portage è ora a conoscenza dei nuovi pacchetti grazie all'istantanea del repositorio. Gli aggiornamenti dei pacchetti possono essere ignorati in sicurezza per ora; gli aggiornamenti possono essere posticipati dopo la conclusione dell'installazione di Gentoo.


Opzionale: Selezionare i mirror

Per scaricare rapidamente il codice sorgente si raccomanda di selezionare un mirror (distributore) veloce. Portage cercherà la variabile GENTOO_MIRRORS nel file make.conf ed utilizzerà i mirror lì elencati. È possibile navigare nella lista dei mirror di Gentoo e cercare un mirror (o più mirror) vicino alla posizione geografica del sistema (in quanto quelli risulteranno solitamente più veloci). Tuttavia, forniamo anche uno strumento utile chiamato mirrorselect che fornisce agli utenti una comoda interfaccia per selezionare i mirror necessari. Basta semplicemente navigare sui mirror prescelti e premere Spazio per selezionare uno o più mirror.

A tool called mirrorselect provides a pretty text interface to more quickly query and select suitable mirrors. Just navigate to the mirrors of choice and press Spacebar to select one or more mirrors.

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

Alternatively, a list of active mirrors are available online.

Opzionale: Aggiornare il repositorio ebuild di Gentoo

È possibile aggiornare il repositorio ebuild di Gentoo all'ultima versione. Il precedente comando emerge-webrsync avrà installato un'istantanea decisamente recente (solitamente delle ultime 24 ore) dunque questo passo è decisamente facoltativo.

Supponiamo siano necessari gli aggiornamenti degli ultimissimi pacchetti (fino ad 1 ora), dunque si usi emerge --sync. Questo comando userà il protocollo rsync per aggiornare al repositorio ebuild di Gentoo (il quale è stato prelevato prima attraverso emerge-webrsync) al più recente stato.

root #emerge --sync

Sui terminali lenti, come alcuni framebuffer o console seriali, è raccomandato usare l'opzione --quiet per velocizzare il processo:

root #emerge --sync --quiet

Leggere gli elementi notizia

Quando il repositorio ebuild di Gentoo viene sincronizzato, Portage potrebbe scrivere messaggi informativi simili a questo:

* IMPORTANT: 2 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.

Gli elementi notizia sono stati creati per fornire un mezzo di comunicazione affinché i messaggi critici siano notificati agli utenti attraverso il repository ebuild Gentoo. Per gestirli, usare eselect news. L'applicazione eselect è un'utilità di Gentoo che fornisce un'interfaccia di gestione comune per l'amministrazione di sistema. In questo caso, eselect è richiesto per usare il modulo news.

Per il modulo news, tre operazioni sono le più comuni:

  • Con list viene mostrata una panoramica degli elementi notizia disponibili.
  • Con read possono essere letti gli elementi notizia.
  • Con purge possono essere rimossi gli elementi notizia una volta che siano stati letti e non si potranno più rileggere.
root #eselect news list
root #eselect news read

Ulteriori informazioni sul lettore delle notizie sono presenti sulla sua pagina manuale:

root #man news.eselect

Scegliere il profilo corretto

Suggerimento
Desktop profiles are not exclusively for desktop environments. They are also suitable for minimal window managers like i3 or sway.

Un profilo è un elemento costitutivo per un qualsiasi sistema Gentoo. Non solo specifica valori predefiniti per USE, CFLAGS, ed altre importanti variabili, ma blocca il sistema su un certo intervallo di versione di pacchetti. Queste impostazioni sono tutte mantenute dagli sviluppatori Portage di Gentoo.

Per vedere quale profilo sta attualmente usando il sistema, esegui eselect usando il modulo profile:

root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/23.0 *
  [2]   default/linux/amd64/23.0/desktop
  [3]   default/linux/amd64/23.0/desktop/gnome
  [4]   default/linux/amd64/23.0/desktop/kde
Nota
La risposta del comando è giusto un esempio e cambia con il tempo.
Nota
Quando si usa systemd, assicurarsi che il nome del profilo contenga systemd. Altrimenti, assicurati che il nome del profilo non contenga systemd.

Come si può vedere, ci sono anche sotto profili per i desktop disponibili per alcune architetture.

Attenzione
Gli aggiornamenti del profilo non devono essere presi alla leggera. Quando si seleziona il profilo iniziale, assicurarsi di utilizzare il profilo corrispondente a la stessa versione come quello inizialmente utilizzato da stage3 (es. 23.0). Ogni nuova versione del profilo viene annunciata attraverso una news contenente le istruzioni di migrazione. Assicurati di leggerlo e seguirlo prima di passare a un nuovo profilo.

Dopo aver visto i profili disponibili per l'architettura amd64, gli utenti possono selezionare un profilo diverso per il sistema:

root #eselect profile set 2


No-multilib

Per avere un ambiente 64-bit puro, senza alcuna applicazione 32-bit, usare un profilo no-multilib:

root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0 *
  [2]   default/linux/amd64/13.0/desktop
  [3]   default/linux/amd64/13.0/desktop/gnome
  [4]   default/linux/amd64/13.0/desktop/kde
  [5]   default/linux/amd64/13.0/no-multilib

Selezionare il profilo no-multilib:

root #eselect profile set 5
root #eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0
  [2]   default/linux/amd64/13.0/desktop
  [3]   default/linux/amd64/13.0/desktop/gnome
  [4]   default/linux/amd64/13.0/desktop/kde
  [5]   default/linux/amd64/13.0/no-multilib *



Nota
Il sotto profilo developer è dedicato ad uno sviluppatore Gentoo Linux e non va considerato come una scelta per l'utente qualsiasi.

Optional: Adding a binary package host

Since December 2023, Gentoo's Release Engineering team has offered an official binary package host (colloquially shorted to just "binhost") for use by the general community to retrieve and install binary packages (binpkgs).[1]

Adding a binary package host allows Portage to install cryptographically signed, compiled packages. In many cases, adding a binary package host will greatly decrease the mean time to package installation and adds much benefit when running Gentoo on older, slower, or low power systems.

Repository configuration

The repository configuration for a binhost is found in Portage's /etc/portage/binrepos.conf/ directory, which functions similarly to the configuration mentioned in the Gentoo ebuild repository section.

When defining a binary host, there are two important aspects to consider:

  1. The architecture and profile targets within the sync-uri value do matter and should align to the respective computer architecture (amd64 in this case) and system profile selected in the Choosing the right profile section.
  2. Selecting a fast, geographically close mirror will generally shorten retrieval time. Review the mirrorselect tool mentioned in the Optional: Selecting mirrors section or review the online list of mirrors where URL values can be discovered.

FILE /etc/portage/binrepos.conf/gentoobinhost.confCDN-based binary package host example
[binhost]
priority = 9999
sync-uri = https://distfiles.gentoo.org/releases/<arch>/binpackages/<profile>/x86-64/

Installing binary packages

Portage will compile packages from code source by default. It can be instructed to use binary packages in the following ways:

  1. The --getbinpkg option can be passed when invoking the emerge command. This method of for binary package installation is useful to install only a particular binary package.
  2. Changing the system's default via Portage's FEATURES variable, which is exposed through the /etc/portage/make.conf file. Applying this configuration change will cause Portage to query the binary package host for the package(s) to be requested and fall back to compiling locally when no results are found.

For example, to have Portage always install available binary packages:

FILE /etc/portage/make.confConfigure Portage to use binary packages by default
# Appending getbinpkg to the list of values within the FEATURES variable
FEATURES="${FEATURES} getbinpkg"
# Require signatures
FEATURES="${FEATURES} binpkg-request-signature"

Please also run getuto for Portage to set up the necessary keyring for verification:

root #getuto

Additional Portage features will be discussed in the the next chapter of the handbook.

Configurare la variabile USE

La variabile USE è una delle più potenti che Gentoo offre ai suoi utenti. Numerosi programmi possono essere compilati con o senza il supporto facoltativo di certi elementi. Per esempio, alcuni programmi possono essere compilati con il supporto a GTK+ o con il supporto a Qt. Altri possono essere compilati con o senza il supporto SSL. Alcuni programmi possono essere persino compilati con il supporto al framebuffer (svgalib) anziché il supporto a X11 (X-server).

La maggior parte delle distribuzioni compila i pacchetti con il supporto per più cose possibili, aumentando la dimensione dei programmi ed i tempi di avvio, per non menzionare l'enorme quantità di dipendenze. Con Gentoo gli utenti possono definire con quali opzioni un pacchetto dovrebbe essere compilato. Qui entra in gioco USE.

Nella variabile USE gli utenti definiscono le parole chiave che saranno mappate come opzioni di compilazione. Per esempio, ssl compilerà con il supporto SSL nei programmi che lo supportano. -X rimuoverà il supporto al server X (notare il meno di fronte al simbolo). gnome gtk -kde -qt5 compilerà i programmi con il supporto GNOME (e GTK+) e non con il supporto KDE (e Qt), rendendo il sistema interamente modificato per GNOME (se l'architettura lo supporta).

Le impostazioni predefinite per USE si trovano nei file make.defaults del profilo Gentoo usato per il sistema. Gentoo usa un (complesso) sistema di eredità per i suoi profili, nel quale non scaveremo a fondo in questo stadio. Il modo più facile per controllare le attuali impostazioni attive per USE è eseguire emerge --info e selezionare la linea che inizia con USE:

root #emerge --info | grep ^USE
USE="X acl alsa amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri ..."
Nota
L'esempio soprastante è stato troncato, l'elenco effettivo dei valori di USE è molto, molto più grande.

Una descrizione completa sulle opzioni disponibili per USE può essere trovata nel sistema su /var/db/repos/gentoo/profiles/use.desc.

root #less /var/db/repos/gentoo/profiles/use.desc

Dentro il comando less, si può scorrere il testo usando i tasti e , ed uscire premendo q.

Come esempio mostriamo un'impostazione di USE per un sistema basato su KDE con supporto DVD, ALSA e scrittura CD:

root #nano -w /etc/portage/make.conf
FILE /etc/portage/make.confAbilitare i flag per un sistema basato su KDE/Plasma con supporto per la registrazione di DVD, ALSA e CD
USE="-gtk -gnome qt5 kde dvd alsa cdr"

Quando USE viene definita in /etc/portage/make.conf essa aggiunge (o rimuove se l'opzione USE inizia con il segno -) opzioni dall'elenco predefinito. Gli utenti che vogliono ignorare qualsiasi impostazione predefinita di USE e gestirla completamente da soli devono far cominciare la definizione di USE in make.conf con -*:

FILE /etc/portage/make.confIgnorando le opzioni predefinite di USE
USE="-X acl alsa"
Attenzione
Sebbene sia possibile, l'opzione -* (vista nell'esempio precedente) è sconsigliata poiché le impostazioni predefinite accuratamente scelte per USE possono essere configurate in alcuni ebuild per prevenire conflitti ed altri errori.

CPU_FLAGS_*

Some architectures (including AMD64/X86, ARM, PPC) have a USE_EXPAND variable called CPU_FLAGS_<ARCH>, where <ARCH> is replaced with the relevant system architecture name.

Importante
Do not be confused! AMD64 and X86 systems share some common architecture, so the proper variable name for AMD64 systems is CPU_FLAGS_X86.

This is used to configure the build to compile in specific assembly code or other intrinsics, usually hand-written or otherwise extra, and is not the same as asking the compiler to output optimized code for a certain CPU feature (e.g. -march=).

Users should set this variable in addition to configuring their COMMON_FLAGS as desired.

A few steps are needed to set this up:

root #emerge --ask --oneshot app-portage/cpuid2cpuflags

Inspect the output manually if curious:

root #cpuid2cpuflags

Then copy the output into package.use:

root #echo "*/* $(cpuid2cpuflags)" > /etc/portage/package.use/00cpu-flags

VIDEO_CARDS

The VIDEO_CARDS USE_EXPAND variable should be configured appropriately depending on the available GPU(s). Setting VIDEO_CARDS is not required for a console only install.

Below is an example of a properly set VIDEO_CARDS variable. Substitute the name of the driver(s) to be used.

FILE /etc/portage/make.conf
VIDEO_CARDS="amdgpu radeonsi"

Details for various GPU(s) can be found at the AMDGPU, Intel, Nouveau (Open Source), or NVIDIA (Proprietary) articles.

Opzionale: Configurare la variabile ACCEPT_LICENSE

Starting with Gentoo Linux Enhancement Proposal 23 (GLEP 23), a mechanism was created to allow system administrators the ability to "regulate the software they install with regards to licenses... Some want a system free of any software that is not OSI-approved; others are simply curious as to what licenses they are implicitly accepting."[2] With a motivation to have more granular control over the type of software running on a Gentoo system, the ACCEPT_LICENSE variable was born.

Gentoo viene fornito con un valore predefinito nei profili, ad esempio:

user $portageq envvar ACCEPT_LICENSE
@FREE

For the convenience of system administration, legally-similar software licenses have been bundled together - each according to its like-kind. License group definitions are available for viewing and are managed by the Gentoo Licenses project. While an individual license is not, license groups are syntactically preceded with an @ symbol, enabling them to be easily distinguished in the ACCEPT_LICENSE variable.

Some common license groups include:

A list of software licenses grouped according to their kinds.
Name Description
@GPL-COMPATIBLE GPL compatible licenses approved by the Free Software Foundation [a_license 1]
@FSF-APPROVED Free software licenses approved by the FSF (includes @GPL-COMPATIBLE)
@OSI-APPROVED Licenses approved by the Open Source Initiative [a_license 2]
@MISC-FREE Misc licenses that are probably free software, i.e. follow the Free Software Definition [a_license 3] but are not approved by either FSF or OSI
@FREE-SOFTWARE Combines @FSF-APPROVED, @OSI-APPROVED, and @MISC-FREE.
@FSF-APPROVED-OTHER FSF-approved licenses for "free documentation" and "works of practical use besides software and documentation" (including fonts)
@MISC-FREE-DOCS Misc licenses for free documents and other works (including fonts) that follow the free definition [a_license 4] but are NOT listed in @FSF-APPROVED-OTHER.
@FREE-DOCUMENTS Combines @FSF-APPROVED-OTHER and @MISC-FREE-DOCS.
@FREE Metaset of all licenses with the freedom to use, share, modify and share modifications. Combines @FREE-SOFTWARE and @FREE-DOCUMENTS.
@BINARY-REDISTRIBUTABLE Licenses that at least permit free redistribution of the software in binary form. Includes @FREE.
@EULA License agreements that try to take away your rights. These are more restrictive than "all-rights-reserved" or require explicit approval

Currently set system wide acceptable license values can be viewed via:

user $portageq envvar ACCEPT_LICENSE
@FREE

As visible in the output, the default value is to only allow software which has been grouped into the @FREE category to be installed.

Specific licenses or licenses groups for a system can be defined in the following locations:

  • System wide within the selected profile - this sets the default value.
  • System wide within the /etc/portage/make.conf file. System administrators override the profile's default value within this file.
  • Per-package within a /etc/portage/package.license file.
  • Per-package within a /etc/portage/package.license/ directory of files.

The system wide license default in the profile is overridden within the /etc/portage/make.conf:

FILE /etc/portage/make.confAccept licenses with ACCEPT_LICENSE system wide
# Overrides the profile's ACCEPT_LICENSE default value
ACCEPT_LICENSE="-* @FREE @BINARY-REDISTRIBUTABLE"

Optionally system administrators can also define accepted licenses per-package as shown in the following directory of files example. Note that the package.license directory will need created if it does not already exist:

root #mkdir /etc/portage/package.license

Software license details for an individual Gentoo package are stored within the LICENSE variable of the associated ebuild. One package may have one or many software licenses, therefore it be necessary to specify multiple acceptable licenses for a single package.

FILE /etc/portage/package.license/kernelAccepting licenses on a per-package basis
app-arch/unrar unRAR
sys-kernel/linux-firmware @BINARY-REDISTRIBUTABLE
sys-firmware/intel-microcode intel-ucode
Importante
The LICENSE variable in an ebuild is only a guideline for Gentoo developers and users. It is not a legal statement, and there is no guarantee that it will reflect reality. It is recommended to not solely rely on a ebuild developer's interpretation of a software package's license; but check the package itself in depth, including all files that have been installed to the system.

Aggiornare il @world set

Il seguente passo è necessario per fa sì che il sistema possa applicare aggiornamenti o cambiamenti alle flag USE apparsi dopo la costruzione dello stage3 e da qualsiasi selezione di profilo:

  1. A profile target different from the stage file has been selected.
  2. Additional USE flags have been set for installed packages.

Readers who are performing an 'install Gentoo speed run' may safely skip @world set updates until after their system has rebooted into the new Gentoo environment.

Readers who are performing a slow run can have Portage perform updates for package, profile, and/or USE flag changes at the present time:

root #emerge --ask --verbose --update --deep --newuse @world

Removing obsolete packages

It is important to always depclean after system upgrades to remove obsolete packages. Review the output carefully with emerge --depclean --pretend to see if any of the to-be-cleaned packages should be kept if personally using them. To keep a package which would otherwise be depcleaned, use emerge --noreplace foo.

root #emerge --ask --pretend --depclean

If happy, then proceed with a real depclean:

root #emerge --ask --depclean
Suggerimento
Se è stato selezionato un profilo con un ambiente desktop completo, il processo potrebbe aumentare notevolmente la quantità di tempo necessaria per il processo di installazione. Coloro che hanno un tempo ristretto possono lavorare seguendo questa 'regola pratica': più corto è il nome del profilo, meno specifico sarà il @world set del sistema; meno specifico sarà il @world set del sistema, meno pacchetti saranno richiesti dal sistema. In altre parole:
  • Selezionare default/linux/amd64/23.0 comporterà l'aggiornamento di veramente pochi pacchetti, mentre
  • Selezionare default/linux/amd64/23.0/desktop/gnome/systemd richiederà molti pacchetti da installare, dato che il sistema di init sta cambiando da OpenRC a systemd, e le librerie dell'ambiente desktop GNOME saranno installate.


Ora locale

Nota
This step does not apply to users of the musl libc. Users who do not know what that means should perform this step.

Si evitino le ore locali /usr/share/zoneinfo/Etc/GMT* poiché i loro nomi non indicano le aree attese. Per esempio, GMT-8 è di fatto GMT+8.

Scegliere l'ora locale per il sistema. Cercare le ore locali disponibili su /usr/share/zoneinfo/:

root #ls /usr/share/zoneinfo
root #ls -l /usr/share/zoneinfo/Europe/
total 256
-rw-r--r-- 1 root root 2933 Dec  3 17:19 Amsterdam
-rw-r--r-- 1 root root 1742 Dec  3 17:19 Andorra
-rw-r--r-- 1 root root 1151 Dec  3 17:19 Astrakhan
-rw-r--r-- 1 root root 2262 Dec  3 17:19 Athens
-rw-r--r-- 1 root root 3664 Dec  3 17:19 Belfast
-rw-r--r-- 1 root root 1920 Dec  3 17:19 Belgrade
-rw-r--r-- 1 root root 2298 Dec  3 17:19 Berlin
-rw-r--r-- 1 root root 2301 Dec  3 17:19 Bratislava
-rw-r--r-- 1 root root 2933 Dec  3 17:19 Brussels
...

Supponiamo che la timezone scelta sia Europe/Brussels.

OpenRC

Scriviamo il nome della timezone nel file /etc/timezone.

root #echo "Europe/Brussels" > /etc/timezone

Poi, riconfigurare il pacchetto sys-libs/timezone-data, il quale aggiornerà il file /etc/localtime per noi, basato sugli inserimenti di /etc/timezone. Il file /etc/localtime è usato dalla libreria C del sistema per conoscere in quale ora locale il sistema si trova.

root #emerge --config sys-libs/timezone-data
Nota
The /etc/localtime file is used by the system C library to know the timezone the system is in.

systemd

Quando si usa systemd si utilizza un approccio leggermente diverso. Viene generato un collegamento simbolico:

root #ln -sf ../usr/share/zoneinfo/Europe/Brussels /etc/localtime

Successivamente, quando systemd è in esecuzione, il fuso orario e le relative impostazioni possono essere configurate con il comando timedatectl.

Configurare le lingue

Nota
Questo passaggio non si applica agli utenti di musl libc. Gli utenti che non sanno cosa significa dovrebbero eseguire questo passaggio.

Generazione locale

La maggior parte degli utenti usa solo una o due lingue nel proprio sistema.

Le lingue non specificano solamente la lingua che l'utente userà per interagire con il proprio sistema, ma anche le regole per ordinare le stringhe, mostrare le date e gli orari, ecc. i locale sono case sensitive e devono essere rappresentati esattamente come descritti. Un lista completa di tutti i locale disponibili può essere trovata nel file /usr/share/i18n/SUPPORTED.

Le localizzazioni di sistema supportate devono essere definite nel file /etc/locale.gen.

root #nano -w /etc/locale.gen

Le lingue seguenti sono un esempio per avere sia l'inglese (Stati Uniti) sia il tedesco (Germania/Deutchland) con i formati di carattere corrispondenti (per esempio UTF-8).

FILE /etc/locale.genAbilitare le lingue US e DE con i formati dei caratteri appropriati
en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE.UTF-8 UTF-8
Attenzione
Raccomandiamo fortemente di aggiungere almeno una lingua UTF-8 poiché molte applicazioni possono richiederla per compilare correttamente.

Il passo successivo è eseguire il comando locale-gen. Questo comando genererà tutti i valori locali specificati nel file /etc/locale.gen.

root #locale-gen

Per verificare che i valori locali selezionati sono ora disponibili, eseguire locale -a.

On systemd installs, localectl can be used, e.g. localectl set-locale ... or localectl list-locales.

Selezione dei locale

Fatto ciò, si passa ad impostare le opzioni locali per tutto il sistema. Nuovamente si userà eselect, questa volta con il modulo locale.

Con eselect locale list vengono mostrate le opzioni disponibili:

root #eselect locale list
Available targets for the LANG variable:
  [1]  C
  [2]  C.utf8
  [3]  en_US
  [4]  en_US.iso88591
  [5]  en_US.utf8
  [6]  de_DE
  [7]  de_DE.iso88591
  [8]  de_DE.iso885915
  [9]  de_DE.utf8
  [10] POSIX
  [ ]  (free form)

Con eselect locale set <NUMBER>si può selezionare il locale corretto:

root #eselect locale set 9

Manualmente, ciò può essere fatto intervenendo sul file /etc/env.d/02locale e per Systemd il file /etc/locale.conf:

FILE /etc/env.d/02localeImpostare manualmente le definizioni dei valori locali del sistema
LANG="de_DE.UTF-8"
LC_COLLATE="C.UTF-8"

L'impostazione della localizzazione eviterà avvisi ed errori durante le compilazioni del kernel e del software più avanti nell'installazione.

Ora ricaricare l'ambiente:

root #env-update && source /etc/profile && export PS1="(chroot) ${PS1}"

Una completa Guida di localizazzione per fornire una guida aggiuntiva attraverso il processo di selezione locale. Un altro interessante articolo è la guida UTF-8 per informazioni molto specifiche su come abilitare UTF-8 nel sistema.




Opzionale: Installare il firmware

Firmware

Linux Firmware

Alcuni driver richiedono firmware addizionali da installare nel sistema affinché funzioni. Questo caso riguarda spesso le interfacce di rete, specialmente le interfacce di rete wireless. La maggior parte dei firmware si trovano su sys-kernel/linux-firmware:

It is recommended to have the sys-kernel/linux-firmware package installed before the initial system reboot in order to have the firmware available in the event that it is necessary:

root #emerge --ask sys-kernel/linux-firmware
Nota
Installing certain firmware packages often requires accepting the associated firmware licenses. If necessary, visit the license handling section of the Handbook for help on accepting licenses.

It is important to note that kernel symbols that are built as modules (M) will load their associated firmware files from the filesystem when they are loaded by the kernel. It is not necessary to include the device's firmware files into the kernel's binary image for symbols loaded as modules.

SOF Firmware

Sound Open Firmware (SOF) is a new open source audio driver meant to replace the proprietary Smart Sound Technology (SST) audio driver from Intel. 10th gen+ and Apollo Lake (Atom E3900, Celeron N3350, and Pentium N4200) Intel CPUs require this firmware for certain features and certain AMD APUs also have support for this firmware. SOF's supported platforms matrix can be found here for more information.

root #emerge --ask sys-firmware/sof-firmware

Microcode

In addition to discrete graphics hardware and network interfaces, CPUs also can require firmware updates. Typically this kind of firmware is referred to as microcode. Newer revisions of microcode are sometimes necessary to patch instability, security concerns, or other miscellaneous bugs in CPU hardware.

Microcode updates for AMD CPUs are distributed within the aforementioned sys-kernel/linux-firmware package. Microcode for Intel CPUs can be found within the sys-firmware/intel-microcode package, which will need to be installed separately. See the Microcode article for more information on how to apply microcode updates.

Kernel configuration and compilation

Adesso è ora di configurare e compilare i sorgenti del kernel. Ci sono due approcci per farlo:

Ranked from least involved to most involved:

  1. Il kernel sarà configurato e compilato manualmente.
  2. Un programma di nome genkernel sarà usato per compilare ed installare il kernel automaticamente.

Il nucleo su cui tutte le distribuzioni si basano è il kernel Linux, che fa da intermediario tra i programmi dell'utente ed il sistema fisico (hardware). Gentoo offre ai suoi utenti numerosi possibili sorgenti per il kernel. Una lista completa con descrizioni è disponibile alla pagina panoramica sui kernel.

Suggerimento
Kernel installation tasks such as, copying the kernel image to /boot or the EFI System Partition, generating an initramfs and/or Unified Kernel Image, updating bootloader configuration, can be automated with installkernel. Users may wish to configure and install sys-kernel/installkernel before proceeding. See the Kernel installation section below for more more information.

Distribution kernels

Distribution Kernels are ebuilds that cover the complete process of unpacking, configuring, compiling, and installing the kernel. The primary advantage of this method is that the kernels are updated to new versions by the package manager as part of @world upgrade. This requires no more involvement than running an emerge command. Distribution kernels default to a configuration supporting the majority of hardware, however two mechanisms are offered for customization: savedconfig and config snippets. See the project page for more details on configuration.

Installing a distribution kernel

Before installing the kernel package the dracut USE flag needs to be added for the package sys-kernel/installkernel in /etc/portage/package.use:

FILE /etc/portage/package.use/installkernelEnable dracut support
sys-kernel/installkernel dracut

Users may also wish to enable additional sys-kernel/installkernel USE flags at this stage. See the Installation/Kernel#Installkernel section for details.

To build a kernel with Gentoo patches from source, type:

root #emerge --ask sys-kernel/gentoo-kernel

System administrators who want to avoid compiling the kernel sources locally can instead use precompiled kernel images:

root #emerge --ask sys-kernel/gentoo-kernel-bin
Optional: Signed kernel modules

The kernel modules in the prebuilt distribution kernel (sys-kernel/gentoo-kernel-bin) are already signed. To sign the modules of kernels built from source enable the modules-sign USE flag, and optionally specify which key to use for signing in /etc/portage/make.conf:

FILE /etc/portage/make.confEnable module signing
USE="modules-sign"

# Optionally, to use custom signing keys.
MODULES_SIGN_KEY="/path/to/kernel_key.pem"
MODULES_SIGN_CERT="/path/to/kernel_key.pem" # Only required if the MODULES_SIGN_KEY does not also contain the certificate.
MODULES_SIGN_HASH="sha512" # Defaults to sha512.

If MODULES_SIGN_KEY is not specified the kernel build system will generate a key, it will be stored in /usr/src/linux-x.y.z/certs. It is recommended to manually generate a key to ensure that it will be the same for each kernel release. A key may be generated with:

root #openssl req -new -nodes -utf8 -sha256 -x509 -outform PEM -out kernel_key.pem -keyout kernel_key.pem
Nota
The MODULES_SIGN_KEY and MODULES_SIGN_CERT may be different files. For this example the pem file generated by OpenSSL includes both the key and the accompanying certificate, and thus both variables are set to the same value.

OpenSSL will ask some questions about the user generating the key, it is recommended to fill in these questions as detailed as possible.

Store the key in a safe location, at the very least the key should be readable only by the root user. Verify this with:

root #ls -l kernel_key.pem
 -r-------- 1 root root 3164 Jan  4 10:38 kernel_key.pem 

If this outputs anything other then the above, correct the permissions with:

root #chown root:root kernel_key.pem
root #chmod 400 kernel_key.pem
Optional: Signing the kernel image (Secure Boot)

The kernel image in the prebuilt distribution kernel (sys-kernel/gentoo-kernel-bin) is already signed for use with Secure Boot. To sign the kernel image of kernels built from source enable the secureboot USE flag, and optionally specify which key to use for signing in /etc/portage/make.conf. Note that signing the kernel image for use with secureboot requires that the kernel modules are also signed, the same key may be used to sign both the kernel image and the kernel modules:

FILE /etc/portage/make.confEnable custom signing keys
USE="modules-sign secureboot"

# Optionally, to use custom signing keys.
MODULES_SIGN_KEY="/path/to/kernel_key.pem"
MODULES_SIGN_CERT="/path/to/kernel_key.pem" # Only required if the MODULES_SIGN_KEY does not also contain the certificate.
MODULES_SIGN_HASH="sha512" # Defaults to sha512.

# Optionally, to boot with secureboot enabled, may be the same or different signing key.
SECUREBOOT_SIGN_KEY="/path/to/kernel_key.pem"
SECUREBOOT_SIGN_CERT="/path/to/kernel_key.pem"
Nota
The SECUREBOOT_SIGN_KEY and SECUREBOOT_SIGN_CERT may be different files. For this example the pem file generated by OpenSSL includes both the key and the accompanying certificate, and thus both variables are set to the same value.
Nota
For this example the same key that was generated to sign the modules is used to sign the kernel image. It is also possible to generate and use a second separate key for signing the kernel image. The same OpenSSL command as in the previous section may be used again.

See the above section for instructions on generating a new key, the steps may be repeated if a separate key should be used to sign the kernel image.

To successfully boot with Secure Boot enabled, the used bootloader must also be signed and the certificate must be accepted by the UEFI firmware or Shim. This will be explained later in the handbook.

Upgrading and cleaning up

Once the kernel is installed, the package manager will automatically update it to newer versions. The previous versions will be kept until the package manager is requested to clean up stale packages. To reclaim disk space, stale packages can be trimmed by periodically running emerge with the --depclean option:

root #emerge --depclean

Alternatively, to specifically clean up old kernel versions:

root #emerge --prune sys-kernel/gentoo-kernel sys-kernel/gentoo-kernel-bin

Post-install/upgrade tasks

Distribution kernels are capable of rebuilding kernel modules installed by other packages. linux-mod-r1.eclass provides the dist-kernel USE flag which controls a subslot dependency on virtual/dist-kernel.

Enabling this USE flag on packages like sys-fs/zfs and sys-fs/zfs-kmod allows them to automatically be rebuilt against a newly updated kernel and, if applicable, will re-generate the initramfs accordingly.

Manually rebuilding the initramfs or Unified Kernel Image

If required, manually trigger such rebuilds by, after a kernel upgrade, executing:

root #emerge --ask @module-rebuild

If any kernel modules (e.g. ZFS) are needed at early boot, rebuild the initramfs afterward via:

root #emerge --config sys-kernel/gentoo-kernel
root #emerge --config sys-kernel/gentoo-kernel-bin

Installare i sorgenti

Nota
This section is only relevant when using the following genkernel (hybrid) or manual kernel management approach.

The use of sys-kernel/installkernel is not strictly required, but highly recommended. When this package is installed, the kernel installation process will be delegated to installkernel. This allows for installing several different kernel versions side-by-side as well as managing and automating several tasks relating to kernel installation described later in the handbook. Install it now with:

root #emerge --ask sys-kernel/installkernel

When installing and compiling the kernel for amd64-based systems, Gentoo recommends the sys-kernel/gentoo-sources package.

Choose an appropriate kernel source and install it using emerge:

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

Questo comando installerà i sorgenti del kernel Linux in /usr/src/ in cui un collegamento simbolico chiamato linux punterà ai sorgenti appena installati:

It is conventional for a /usr/src/linux symlink to be maintained, such that it refers to whichever sources correspond with the currently running kernel. However, this symbolic link will not be created by default. An easy way to create the symbolic link is to utilize eselect's kernel module.

For further information regarding the purpose of the symlink, and how to manage it, please refer to Kernel/Upgrade.

First, list all installed kernels:

root #eselect kernel list
Available kernel symlink targets:
  [1]   linux-6.6.21-gentoo

In order to create a symbolic link called linux, use:

root #eselect kernel set 1
root #ls -l /usr/src/linux
lrwxrwxrwx    1 root   root    12 Oct 13 11:04 /usr/src/linux -> linux-6.6.21-gentoo

Alternativa: Usare genkernel

Nota
In case it was missed, this section requires the kernel sources to be installed. Be sure to obtain the relevant kernel sources, then return here for the rest of section.

Se la configurazione manuale risulta troppo difficoltosa, allora è raccomandato usare genkernel. Esso configurerà e costruirà il kernel in modo automatico.

Genkernel provides a generic kernel configuration file and will compile the kernel and initramfs, then install the resulting binaries to the appropriate locations. This results in minimal and generic hardware support for the system's first boot, and allows for additional update control and customization of the kernel's configuration in the future.

Be informed: while using genkernel to maintain the kernel provides system administrators with more update control over the system's kernel, initramfs, and other options, it will require a time and effort commitment to perform future kernel updates as new sources are released. Those looking for a hands-off approach to kernel maintenance should use a distribution kernel.

For additional clarity, it is a misconception to believe genkernel automatically generates a custom kernel configuration for the hardware on which it is run; it uses a predetermined kernel configuration that supports most generic hardware and automatically handles the make commands necessary to assemble and install the kernel, the associate modules, and the initramfs file.

Binary redistributable software license group

If the linux-firmware package has been previously installed, then skip onward to the to the installation section.

As a prerequisite, due to the firwmare USE flag being enabled by default for the sys-kernel/genkernel package, the package manager will also attempt to pull in the sys-kernel/linux-firmware package. The binary redistributable software licenses are required to be accepted before the linux-firmware will install.

This license group can be accepted system-wide for any package by adding the @BINARY-REDISTRIBUTABLE as an ACCEPT_LICENSE value in the /etc/portage/make.conf file. It can be exclusively accepted for the linux-firmware package by adding a specific inclusion via a /etc/portage/package.license/linux-firmware file.

If necessary, review the methods of accepting software licenses available in the Installing the base system chapter of the handbook, then make some changes for acceptable software licenses.

If in analysis paralysis, the following will do the trick:

root #mkdir /etc/portage/package.license
FILE /etc/portage/package.license/linux-firmwareAccept binary redistributable licenses for the linux-firmware package
sys-kernel/linux-firmware @BINARY-REDISTRIBUTABLE

Installation

Vediamo ora come usare genkernel. Prima di tutto, installare sys-kernel/genkernel:

root #emerge --ask sys-kernel/genkernel

Generation

Ora, compilare i sorgenti del kernel eseguendo genkernel all. Attenzione, genkernel compila un kernel che supporta quasi tutto l'hardware possibile, questa compilazione richiederà molto tempo prima di arrivare alla fine!

Nota
Se la partizione di boot non usa ext2 o ext3 come filesystem potrebbe essere necessario configurare manualmente il kernel usando genkernel --menuconfig all e aggiungere il supporto a questo tipo particolare di filesystem nel kernel (ovvero, non come modulo). Gli utenti di LVM2 dovranno probabilmente aggiungere anche --lvm come argomento.
Nota
Users of LVM2 should add --lvm as an argument to the genkernel command below.
root #genkernel all

Quando genkernel conclude, vengono creati un kernel, un insieme completo di moduli e un disco RAM iniziale (initramfs). Useremo il kernel e l'initrd per configurare un boot loader più avanti in questo documento. Annotarsi i nomi del kernel e dell'initrd, in quanto queste informazioni verranno usate quando verrà modificato il file di configurazione del boot loader. L'initrd verrà avviato immediatamente dopo che il processo di avvio avrà effettuato l'autorilevamento dell'hardware (proprio come fa il CD di installazione) prima che il sistema "reale" si avvii.

root #ls /boot/kernel* /boot/initramfs*

Predefinito: Configurazione manuale

Introduzione

Nota
In case it was missed, this section requires the kernel sources to be installed. Be sure to obtain the relevant kernel sources, then return here for the rest of section.

Configurare manualmente un kernel è spesso considerata la procedura più difficile che un utente Linux debba compiere. Niente di più falso - dopo aver configurato un paio di kernel nessuno nemmeno ricorda che fosse difficile ;)

Comunque, una cosa è vera: è di vitale importanza conoscere il sistema quando si configura il kernel manualmente. La maggior parte delle informazioni si possono raccogliere installando sys-apps/pciutils che contiene il comando lspci:

root #emerge --ask sys-apps/pciutils
Nota
Dentro la chroot (radice cambiata), si possono ignorare con sicurezza gli avvisi pcilib (come pcilib: cannot open /sys/bus/pci/devices) che lspci potrebbere tirar fuori.

Un'altra fonte di informazioni è lsmod per vedere quali moduli del kernel il CD di installazione usa, poiché ciò potrebbe dare buone idee su cosa abilitare.

Adesso bisogna spostarsi nella directory del sorgente del kernel ed eseguire make menuconfig. Questo farà apparire il menù di configurazione.

root #cd /usr/src/linux
root #make menuconfig

La configurazione del kernel Linux ha molte, molte sezioni. Per prima cosa saranno elencate le opzioni che devono essere attivate (altrimenti Gentoo non funzionerà, o non funzionerà correttamente senza modifiche aggiuntive). Esiste anche una guida alla configurazione del kernel Gentoo nel wiki di Gentoo che potrebbe aiutare ulteriormente.

Abilitare le opzioni richieste

When using sys-kernel/gentoo-sources, it is strongly recommend the Gentoo-specific configuration options be enabled. These ensure that a minimum of kernel features required for proper functioning is available:

KERNEL Enabling Gentoo-specific options
Gentoo Linux --->
  Generic Driver Options --->
    [*] Gentoo Linux support
    [*]   Linux dynamic and persistent device naming (userspace devfs) support
    [*]   Select options required by Portage features
        Support for init systems, system and service managers  --->
          [*] OpenRC, runit and other script based systems and managers
          [*] systemd

Naturally the choice in the last two lines depends on the selected init system (OpenRC vs. systemd). It does not hurt to have support for both init systems enabled.

When using sys-kernel/vanilla-sources, the additional selections for init systems will be unavailable. Enabling support is possible, but goes beyond the scope of the handbook.

Enabling support for typical system components

Assicurarsi che ogni driver vitale per l'avvio del sistema (come un controller SCSI, ecc.) sia compilato nel kernel e non come modulo, altrimenti il sistema non sarà in grado di avviarsi completamente.

Proseguire selezionando l'esatto tipo di processore. È anche raccomandato abilitare le funzionalità MCE (se disponibili) così che gli utenti possano ricevere notifiche su eventuali problemi hardware. Su alcune architetture (come x86_64), questi errori non sono scritti su dmesg, ma su /dev/mcelog. Ciò richiede il pacchetto app-admin/mcelog.

Selezionare anche Maintain a devtmpfs file system to mount at /dev (Mantenere un file system devtmpfs da montare su /dev) così che i file dei dispositivi critici siano già presenti durante il processo di avvio (CONFIG_DEVTMPFS e CONFIG_DEVTMPFS_MOUNT):

KERNEL Abilitare il supporto a devtmpfs
Device Drivers --->
  Generic Driver Options --->
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [ ]   Automount devtmpfs at /dev, after the kernel mounted the rootfs

Verificare che il supporto dischi SCSI sia stato attivato (CONFIG_BLK_DEV_SD):

KERNEL Abilitare il supporto dischi SCSI
Device Drivers --->
   SCSI device support  --->
      <*> SCSI disk support
KERNEL Enabling basic SATA and PATA support (CONFIG_ATA_ACPI, CONFIG_SATA_PMP, CONFIG_SATA_AHCI, CONFIG_ATA_BMDMA, CONFIG_ATA_SFF, CONFIG_ATA_PIIX)
Device Drivers --->
  <*> Serial ATA and Parallel ATA drivers (libata)  --->
    [*] ATA ACPI Support
    [*] SATA Port Multiplier support
    <*> AHCI SATA support (ahci)
    [*] ATA BMDMA support
    [*] ATA SFF support (for legacy IDE and PATA)
    <*> Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support (ata_piix)

Verify basic NVMe support has been enabled:

KERNEL Enable basic NVMe support for Linux 4.4.x (CONFIG_BLK_DEV_NVME)
Device Drivers  --->
  <*> NVM Express block device
KERNEL Enable basic NVMe support for Linux 5.x.x (CONFIG_DEVTMPFS)
Device Drivers --->
  NVME Support --->
    <*> NVM Express block device

It does not hurt to enable the following additional NVMe support:

KERNEL Enabling additional NVMe support (CONFIG_NVME_MULTIPATH, CONFIG_NVME_MULTIPATH, CONFIG_NVME_HWMON, CONFIG_NVME_FC, CONFIG_NVME_TCP, CONFIG_NVME_TARGET, CONFIG_NVME_TARGET_PASSTHRU, CONFIG_NVME_TARGET_LOOP, CONFIG_NVME_TARGET_FC, CONFIG_NVME_TARGET_FCLOOP, CONFIG_NVME_TARGET_TCP
[*] NVMe multipath support
[*] NVMe hardware monitoring
<M> NVM Express over Fabrics FC host driver
<M> NVM Express over Fabrics TCP host driver
<M> NVMe Target support
  [*]   NVMe Target Passthrough support
  <M>   NVMe loopback device support
  <M>   NVMe over Fabrics FC target driver
  < >     NVMe over Fabrics FC Transport Loopback Test driver (NEW)
  <M>   NVMe over Fabrics TCP target support

Adesso andare su File Systems e selezionare il supporto ai file system desiderati. Non si compili il file system usato per la radice (root) come modulo, altrimenti Gentoo non sarà in grado di montare questa partizione. Selezionare anche Virtual memory e /proc file system. Selezionare una o più delle seguenti opzioni come richiesto dal sistema (CONFIG_EXT2_FS, CONFIG_EXT3_FS, CONFIG_EXT4_FS, CONFIG_MSDOS_FS, CONFIG_VFAT_FS, CONFIG_PROC_FS, e CONFIG_TMPFS):

KERNEL Selezionare i file system necessari
File systems --->
  <*> Second extended fs support
  <*> The Extended 3 (ext3) filesystem
  <*> The Extended 4 (ext4) filesystem
  <*> Reiserfs support
  <*> JFS filesystem support
  <*> XFS filesystem support
  <*> Btrfs filesystem support
  DOS/FAT/NT Filesystems  --->
    <*> MSDOS fs support
    <*> VFAT (Windows-95) fs support
 
Pseudo Filesystems --->
    [*] /proc file system support
    [*] Tmpfs virtual memory file system support (former shm fs)

Se PPPoE è usato per connettersi ad Internet, o un modem dial-up, allora abilitare le seguenti opzioni (CONFIG_PPP, CONFIG_PPP_ASYNC, e CONFIG_PPP_SYNC_TTY):

KERNEL Selezionare i driver necessari per PPPoE
Device Drivers --->
  Network device support --->
    <*> PPP (point-to-point protocol) support
    <*>   PPP support for async serial ports
    <*>   PPP support for sync tty ports

Le due opzioni di compressione non causaranno danni, ma non sono assolutamente necessarie, né lo è l'opzione PPP attraverso Ethernet, che potrebbe essere utilizzata solo da ppp quando configurata per eseguire PPPoE in modalità kernel.

Non si dimentichi di includere il supporto nel kernel per le schede di rete (Ethernet o wireless).

La maggior parte dei sistemi dispone di più core, quindi è importante attivare Symmetric multi-processing support (CONFIG_SMP):

KERNEL Abilitare il supporto SMP
Processor type and features  --->
  [*] Symmetric multi-processing support
Nota
Nei sistemi multi-core, ogni core conta come un processore.

Se verranno utilizzati dispositivi di input USB (come tastiera o mouse) o altri dispositivi USB, non si dimentichi di abilitare anche quelli (CONFIG_HID_GENERIC e CONFIG_USB_HID, CONFIG_USB_SUPPORT, CONFIG_USB_XHCI_HCD, CONFIG_USB_EHCI_HCD, CONFIG_USB_OHCI_HCD):

KERNEL Abilitare supporto USB per dispositivi di input
Device Drivers --->
  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

Optional: Signed kernel modules

To automatically sign the kernel modules enable CONFIG_MODULE_SIG_ALL:

KERNEL Sign kernel modules CONFIG_MODULE_SIG_ALL
[*] Enable loadable module support  
  -*-   Module signature verification    
    [*]     Automatically sign all modules    
    Which hash algorithm should modules be signed with? (Sign modules with SHA-512) --->

Optionally change the hash algorithm if desired.

To enforce that all modules are signed with a valid signature, enable CONFIG_MODULE_SIG_FORCE as well:

KERNEL Enforce signed kernel modules CONFIG_MODULE_SIG_FORCE
[*] Enable loadable module support  
  -*-   Module signature verification    
    [*]     Require modules to be validly signed
    [*]     Automatically sign all modules
    Which hash algorithm should modules be signed with? (Sign modules with SHA-512) --->

To use a custom key, specify the location of this key in CONFIG_MODULE_SIG_KEY, if unspecified the kernel build system will generate a key. It is recommended to generate one manually instead. This can be done with:

root #openssl req -new -nodes -utf8 -sha256 -x509 -outform PEM -out kernel_key.pem -keyout kernel_key.pem

OpenSSL will ask some questions about the user generating the key, it is recommended to fill in these questions as detailed as possible.

Store the key in a safe location, at the very least the key should be readable only by the root user. Verify this with:

root #ls -l kernel_key.pem
 -r-------- 1 root root 3164 Jan  4 10:38 kernel_key.pem 

If this outputs anything other then the above, correct the permissions with:

root #chown root:root kernel_key.pem
root #chmod 400 kernel_key.pem
KERNEL Specify signing key CONFIG_MODULE_SIG_KEY
-*- Cryptographic API  ---> 
  Certificates for signature checking  --->  
    (/path/to/kernel_key.pem) File name or PKCS#11 URI of module signing key

To also sign external kernel modules installed by other packages via linux-mod-r1.eclass, enable the modules-sign USE flag globally:

FILE /etc/portage/make.confEnable module signing
USE="modules-sign"
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
# Optionally, when using custom signing keys.
MODULES_SIGN_KEY="/path/to/kernel_key.pem"
MODULES_SIGN_CERT="/path/to/kernel_key.pem" # Only required if the MODULES_SIGN_KEY does not also contain the certificate
MODULES_SIGN_HASH="sha512" # Defaults to sha512
Nota
The MODULES_SIGN_KEY and MODULES_SIGN_CERT may be different files. For this example the pem file generated by OpenSSL includes both the key and the accompanying certificate, and thus both variables are set to the same value.

Optional: Signing the kernel image (Secure Boot)

When signing the kernel image (for use on systems with Secure Boot enabled) it is recommended to set the following kernel config options:

KERNEL Lockdown for secureboot
General setup  --->
  Kexec and crash features  --->   
    [*] Enable kexec system call                                                                                          
    [*] Enable kexec file based system call                                                                               
    [*]   Verify kernel signature during kexec_file_load() syscall                                                        
    [*]     Require a valid signature in kexec_file_load() syscall                                                        
    [*]     Enable ""image"" signature verification support
</div>  

<div lang="en" dir="ltr" class="mw-content-ltr">
[*] Enable loadable module support  
  -*-   Module signature verification    
    [*]     Require modules to be validly signed
    [*]     Automatically sign all modules
    Which hash algorithm should modules be signed with? (Sign modules with SHA-512) --->
</div>  

<div lang="en" dir="ltr" class="mw-content-ltr">
Security options  ---> 
[*] Integrity subsystem   
  [*] Basic module for enforcing kernel lockdown                                                                       
  [*]   Enable lockdown LSM early in init                                                                       
        Kernel default lockdown mode (Integrity)  --->
</div>            

  <div lang="en" dir="ltr" class="mw-content-ltr">
[*]   Digital signature verification using multiple keyrings                                                            
  [*]     Enable asymmetric keys support                                                                                     
  -*-       Require all keys on the integrity keyrings be signed                                                              
  [*]       Provide keyring for platform/firmware trusted keys                                                                
  [*]       Provide a keyring to which Machine Owner Keys may be added                                                        
  [ ]         Enforce Machine Keyring CA Restrictions

Where ""image"" is a placeholder for the architecture specific image name. These options, from the top to the bottom: enforces that the kernel image in a kexec call must be signed (kexec allows replacing the kernel in-place), enforces that kernel modules are signed, enables lockdown integrity mode (prevents modifying the kernel at runtime), and enables various keychains.

On arches that do not natively support decompressing the kernel (e.g. arm64 and riscv), the kernel must be built with its own decompressor (zboot):

KERNEL zboot CONFIG_EFI_ZBOOT
Device Drivers --->                                                                                                                           
  Firmware Drivers --->                                                                                                                       
    EFI (Extensible Firmware Interface) Support --->                                                                                               
      [*] Enable the generic EFI decompressor

After compilation of the kernel, as explained in the next section, the kernel image must be signed. First install app-crypt/sbsigntools and then sign the kernel image:

root #emerge --ask app-crypt/sbsigntools
root #sbsign /usr/src/linux-x.y.z/path/to/kernel-image --cert /path/to/kernel_key.pem --key /path/to/kernel_key.pem --out /usr/src/linux-x.y.z/path/to/kernel-image
Nota
For this example the same key that was generated to sign the modules is used to sign the kernel image. It is also possible to generate and use a second sperate key for signing the kernel image. The same OpenSSL command as in the previous section may be used again.

Then proceed with the installation.

To automatically sign EFI executables installed by other packages, enable the secureboot USE flag globally:

FILE /etc/portage/make.confEnable Secure Boot
USE="modules-sign secureboot"
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
# Optionally, to use custom signing keys.
MODULES_SIGN_KEY="/path/to/kernel_key.pem"
MODULES_SIGN_CERT="/path/to/kernel_key.pem" # Only required if the MODULES_SIGN_KEY does not also contain the certificate.
MODULES_SIGN_HASH="sha512" # Defaults to sha512
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
# Optionally, to boot with secureboot enabled, may be the same or different signing key.
SECUREBOOT_SIGN_KEY="/path/to/kernel_key.pem"
SECUREBOOT_SIGN_CERT="/path/to/kernel_key.pem"
Nota
The SECUREBOOT_SIGN_KEY and SECUREBOOT_SIGN_CERT may be different files. For this example the pem file generated by OpenSSL includes both the key and the accompanying certificate, and thus both variables are set to the same value.
Nota
When generating an Unified Kernel Image with systemd's ukify the kernel image will be signed automatically before inclusion in the unified kernel image and it is not necessary to sign it manually.


Configurazioni del kernel specifiche per architettura

Assicurarsi di selezionare Emulazione IA32 se i programmi a 32 bit devono essere supportati (CONFIG_IA32_EMULATION). Gentoo intallerà un sistema multilib (sistema misto a 32 e 64 bit) per impostazione predefinita. Quindi, a meno che un profilo no-multilib sia stato scelto, questa opzione è richiesta.

KERNEL Selezionare il tipo di processore e le sue caratteristiche
Processor type and features  --->
   [ ] Machine Check / overheating reporting 
   [ ]   Intel MCE Features
   [ ]   AMD MCE Features
  Processor family (AMD-Opteron/Athlon64)  --->
    ( ) Opteron/Athlon64/Hammer/K8
    ( ) Intel P4 / older Netburst based Xeon
    ( ) Core 2/newer Xeon
    ( ) Intel Atom
    ( ) Generic-x86-64
Executable file formats / Emulations  --->
   [*] IA32 Emulation

Abilitare il supporto alle tabelle di partizione GPT se ciò era stato precedentemente usato per partizionare il disco (CONFIG_PARTITION_ADVANCED e CONFIG_EFI_PARTITION):

KERNEL Abilitare il supporto a GPT
-*- Enable the block layer --->
   Partition Types --->
      [*] Advanced partition selection
      [*] EFI GUID Partition support

Abilitare il supporto ad EFI stub ed alle variabili EFI nel kernel Linux se UEFI viene usato per avviare il sistema (CONFIG_EFI, CONFIG_EFI_STUB, CONFIG_EFI_MIXED, e CONFIG_EFI_VARS):

KERNEL Abilitare il supporto a UEFI
Processor type and features  --->
    [*] EFI runtime service support 
    [*]   EFI stub support
    [*]     EFI mixed-mode support
 
Firmware Drivers  --->
    EFI (Extensible Firmware Interface) Support  --->
        <*> EFI Variable Support via sysfs
KERNEL Enabling SOF Firmware support (CONFIG_SND_SOC_SOF_TOPLEVEL, CONFIG_SND_SOC_SOF_PCI, CONFIG_SND_SOC_SOF_ACPI, CONFIG_SND_SOC_SOF_AMD_TOPLEVEL, CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL)
Device Drivers --->
  Sound card support --->
    Advanced Linux Sound Architecture --->
      <M> ALSA for SoC audio support --->
        [*] Sound Open Firmware Support --->
            <M> SOF PCI enumeration support
            <M> SOF ACPI enumeration support
            <M> SOF support for AMD audio DSPs
            [*] SOF support for Intel audio DSPs


Compilare e installare

Ora che la configurazione è completata, è il momento di compilare e installare il kernel. Uscire dalla configurazione ed avviare il processo di compilazione:

root #make && make modules_install
Nota
È possibile abilitare la compilazione parallela usando make -jX, dove X è un numero intero pari alle attività parallele che il processo di compilazione è abilitato a far girare. Le istruzioni sono similie a quelle usate precedentemente per /etc/portage/make.conf, con la variabile MAKEOPTS.

Quando il kernel ha terminato la compilazione, copiare l'immagine del kernel dentro /boot/. L'operazione viene gestita dal comando make install:

root #make install

Questo comando copierà l'immagine del kernel dentro /boot/ insieme al file System.map ed al file di configurazione del kernel.


Kernel installation

Installkernel

Installkernel may be used to automate, the kernel installation, initramfs generation, unified kernel image generation and/or bootloader configuration among other things. sys-kernel/installkernel implements two paths of achieving this: the traditional installkernel originating from Debian and systemd's kernel-install. Which one to choose depends, among other things, on the system's bootloader. By default systemd's kernel-install is used on systemd profiles, while the traditional installkernel is the default for other profiles.

If unsure, follow the 'Traditional layout' subsection below.

systemd-boot

When using systemd-boot (formerly gummiboot) as the bootloader, systemd's kernel-install must be used. Therefore ensure the systemd and the systemd-boot USE flags are enabled on sys-kernel/installkernel, and then install the relevant package for systemd-boot.

On OpenRC systems:

FILE /etc/portage/package.use/systemd-boot
sys-apps/systemd-utils boot kernel-install
sys-kernel/installkernel systemd systemd-boot
root #emerge --ask sys-apps/systemd-utils

On systemd systems:

FILE /etc/portage/package.use/systemd
sys-apps/systemd boot
sys-kernel/installkernel systemd-boot
root #emerge --ask sys-apps/systemd

GRUB

Users of GRUB can use either systemd's kernel-install or the traditional Debian installkernel. The systemd USE flag switches between these implementations. To automatically run grub-mkconfig when installing the kernel, enable the grub USE flag.

FILE /etc/portage/package.use/installkernel
sys-kernel/installkernel grub
root #emerge --ask sys-kernel/installkernel

Traditional layout, other bootloaders (e.g. lilo, etc.)

The traditional /boot layout (for e.g. LILO, etc.) is used by default if the grub, systemd-boot and uki USE flags are not enabled. No further action is required.


Building an initramfs

In certain cases it is necessary to build an initramfs - an initial ram-based file system. The most common reason is when important file system locations (like /usr/ or /var/) are on separate partitions. With an initramfs, these partitions can be mounted using the tools available inside the initramfs. The default configuration of the Project:Distribution Kernel requires an initramfs.

Without an initramfs, there is a risk that the system will not boot properly as the tools that are responsible for mounting the file systems require information that resides on unmounted file systems. An initramfs will pull in the necessary files into an archive which is used right after the kernel boots, but before the control is handed over to the init tool. Scripts on the initramfs will then make sure that the partitions are properly mounted before the system continues booting.

Importante
If using genkernel, it should be used for both building the kernel and the initramfs. When using genkernel only for generating an initramfs, it is crucial to pass --kernel-config=/path/to/kernel.config to genkernel or the generated initramfs may not work with a manually built kernel. Note that manually built kernels go beyond the scope of support for the handbook. See the kernel configuration article for more information.

Installkernel can automatically generate an initramfs when installing the kernel if the dracut USE flag is enabled:

FILE /etc/portage/package.use/installkernel
sys-kernel/installkernel dracut

Alternatively, dracut may be called manually to generate an initramfs. Install sys-kernel/dracut first, then have it generate an initramfs:

root #emerge --ask sys-kernel/dracut
root #dracut --kver=6.6.21-gentoo

The initramfs will be stored in /boot/. The resulting file can be found by simply listing the files starting with initramfs:

root #ls /boot/initramfs*

Optional: Building an Unified Kernel Image

An Unified Kernel Image (UKI) combines, among other things, the kernel, the initramfs and the kernel command line into a single executable. Since the kernel command line is embedded into the unified kernel image it should be specified before generating the unified kernel image (see below). Note that any kernel command line arguments supplied by the bootloader or firmware at boot are ignored when booting with secure boot enabled.

An unified kernel image requires a stub loader, currently the only one available is systemd-stub. To enable it:

For systemd systems:

FILE /etc/portage/package.use/systemd
sys-apps/systemd boot

For OpenRC systems:

FILE /etc/portage/package.use/systemd-utils
sys-apps/systemd-utils boot kernel-install

Installkernel can automatically generate an unified kernel image using either dracut or ukify, by enabling the respective flag. The uki USE flag should be enabled as well to install the generated unified kernel image to the $ESP/EFI/Linux directory on the EFI system partition (ESP).

For dracut:

FILE /etc/portage/package.use/installkernel
sys-kernel/installkernel dracut uki
FILE /etc/dracut.conf
uefi="yes"
kernel_cmdline="some-kernel-command-line-arguments"

For ukify:

FILE /etc/portage/package.use/installkernel
sys-apps/systemd ukify          # For systemd systems
sys-apps/systemd-utils ukify    # For OpenRC systems
sys-kernel/installkernel dracut ukify uki
FILE /etc/kernel/cmdline
some-kernel-command-line-arguments

Note that while dracut can generate both an initramfs and an unified kernel image, ukify can only generate the latter and therefore the initramfs must be generated separately with dracut.

Generic Unified Kernel Image

The prebuilt sys-kernel/gentoo-kernel-bin can optionally install a prebuilt generic unified kernel image containing a generic initramfs that is able to boot most systemd based systems. It can be installed by enabling the generic-uki USE flag, and configuring installkernel to not generate a custom initramfs or unified kernel image:

FILE /etc/portage/package.use/generic-uki
sys-kernel/gentoo-kernel-bin generic-uki
sys-kernel/installkernel -dracut -ukify uki

Secure Boot

The generic Unified Kernel Image optionally distributed by sys-kernel/gentoo-kernel-bin is already pre-signed. How to sign a locally generated unified kernel image depends on whether dracut or ukify is used. Note that the location of the key and certificate should be the same as the SECUREBOOT_SIGN_KEY and SECUREBOOT_SIGN_CERT as specified in /etc/portage/make.conf.

For dracut:

FILE /etc/dracut.conf
uefi="yes"
kernel_cmdline="some-kernel-command-line-arguments"
uefi_secureboot_key="/path/to/kernel_key.pem"
uefi_secureboot_cert="/path/to/kernel_key.pem"

For ukify:

FILE /etc/kernel/uki.conf
[UKI]
SecureBootPrivateKey=/path/to/kernel_key.pem
SecureBootCertificate=/path/to/kernel_key.pem

Rebuilding external kernel modules

External kernel modules installed by other packages via linux-mod-r1.eclass must be rebuilt for each new kernel version. When the distribution kernels are used this may be automated by enabling the dist-kernel flag globally.

FILE /etc/portage/package.use/module-rebuild
*/* dist-kernel

External kernel modules may also be rebuilt manually with:

root #emerge --ask @module-rebuild

Moduli del kernel

Configurazione dei moduli

Nota
Hardware modules are optional to be listed manually. udev will normally load all hardware modules that are detected to be connected in most cases. However, it is not harmful for modules that will be automatically loaded to be listed. Modules cannot be loaded twice; they are either loaded or unloaded. Sometimes exotic hardware requires help to load their drivers.

Elencare i moduli, che serve caricare automaticamente, su /etc/conf.d/modules. Anche le opzioni extra possono essere aggiunte ai moduli se necessario.

Per visualizzare tutti i moduli disponibili, eseguire il seguente comando find. Non dimenticarsi di sostituire "<versione del kernel>" con la versione del kernel appena compilata:

root #find /lib/modules/<versione del kernel>/ -type f -iname '*.o' -or -iname '*.ko' | less

Force loading particular kernel modules

Per esempio, per caricare automaticamente il modulo 3c59x.ko (che è il driver per una famiglia specifica di schede di rete 3Com), modificare il file /etc/conf.d/modules ed inserirvi il nome del modulo.

root #nano -w /etc/conf.d/modules
modules="3c59x"

Note that the module's .ko file suffix is insignificant to the loading mechanism and left out of the configuration file:

FILE /etc/modules-load.d/network.confForce loading 3c59x module
3c59x

Continuare l'installazione con la Configurazione del sistema.




Informazioni sul file system

Etichette dei file system e UUID

Sia MBR (BIOS) che GPT includono il supporto per le etichette e gli UUID dei file system. Questi attributi possono essere definiti in /etc/fstab come alternative per il comando mount da usare quando si tenta di trovare e montare i dispositivi a blocchi. Le etichette e gli UUID dei file system sono identificati dai prefissi LABEL e UUID e possono essere visionati con il comando blkid:

root #blkid
Attenzione
Se il file system dentro la partizione viene eliminato, allora i valori delle etichette e degli UUID del file system saranno conseguentemente alterati o rimossi.

Per via della sua unicità, si raccomanda ai lettori, che stanno usando una tabella delle partizioni stile MBR, di usare gli UUID anziché le etichette per definire i volumi da montare nel file /etc/fstab.

Importante
UUIDs of the filesystem on a LVM volume and its LVM snapshots are identical, therefore using UUIDs to mount LVM volumes should be avoided.

Etichette e UUID delle partizioni

Gli utenti che hanno scelto la strada GPT hanno un paio di 'robuste' opzioni disponibili per definire le partizioni su /etc/fstab. Le etichette e gli UUID delle partizioni possono essere usate per identificare le o la partizione individuale del dispositivo a blocchi, senza badare a quale file system è stato scelto per la partizione stessa. Le etichette e gli UUID sono identificati rispettivamente dai prefissi PARTLABEL e PARTUUID e possono essere comodamente visionati da terminale con il comando blkid:

Output for an amd64 EFI system using the Discoverable Partition Specification UUIDs may like the following:

root #blkid

Mentre non sempre è vero per le etichette delle partizioni, usando un UUID per identificare una partizione su fstab fornisce una garanzia che l'avviatore non farà confusione quando ricercherà un certo volume, persino quando il file system dovesse cambiare in futuro. Usare i percorsi per i dispositivi a blocchi predefiniti (/dev/sd*N) per definire le partizioni su fstab è rischioso per i sistemi che vengono riavviati spesso ed hanno dispositivi a blocchi SATA che vengono aggiunti e rimossi regolarmente.

La denominazione dei percorsi dei dispositivi a blocchi dipende da un certo numero di fattori, incluso come ed in quale ordine i dischi sono attaccati al sistema. Essi potrebbero anche apparire in un ordine differente in base a quali dispositivi vengono rilevati prima dal kernel durante la prima fase del processo di avvio. Premesso ciò, a meno che uno non intenda avere continuamente a che fare con l'ordinamento dei dischi, usare i percorsi predefiniti per i dispositivi a blocchi è un approccio semplice e diretto.

Riguardo fstab

Su Linux, tutte le partizioni usate dal sistema devono essere elencate in /etc/fstab. Questo file contiene i punti di montaggio di quelle partizioni (cioè dove esse verranno viste rispetto alla struttura del file system), come dovranno essere montate e con quali opzioni speciali (automaticamente o meno, se gli utenti potranno montarle o meno, ecc.).

Creare il file fstab

Il file /etc/fstab usa una sintassi stile tabella. Ogni linea consiste in sei campi, separati da uno spazio bianco (uno o più spazi, tabulazioni, o un misto). Ogni campo ha il suo specifico significato:

  1. Il primo campo mostra il dispositivo a blocchi speciale o il file system in remoto che deve essere montato. Svariati tipi di identificatori di dispositivi sono disponibili per i nodi dei dispositivi a blocchi speciali, etichette di file system e UUID, ed etichette di partizioni e UUID.
  2. Il secondo campo mostra il punto di montaggio sul quale la partizione andrebbe montata.
  3. Il terzo campo mostra il file system usato dalla partizione
  4. Il quarto campo mostra le opzioni di montaggio usate da mount quando si vuole montare la partizione. Siccome ogni file system ha le sue opzioni di montaggio, gli utenti sono incoraggiati a leggere la pagina del manuale di mount (man mount) per averne una lista completa. Opzioni multiple di montaggio vanno separate con una virgola.
  5. Il quinto campo è usato da dump (copia del contenuto della memoria) per determinare se la partizione necessità di ricevere un dump oppure no. Questo valore viene generalmente lasciato a 0 (zero).
  6. Il sesto campo è usato da fsck per determinare l'ordine in cui i file system dovrebbero essere controllati quando il sistema non si arresta correttamente. Il file system radice (root) dovrebbe avere 1 mentre i rimanenti dovrebbero avere 2 (oppure 0 se il controllo del file system non è necessario).
Importante
Il file predefinito /etc/fstab fornito da Gentoo non è un file fstab valido, però offre più di un modello soltanto.
root #nano -w /etc/fstab

DOS/Legacy BIOS systems

Diamo un'occhiata a come scrivere le opzioni per la partizione /boot/. Questo è solo un esempio e dovrebbe essere modificato in accordo alle decisioni di partizionamento prese all'inizio dell'installazione. Nel nostro esempio di partizionamento per amd64, /boot/ è solitamente la partizione /dev/sda1, con file system ext2. Esso necessita di essere controllato durante l'avvio, dunque dovremmo scrivere:

FILE /etc/fstabUn esempio per la linea di /boot su /etc/fstab
/dev/sda1   /boot     ext2    defaults        0 2

Alcuni utenti non vogliono che la loro partizione /boot/ sia montata automaticamente per migliorare la sicurezza del loro sistema. Tali utenti dovrebbero sostituire defaults con noauto. Ciò fa sì che questi utenti dovranno montare manualmente la partizione ogni volta che desiderino usarla.

Aggiungere regole che corrispondano al precedente schema di partizionamento deciso ed aggiungere regole per i dispositivi come i lettori CD-ROM e, certamente, per ogni altra partizione o lettore (drive) in uso.

Sotto c'è un esempio molto più elaborato del file /etc/fstab:

FILE /etc/fstabUn esempio completo per /etc/fstab
/dev/sda1   /boot        ext2    defaults,noatime     0 2
/dev/sda2   none         swap    sw                   0 0
/dev/sda3   /            ext4    noatime              0 1
  
/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0

/dev/cdrom /mnt/cdrom auto noauto,user 0 0 }}

UEFI systems

Below is an example of an /etc/fstab file for a system that will boot via UEFI firmware:

FILE /etc/fstabA full /etc/fstab example for an UEFI system
# Adjust for any formatting differences and/or additional partitions created from the "Preparing the disks" step
/dev/sda1   /efi        vfat    umask=0077     0 2
/dev/sda2   none         swap    sw                   0 0
/dev/sda3   /            xfs    defaults,noatime              0 1
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0


DPS UEFI PARTUUID

Below is an example of an /etc/fstab file for a disk formatted with a GPT disklabel and Discoverable Partition Specification (DPS) UUIDs set for UEFI firmware:

FILE /etc/fstabDPS PARTUUID fstab example
# Adjust any formatting difference and additional partitions created from the "Preparing the disks" step.
# This example shows a GPT disklabel with Discoverable Partition Specification (DSP) UUID set:
PARTUUID=c12a7328-f81f-11d2-ba4b-00a0c93ec93b   /efi        vfat    umask=0077                   0 2
PARTUUID=0657fd6d-a4ab-43c4-84e5-0933c84b4f4f   none        swap    sw                           0 0
PARTUUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709   /           xfs     defaults,noatime             0 1


Quando si usa nel terzo campo auto, lascia che il comando mount indovini quale file system ci sia. Questo è raccomandato per i supporti removibili in quanto possono essere creati con uno tra tanti file system. L'opzione user nel quarto campo rende possibile ad un utente non-root (non amministratore o "radice") montare il CD.

To improve performance, most users would want to add the noatime mount option, which results in a faster system since access times are not registered (those are not needed generally anyway). This is also recommended for systems with solid state drives (SSDs). Users may wish to consider lazytime instead.

Suggerimento
Due to degradation in performance, defining the discard mount option in /etc/fstab is not recommended. It is generally better to schedule block discards on a periodic basis using a job scheduler such as cron or a timer (systemd). See Periodic fstrim jobs for more information.

Controllare due volte il file /etc/fstab, salvare ed uscire per continuare.

Informazioni di rete

It is important to note the following sections are provided to help the reader quickly setup their system to partake in a local area network.

For systems running OpenRC, a more detailed reference for network setup is available in the advanced network configuration section, which is covered near the end of the handbook. Systems with more specific network needs may need to skip ahead, then return here to continue with the rest of the installation.

For more specific systemd network setup, please review see the networking portion of the systemd article.

Informazioni host e dominio

Una delle scelte che l'utente deve compiere è dare un nome al suo PC. Questo sembra piuttosto facile, ma molti utenti hanno difficoltà a trovare il nome appropriato per il proprio PC Linux. Per velocizzare le cose, si sappia che la decisione non è definitiva - può essere cambiata in seguito. Nell'esempio sottostante il nome host tux è stato usato all'interno del dominio homenetwork (rete di casa).

Set the hostname (OpenRC or systemd)

root #echo tux > /etc/hostname

systemd

To set the system hostname for a system currently running systemd, the hostnamectl utility may be used. During the installation process however, systemd-firstboot command must be used instead (see later on in handbook).

For setting the hostname to "tux", one would run:

root #hostnamectl hostname tux

View help by running hostnamectl --help or man 1 hostnamectl.

Network

There are many options available for configuring network interfaces. This section covers a only a few methods. Choose the one which seems best suited to the setup needed.

DHCP via dhcpcd (any init system)

Most LAN networks operate a DHCP server. If this is the case, then using the dhcpcd program to obtain an IP address is recommended.

To install:

root #emerge --ask net-misc/dhcpcd

To enable and then start the service on OpenRC systems:

root #rc-update add dhcpcd default
root #rc-service dhcpcd start

To enable the service on systemd systems:

root #systemctl enable dhcpcd

With these steps completed, next time the system boots, dhcpcd should obtain an IP address from the DHCP server. See the Dhcpcd article for more details.

netifrc (OpenRC)

Suggerimento
This is one particular way of setting up the network using Netifrc on OpenRC. Other methods exist for simpler setups like Dhcpcd.

Configurare la rete

Durante l'installazione di Gentoo Linux, la rete per lavorare era già configurata. Comunque, ciò valeva per il CD di installazione stesso e non per l'ambiente installato. Adesso, la configurazione di rete è stata fatta per il sistema Gentoo Linux installato.

Nota
Informazioni più dettagliate sul lavoro di rete, inclusi argomenti avanzati come collegamenti, ponti, VLAN 802.1Q o reti wireless sono trattati nella sezione della Configurazione delle reti su Gentoo.

Tutte le informazioni di rete sono raccolte su /etc/conf.d/net. La sintassi è lineare ma forse non ancora intuitiva. Ma niente paura, ogni cosa sarà spiegata di seguito. Un esempio completamente commentato che copre molte diverse configurazioni è disponibile in /usr/share/doc/netifrc-*/net.example.bz2.

Prima installare net-misc/netifrc:

root #emerge --ask --noreplace net-misc/netifrc

DHCP è usato in modo predefinito. Affinché DHCP funzioni, è necessario installare un client DHCP. Ciò viene descritto più avanti negli Strumenti di sistema necessari per l'installazione.

Se la connessione di rete necessita di essere configurata a causa di opzioni specifiche per DHCP o perché DHCP non è usato affatto, allora si apra /etc/conf.d/net:

root #nano -w /etc/conf.d/net

Impostare sia config_eth0 che routes_eth0 per inserire le informazioni sull'indirizzo IP e sull'instradamento.

Nota
Si presume che l'interfaccia di rete sia chiamata eth0. Comunque, ciò dipende strettamente dal sistema. È raccomandato assumere che l'interfaccia sia nominata con il nome dell'interfaccia presente all'avvio del mezzo di installazione, considerando che il mezzo di installazione sia abbastanza recente. Maggiori informazioni si possono trovare su Denominazione delle interfacce di rete.
FILE /etc/conf.d/netDefinizione di un IP statico
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"

Per usare DHCP, definire config_eth0:

FILE /etc/conf.d/netDefinizione di DHCP
config_eth0="dhcp"

Si legga /usr/share/doc/netifrc-*/net.example.bz2 per un elenco completo delle opzioni disponibili. Assicurarsi di controllare bene anche la pagina man (manuale) del client DHCP se è necessario impostare opzioni specifiche per DHCP.

Se il sistema ha svariate interfacce di rete, allora ripetere i passi precedenti per config_eth1, config_eth2, ecc.

Adesso salvare la configurazione ed uscire per proseguire.

Avvio automatico dei servizi di rete

Per avere le interfacce di rete attive all'avvio, esse vanno aggiunte al runlevel (livello di esecuzione) predefinito.

root #cd /etc/init.d
root #ln -s net.lo net.eth0
root #rc-update add net.eth0 default

Se il sistema ha diverse interfacce di rete, allora gli appropriati file net.* devono essere creati come è stato fatto con net.eth0.

Se dopo aver avviato il sistema, risulta che il nome assunto per l'interfaccia di rete (attualmente nella documentazione come eth0) era sbagliato, allora si eseguano i seguenti passaggi per correggerlo:

  1. Aggiornare il file /etc/conf.d/net con il nome di interfaccia corretto (per esempio enp3s0 anziché eth0).
  2. Creare un nuovo link simbolico (esempio /etc/init.d/net.enp3s0).
  3. Rimuovere il vecchio link simbolico (rm /etc/init.d/net.eth0).
  4. Aggiungere quello nuovo al runlevel (livello di esecuzione) predefinito.
  5. Rimuovere quello vecchio con rc-update del net.eth0 default.

Il file degli host

Si passa ad informare Linux riguardo l'ambiente di rete. Questo è definito su /etc/hosts ed aiuta a risolvere i nomi host permettendo di ottenere gli indirizzi IP per gli host che non sono risolti dal nameserver (server dei nomi).

root #nano -w /etc/hosts
FILE /etc/hostsCompilazione delle informazioni di rete
# This defines the current system and must be set
# Questo definisce il sistema stesso e deve essere impostato
127.0.0.1     tux.homenetwork tux localhost
  
# Optional definition of extra systems on the network
# Definizione opzionale per sistema extra sulla rete
192.168.0.5   jenny.homenetwork jenny
192.168.0.6   benny.homenetwork benny

Salvare ed uscire dall'editor per continuare.

Informazioni di sistema

Password root

Impostare la password per root (radice) usando il comando passwd.

root #passwd

L'account Linux root è un account con tutti i poteri, dunque si scelga una password robusta. In seguito, verranno creati degli account aggiuntivi per le operazioni quotidiane degli utenti ordinari.

Configurazione init e all'avvio

OpenRC

Gentoo (almeno quando si usa OpenRC) usa /etc/rc.conf per configurare i servizi, la partenza, e lo spegnimento del sistema. Aprire /etc/rc.conf e divertirsi con tutti i commenti nel file. Rivedere le impostazioni e cambiarle dove necessario.

root #nano -w /etc/rc.conf

Poi, aprire /etc/conf.d/keymaps per gestire la configurazione della tastiera. Modificare il file per configurare ed impostare correttamente la tastiera.

root #nano -w /etc/conf.d/keymaps

Si presti particolare attenzione alla variabile keymap. Se viene selezionata la mappa dei tasti sbagliata, quando si digita sulla tastiera verranno visualizzati strani risultati.

Infine, modificare /etc/conf.d/hwclock per impostare le opzioni dell'orologio. Modificarlo secondo le preferenze personali.

root #nano -w /etc/conf.d/hwclock

Se l'orologio hardware non sta usando UTC, allora è necessario impostare clock="local" nel file. Nel caso contrario, ciò comporterebbe disallineamenti dell'ora nel sistema.

systemd

First, it is recommended to run systemd-machine-id-setup and then systemd-firstboot which will prepare various components of the system are set correctly for the first boot into the new systemd environment. The passing the following options will include a prompt for the user to set a locale, timezone, hostname, root password, and root shell values. It will also assign a random machine ID to the installation:

root #systemd-machine-id-setup
root #systemd-firstboot --prompt

Next users should run systemctl to reset all installed unit files to the preset policy values:

root #systemctl preset-all --preset-mode=enable-only

It's possible to run the full preset changes but this may reset any services which were already configured during the process:

root #systemctl preset-all

These two steps will help ensure a smooth transition from the live environment to the installation's first boot.




Registratore di sistema

OpenRC

Alcuni strumenti risultano assenti sull'archivio stage3, dato che numerosi pacchetti forniscono le stesse funzionalità. Spetta all'utente scegliere quali installare.

Il primo strumento su cui decidere fornisce facilitazioni sulla registrazione degli eventi di sistema (log). Unix e Linux hanno un'eccellente storia sulle loro capacità di annotazione degli eventi - se necessario, qualsiasi cosa succede al sistema può essere registrato nei file di log. Questo avviene tramite un registratore di sistema (logger).

Gentoo offre numerose utilità di registrazione di sistema. Alcune di queste includono:

  • app-admin/sysklogd - Offre l'insieme tradizionale dei servizi di log di sistema. La configurazione predefinita per il log funziona bene così com'è, ciò rende il pacchetto una buona opzione per i principianti.
  • app-admin/syslog-ng - Un sistema avanzato di log. Richiede una configurazione aggiuntiva per qualsiasi cosa che va oltre la registrazione su un unico grande file. Gli utenti più esperti possono scegliere questo pacchetto per il suo potenziale di registrazione; si presti attenzione alla configurazione aggiuntiva, la quale è necessaria per qualsiasi tipo di registrazione intelligente.
  • app-admin/metalog - Un registratore di sistema ampiamente configurabile.

Altri ancora sono disponibili attraverso Portage - il numero di pacchetti disponibili aumenta giorno per giorno.

Suggerimento
Se si intende usare sysklogd o syslog-ng, è raccomandato installare e configurare logrotate in seguito, poiché questi registratori (logger) di sistema non forniscono alcun meccanismo di rotazione per i file di registro (log).

Per installare il registratore di sistema scelto, emergerlo (emerge) e farlo aggiungere al livello di esecuzione (runlevel) predefinito usando rc-update. Il seguente esempio installa app-admin/sysklogd:

root #emerge --ask app-admin/sysklogd
root #rc-update add sysklogd default

systemd

While a selection of logging mechanisms are presented for OpenRC-based systems, systemd includes a built-in logger called the systemd-journald service. The systemd-journald service is capable of handling most of the logging functionality outlined in the previous system logger section. That is to say, the majority of installations that will run systemd as the system and service manager can safely skip adding a additional syslog utilities.

See man journalctl for more details on using journalctl to query and review the systems logs.

For a number of reasons, such as the case of forwarding logs to a central host, it may be important to include redundant system logging mechanisms on a systemd-based system. This is a irregular occurrence for the handbook's typical audience and considered an advanced use case. It is therefore not covered by the handbook.

Opzionale: Servizio cron

OpenRC

Il prossimo è il servizio o demone cron. Sebbene sia opzionale e non richiesto su tutti i sistemi, è saggio averne uno.

Un servizio cron esegue comandi programmati. È molto comodo in caso di comandi da eseguire regolarmente (per esempio, ogni giorno, ogni settimana, od ogni mese).

All cron daemons support high levels of granularity for scheduled tasks, and generally include the ability to send an email or other form of notification if a scheduled task does not complete as expected.

Gentoo offre numerosi possibili servizi cron, tra cui sys-process/bcron, sys-process/dcron, sys-process/fcron, e sys-process/cronie. Installare uno di questi è simile all'installazione di un registratore di sistema. Il seguente esempio usa sys-process/cronie:

  • sys-process/cronie - cronie is based on the original cron and has security and configuration enhancements like the ability to use PAM and SELinux.
  • sys-process/dcron - This lightweight cron daemon aims to be simple and secure, with just enough features to stay useful.
  • sys-process/fcron - A command scheduler with extended capabilities over cron and anacron.
  • sys-process/bcron - A younger cron system designed with secure operations in mind. To do this, the system is divided into several separate programs, each responsible for a separate task, with strictly controlled communications between parts.

cronie

The following example uses sys-process/cronie:

root #emerge --ask sys-process/cronie
root #rc-update add cronie default
root #rc-update add cronie default

Alternative: dcron

root #emerge --ask sys-process/dcron

Se vengono usati dcron o fcron, un comando di inizializzazione aggiuntivo deve essere eseguito:

root #crontab /etc/crontab

Alternative: fcron

root #emerge --ask sys-process/fcron

If fcron is the selected scheduled task handler, an additional emerge step is required:

root #emerge --config sys-process/fcron

Alternative: bcron

bcron is a younger cron agent with built-in privilege separation.

root #emerge --ask sys-process/bcron

systemd

Similar to system logging, systemd-based systems include support for scheduled tasks out-of-the-box in the form of timers. systemd timers can run at a system-level or a user-level and include the same functionality that a traditional cron daemon would provide. Unless redundant capabilities are necessary, installing an additional task scheduler such as a cron daemon is generally unnecessary and can be safely skipped.

Opzionale: Indicizzazione dei file

Allo scopo di indicizzae il filesystem per avere capacità di localizzazione dei file più veloci, installare sys-apps/mlocate.

root #emerge --ask sys-apps/mlocate

Opzionale: Accesso remoto

Suggerimento
opensshd's default configuration does not allow root to login as a remote user. Please create a non-root user and configure it appropriately to allow access post-installation if required, or adjust /etc/ssh/sshd_config to allow root.

Per avere la possibilità di accedere al sistema da remoto dopo l'installazione, aggiungere lo script di init sshd al livello di esecuzione (runlevel) predefinito:

OpenRC

root #rc-update add sshd default

Se è richiesto un accesso da console seriale (che è possibile in caso di server remoti), decommentare la sezione console seriale su /etc/inittab:

Uncomment the serial console section in /etc/inittab:

root #nano -w /etc/inittab
# SERIAL CONSOLES
s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100
s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100

systemd

To enable the SSH server, run:

root #systemctl enable sshd

To enable serial console support, run:

root #systemctl enable getty@tty1.service

Optional: Shell completion

Bash

Bash is the default shell for Gentoo systems, and therefore installing completion extensions can aid in efficiency and convenience to managing the system. The app-shells/bash-completion package will install completions available for Gentoo specific commands, as well as many other common commands and utilities:

root #emerge --ask app-shells/bash-completion

Post installation, bash completion for specific commands can managed through eselect. See the Shell completion integrations section of the bash article for more details.

Time synchronization

It is important to use some method of synchronizing the system clock. This is usually done via the NTP protocol and software. Other implementations using the NTP protocol exist, like Chrony.

To set up Chrony, for example:

root #emerge --ask net-misc/chrony

OpenRC

On OpenRC, run:

root #rc-update add chronyd default

systemd

On systemd, run:

root #systemctl enable chronyd.service

Alternatively, systemd users may wish to use the simpler systemd-timesyncd SNTP client which is installed by default.

root #systemctl enable systemd-timesyncd.service

Strumenti per i file system

In base al file system usato, è necessario installare le utilità per file system richieste (per controllare l'integrità dei file system, creare file system aggiuntivi, ecc.). Si noti che gli strumenti per gestire i file system ext2, ext3 o ext4 (sys-fs/e2fsprogs) sono già installati come parte del @system set.

La seguente tabella elenca gli strumenti da installare in relazione al file system usato:

Filesystem Package
Ext2, 3, e 4 sys-fs/e2fsprogs
XFS sys-fs/xfsprogs
ReiserFS sys-fs/reiserfsprogs
JFS sys-fs/jfsutils
VFAT (FAT32, ...) sys-fs/dosfstools
Btrfs sys-fs/btrfs-progs

It's recommended that sys-block/io-scheduler-udev-rules is installed for the correct scheduler behavior with e.g. nvme devices:

root #emerge --ask sys-block/io-scheduler-udev-rules
Suggerimento
Per maggiori informazioni sui file system in Gentoo vedere l'articolo sui file system.

Strumenti per il lavoro di rete

Se non c'è alcuna necessità di strumenti aggiuntivi per il lavoro di rete, continuare direttamente con la sezione Configurare un bootloader.

Installare un client DHCP

Importante
Sebbene opzionale, la maggior parte degli utenti si serve di un client DHCP per connettersi al server DHCP della propria rete. Si colga ora l'occasione di installare un client DHCP. Se questo passo viene dimenticato, il sistema potrebbe non essere in grado di accedere alla rete rendendo così impossibile scaricare un client DHCP più avanti.

Affinché il sistema ottenga automaticamente un indirizzo IP per una o più interfacce di rete usando gli script netifrc, è necessario installare un client DHCP. Raccomandiamo l'uso di net-misc/dhcpcd sebbene molti altri client DHCP siano disponibili sul deposito (repository) di Gentoo:

root #emerge --ask net-misc/dhcpcd

Opzionale: Installare un client PPPoE

Se PPP è utilizzato per connettersi ad Internet, installare il pacchetto net-dialup/ppp:

root #emerge --ask net-dialup/ppp

Optional: Install wireless networking tools

If the system will be connecting to wireless networks, install the net-wireless/iw package for Open or WEP networks and/or the net-wireless/wpa_supplicant package for WPA or WPA2 networks. iw is also a useful basic diagnostic tool for scanning wireless networks.

root #emerge --ask net-wireless/iw net-wireless/wpa_supplicant

Ora si prosegua con Configurare il bootloader.





Scegliere un avviatore

Con il kernel Linux configurato, gli strumenti di sistema installati ed i file di configurazione modificati, è tempo di installare l'ultimo importante pezzo di un'installazione Linux: l'avviatore (bootloader).

L'avviatore è responsabile del lancio del kernel Linux al momento dell'avvio - senza di esso, il sistema non saprebbe come procedere quando il pulsante di accensione (power) viene premuto.

Per amd64, documenteremo come configurare sia GRUB2 che LILO per sistemi basati su BIOS, e GRUB2 o efibootmgr per sistemi UEFI.

In questa sezione del Manuale, viene fatta una delineazione tra emergere un pacchetto per l'avviatore (boot loader) ed installare un avviatore nel disco di sistema. Qui il termine emergere sarà usato per chiedere a Portage di compilare un pacchetto software che sia disponibile per il sistema. Il termine installare significherà che l'avviatore copia i file o modifica fisicamente le sezioni appropriate dell'unità del disco di sistema affinché l'avviatore sia attivo e pronto ad operare dalla prossima accensione della macchina.

Predefinito: GRUB2

In via predefinita, la maggior parte dei sistemi Gentoo si affidano ora a GRUB2 (presente nel pacchetto sys-boot/grub), che è il diretto successo di GRUB Legacy. Senza configurazioni aggiuntive, GRUB2 supporta di buon grado i vecchi sistemi BIOS ("pc"). Con alcune configurazioni, necessarie prima della fase di compilazione, GRUB2 può supportare più di una mezza dozzina di piattaforme aggiuntive. Per maggiori informazioni, consultare la Sezione dei prerequisiti nell'articolo di GRUB2.

Compilare (emergere)

Quando si usano sistemi BIOS più vecchi che supportano solo tabelle delle partizioni MBR, nessuna configurazione aggiuntiva è necessaria per compilare (far emergere) GRUB:

root #emerge --ask --verbose sys-boot/grub:2

Una nota per gli utenti UEFI: eseguire il comando sopra comporterà l'abilitazione dei valori GRUB_PLATFORMS prima del comando emergere. Quando si usano sistemi che supportano UEFI, gli utenti si dovranno assicurare che GRUB_PLATFORMS="efi-64" sia abilitato (così come avviene nel caso predefinito). Se non è questo il caso durante la configurazione, GRUB_PLATFORMS="efi-64" dovrà essere aggiunto al file /etc/portage/make.conf prima di far emergere GRUB2, così che il pacchetto sarà compilato con la funzionalità EFI:

root #echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
root #emerge --ask sys-boot/grub:2
Se GRUB2 è stato compilato (fatto emergere) senza abilitare GRUB_PLATFORMS="efi-64", la linea (appena mostrata) può essere in seguito aggiunta a make.conf e le dipendenze per il "mondo" dei pacchetti ricalcolati passando le opzioni --update --newuse a emerge:
root #emerge --ask --update --newuse --verbose sys-boot/grub:2

Il software GRUB2 è ora fruibile nel sistema, ma non è ancora installato.

Installare

Poi, installare i file necessari di GRUB2 sulla cartella /boot/grub/ attraverso il comando grub-install. Supponendo che il primo disco (quello da cui il sistema si avvia) sia /dev/sda, uno dei successivi comandi sarà:

  • Quando si usa il BIOS:
root #grub-install /dev/sda

For DOS/Legacy BIOS systems:

root #grub-install /dev/sda
  • Quando si usa UEFI:
Importante
Assicurarsi che la partizione di sistema EFI sia stata montata, prima di eseguire grub-install. È possibile che grub-install installi il file EFI GRUB (grubx64.efi) nella cartella sbagliata senza fornire alcuna indicazione sulla cartella sbagliata usata.

For UEFI systems:

root #grub-install --target=x86_64-efi --efi-directory=/boot

Upon successful installation, the output should match the output of the previous command. If the output does not match exactly, then proceed to Debugging GRUB, otherwise jump to the Configure step.

Optional: Secure Boot

The sys-boot/grub package does not recognize the secureboot USE flag, this is because the GRUB EFI executable is not installed by the package but is instead built and installed by the grub-install command. GRUB must therefore be manually signed after installation to the boot partition. Additionally, GRUB is a modular bootloader but loading modules is prohibited when Secure Boot is enabled. Therefore all necessary modules must be compiled into the GRUB EFI executable, below an example is shown including some basic modules, this may have to be adjusted for more advanced configurations:

root #emerge --noreplace sbsigntools
root #export GRUB_MODULES="all_video boot btrfs cat chain configfile echo efifwsetup efinet ext2 fat font gettext gfxmenu gfxterm gfxterm_background gzio halt help hfsplus iso9660 jpeg keystatus loadenv loopback linux ls lsefi lsefimmap lsefisystab lssal memdisk minicmd normal ntfs part_apple part_msdos part_gpt password_pbkdf2 png probe reboot regexp search search_fs_uuid search_fs_file search_label sleep smbios squash4 test true video xfs zfs zfscrypt zfsinfo"
root #grub-install --target=x86_64-efi --efi-directory=/efi --modules=${GRUB_MODULES} --sbat /usr/share/grub/sbat.csv
root #sbsign /efi/EFI/GRUB/grubx64.efi --key /path/to/kernel_key.pem --cert /path/to/kernel_key.pem --out /efi/EFI/GRUB/grubx64.efi

To successfully boot with secure boot enabled the used certificate must either be accepted by the UEFI firmware, or shim must be used as a pre-loader. Shim is pre-signed with the third-party Microsoft Certificate, accepted by default by most UEFI motherboards.

How to configure the UEFI firmware to accept custom keys depends on the firmware vendor, which is beyond the scope of the handbook. Below is shown how to setup shim instead:

root #emerge sys-boot/shim sys-boot/mokutil sys-boot/efibootmgr
root #cp /usr/share/shim/BOOTX64.EFI /efi/EFI/GRUB/shimx64.efi
root #cp /usr/share/shim/mmx64.efi /efi/EFI/GRUB/mmx64.efi

Shims MOKlist requires keys in the DER format, since the OpenSSL key generated in the example here is in the PEM format, the key must be converted first:

root #openssl x509 -in /path/to/kernel_key.pem -inform PEM -out /path/to/kernel_key.der -outform DER
Nota
The path used here must be the path to the pem file containing the certificate belonging to the generated key. In this example both key and certificate are in the same pem file.

Then the converted certificate can be imported into Shims MOKlist:

root #mokutil --import /path/to/kernel_key.der

And finally we register Shim with the UEFI firmware. In the following command, boot-disk and boot-partition-id must be replaced with the disk and partition identifier of the EFI system partition:

root #efibootmgr --create --disk /dev/boot-disk --part boot-partition-id --loader '\EFI\GRUB\shimx64.efi' --label 'shim' --unicode
Debugging GRUB

When debugging GRUB, there are a couple of quick fixes that may result in a bootable installation without having to reboot to a new live image environment.

In the event that "EFI variables are not supported on this system" is displayed somewhere in the output, it is likely the live image was not booted in EFI mode and is presently in Legacy BIOS boot mode. The solution is to try the removable GRUB step mentioned below. This will overwrite the executable EFI file located at /EFI/BOOT/BOOTX64.EFI. Upon rebooting in EFI mode, the motherboard firmware may execute this default boot entry and execute GRUB.

If grub-install returns an error that says "Could not prepare Boot variable: Read-only file system", and the live environment was correctly booted in UEFI mode, then it should be possible to remount the efivars special mount as read-write and then re-run the aforementioned grub-install command:

root #mount -o remount,rw,nosuid,nodev,noexec --types efivarfs efivarfs /sys/firmware/efi/efivars

This is caused by certain non-official Gentoo environments not mounting the special EFI filesystem by default. If the previous command does not run, then reboot using an official Gentoo live image environment in EFI mode.

Alcuni produttori di schede madri sembrano supportare soltanto la posizione della cartella /efi/boot/ per i file .EFI nella partizione di sistema EFI (ESP). L'installatore di GRUB può eseguire questa operazione automaticamente con l'opzione --removable. Verificare che ESP sia montata prima di eseguire i seguenti comandi. Supponendo che ESP sia montata su /boot (come suggerito prima), eseguire:

root #grub-install --target=x86_64-efi --efi-directory=/boot --removable

Questo crea una cartella predefinita definita dalle specifiche UEFI, e poi copia i file grubx64.efi nella posizione 'predefinita'dei file EFI definita dalle stesse specifiche.

Configurare

Poi, generare la configurazione GRUB2 basata su quella specificata dall'utente nel file /etc/default/grub e negli script /etc/grub.d. Nella maggior parte dei casi, nessuna configurazione è richiesta agli utenti, in quanto GRUB2 rileverà automaticamente quale kernel avviare (quello più in alto disponibile su /boot/) e qual è il file system radice. È anche possibile aggiungere parametri per il kernel su /etc/default/grub tramite la variabile GRUB_CMDLINE_LINUX.

Per generare la configurazione finale di GRUB2, eseguire il comando grub-mkconfig:

root #grub-mkconfig -o /boot/grub/grub.cfg
Generating (Sto generando) grub.cfg ...
Found linux image (Immagine linux trovata): /boot/vmlinuz-6.6.21-gentoo
Found initrd image (Immagine initrd trovata): /boot/initramfs-genkernel-amd64-6.6.21-gentoo
done (fatto)

In risposta il comando deve riferire che almeno un'immagine Linux è stata trovata, in quanto queste sono necessarie per l'avvio del sistema. Se viene utilizzato un initramfs o genkernel è stato usato per compilare il kernel, anche l'immagine initrd corretta dovrebbe essere rilevata. Se questo non succede, andare su /boot/ e controllare il contenuto con il comando ls. Se effettivamente mancano i file, ritornare alla configurazione del kernel ed alle istruzioni di installazione.

Suggerimento
L'utilità os-prober può essere usata in combinazione con GRUB2 per rilevare altri sistemi operativi dai dischi connessi. Windows 7, 8.1, 10 ed altre distribuzioni Linux sono rilevabili. Chi desidera un sistema con doppio avvio dovrebbe compilare il pacchetto sys-boot/os-prober, poi rieseguire il comando grub-mkconfig (come visto sopra). Se si incontrano problemi di rilevamento assicurasi di leggere l'articolo GRUB2 per intero prima di chiedere supporto alla comunità di Gentoo.

Alternativa 1: LILO

Compilare (emergere)

LILO, il LInuxLOader (caricatore di Linux), è il vero cavallo di battaglia degli avviatori di Linux. Comunque, difetta per caratteristiche se comparato a GRUB. LILO è ancora usato, perché su alcuni sistemi GRUB non funziona, mentre LILO sì. Certamente è usato anche perché alcune persone conoscono LILO e vogliono rimanere con esso. Ad ogni modo, Gentoo supporta entrambi gli avviatori (bootloader).

Installare LILO è molto facile; basta usare emerge.

root #emerge --ask sys-boot/lilo

Configurare

Per configurare LILO, creare prima /etc/lilo.conf:

root #nano -w /etc/lilo.conf

Nel file di configurazione, le sezioni vengono utilizzate per fare riferimento al kernel avviabile. Assicurarsi che i file del kernel (con la versione del kernel) e dell'initramfs siano noti, in quanto devono essere indicati in questo file di configurazione.

Nota
Se il file system radice è JFS, aggiungere una linea append="ro" dopo ciascun elemento di avvio poiché JFS deve rieseguire il suo registro prima di consentire il montaggio in lettura e scrittura.
FILE /etc/lilo.confEsempio di configurazione di LILO
'"`UNIQ--pre-00000137-QINU`"'
Nota
Se uno schema di partizionamento e/o un'immagine del kernel differenti sono stati usati, aggiustare in accordo con la propria situazione.

Se è necessario un initramfs, allora cambiare la configurazione facendo riferimento a questo file initramfs e comunicando all'initramfs dove è collocato il dispositivo radice (root):

FILE /etc/lilo.confAggiungere informazioni su initramfs a una voce di avvio
'"`UNIQ--pre-0000013A-QINU`"'

Se opzioni aggiuntive devono essere passate al kernel, usare una dichiarazione append. Per esempio, per aggiungere la dichiarazione video per abilitare il framebuffer (segmento di memoria per i fotogrammi):

FILE /etc/lilo.confAggiunta del parametro video alle opzioni di avvio
'"`UNIQ--pre-0000013D-QINU`"'

Gli utenti che hanno usato genkernel dovrebbero sapere che i loro kernel usano le stesse opzioni di avvio usate dal CD di installazione. Per esempio, se il supporto ai dispositivi SCSI deve essere abilitato, aggiungere doscsi come opzione per il kernel.

Adesso salvare il file ed uscire.

Installare

Per concludere, lanciare l'eseguibile /sbin/lilo così che LILO possa applicare le impostazioni /etc/lilo.conf al sistema (vale a dire installa se stesso sul disco). Tener presente che /sbin/lilo deve essere eseguito ogni volta che viene installato un nuovo kernel o quando si modifica il file lilo.conf, così che il sistema possa avviarsi anche se il nome del file del kernel è stato cambiato.

root #/sbin/lilo

Alternativa 2: efibootmgr

Su sistemi UEFI, il firmware UEFI del sistema (in altre parole il principale bootloader - avviatore) può essere manipolato direttamente per cercare le voci di avvio UEFI. Questi sistemi non necessitano di avviatori aggiuntivi (anche conosciuti come avviatori secondari), come GRUB2 allo scopo di aiutare il sistema ad avviarsi. Dopo quanto detto, la ragione degli avviatori basati su EFI come GRUB2 esiste per estendere le funzionalità dei sistemi UEFI durante il processo di avvio. Usare efibootmgr è per coloro che desiderano decisamente mantenere un approccio minimalista (sebbene più rigido) nell'avvio del proprio sistema; usare GRUB2 (vedi sopra) è più facile per la maggior parte degli utenti perché offre un approccio più flessibile quando si avviano i sistemi UEFI.

System administrators who desire to take a minimalist, although more rigid, approach to booting the system can avoid secondary bootloaders and boot the Linux kernel as an EFI stub.

Terner presente che l'applicazione sys-boot/efibootmgr non è un avviatore; piuttosto è uno strumento per interagire con il firmware UEFI ed aggiornare le sue impostazioni, così che il kernel Linux precedentemente installato possa essere avviato con opzioni aggiuntive (se necessario), oppure per abilitare più voci di avvio. Questa interazione è possibile grazie alle variabili EFI (da cui la necessità del supporto delle variabili EFI da parte del kernel).

Assicurarsi di leggere l'articolo EFI stub kernel prima di continuare. Il kernel deve avere opzioni specifiche abilitate affinché sia direttamente avviabile dal firmware UEFI del sistema. Potrebbe risultare necessario ricompilare il kernel. È anche una buona idea dare un'occhiata all'articolo efibootmgr.

It is also a good idea to take a look at the efibootmgr article for additional information.

Nota
Per ribadire, efibootmgr non è un requisito di avvio di un sistema UEFI. Il kernel Linux stesso può essere avviato immediatamente, ed opzioni aggiuntive per il kernel tramite linea di comando possono essere integrate nel kernel Linux (c'è un'opzione di configurazione del kernel chiamata che permette agli utenti di specificare i parametri di avvio tramite opzioni a linea di comando). Anche un initramfs può essere 'integrato' nel kernel.

Coloro che hanno deciso di seguire questo approccio devono installare il software:

root #emerge --ask sys-boot/efibootmgr

Poi, creare la cartella /boot/efi/boot/ e copiare qui il kernel, chiamandolo bzImage.efi:

root #mkdir -p /boot/efi/boot
root #cp /boot/vmlinuz-* /boot/efi/boot/bzImage.efi
Nota
L'uso di \ come separatore di cartelle è obbligatorio quando si usano le definizioni UEFI.

In seguito, comunicare al firmware UEFI che una voce di avvio nominata "Gentoo" deve essere creata, la quale contiene il kernel appena compilato con la parte EFI:

root #efibootmgr --create --disk /dev/sda --part 2 --label "Gentoo" --loader "\efi\boot\bzImage.efi"

Se un file system iniziale su RAM (initramfs) viene usato, aggiungere l'appropriata opzione di avvio ad esso:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l "\efi\boot\bzImage.efi" initrd='\initramfs-genkernel-amd64-6.6.21-gentoo'

Note that the above command presumes an initramfs file was copied into the ESP inside the same directory as the bzImage.efi file.

Concluse queste modifiche, quando il sistema si riavvia, sarà disponibile una voce di avvio chiamata "Gentoo".

Unified Kernel Image

If installkernel was configured to build and install unified kernel images. The unified kernel image should already be installed to the EFI/Linux directory on the EFI system partition, if this is not the case ensure the directory exists and then run the kernel installation again as described earlier in the handbook.

To add a direct boot entry for the installed unified kernel image:

root #efibootmgr --create --disk /dev/sda --part 1 --label "gentoo" --loader /efi/EFI/Linux/gentoo-x.y.z.efi

Alternativa 3: Syslinux

Syslinux è un'altra alternativa di bootloader per l'architettura amd64. Supporta MBR e, come da versione 6.00, supporta l'avvio EFI. Anche l'avvio PXE (network) e opzioni meno conosciute sono supportate. Sebbene Syslinux sia un famoso bootloader per molti, non è supportato dal Manuale. I lettori possono trovare informazioni per emergerlo ed installarlo nell'articolo Syslinux.

Alternative 4: systemd-boot

Another option is systemd-boot, which works on both OpenRC and systemd machines. It is a thin chainloader and works well with secure boot.

To install systemd-boot:

root #bootctl install
Importante
Make sure the EFI system partition has been mounted before running bootctl install.

When using this bootloader, before rebooting, verify that a new bootable entry exists using:

root #bootctl list

If no new entry exists, ensure the sys-kernel/installkernel package has been installed with the systemd-boot USE flag enabled, and re-run the kernel installation.

For the distribution kernels:

root #emerge --ask --config sys-kernel/gentoo-kernel

For a manually configured and compiled kernel:

root #make install
Importante
When installing kernels for systemd-boot, no root= kernel command line argument is added by default. On systemd systems that are using an initramfs users may rely instead on systemd-gpt-auto-generator to automatically find the root partition at boot. Otherwise users should manually specify the location of the root partition by setting root= in /etc/kernel/cmdline as well as any other kernel command line arguments that should be used. And then reinstalling the kernel as described above.

Optional: Secure Boot

When the secureboot USE flag is enabled, the systemd-boot EFI executable will be signed automatically. bootctl install will automatically install the signed version.

To successfully boot with secure boot enabled the used certificate must either be accepted by the UEFI firmware, or shim must be used as a pre-loader. Shim is pre-signed with the third-party Microsoft Certificate, accepted by default by most UEFI motherboards.

How to configure the UEFI firmware to accept custom keys depends on the firmware vendor, which is beyond the scope of the handbook. A postinst hook to automatically update systemd-boot and set it up with shim instead is provided on the systemd-boot wiki page. However the first time this should be done manually by following the steps below:

root #emerge --ask sys-boot/shim sys-boot/mokutil sys-boot/efibootmgr
root #cp /usr/share/shim/BOOTX64.EFI /efi/EFI/BOOT/BOOTX64.EFI
root #cp /usr/share/shim/mmx64.efi /efi/EFI/BOOT/mmx64.efi
root #cp /efi/EFI/systemd/systemd-bootx64.efi /efi/EFI/BOOT/grubx64.efi
Nota
Shim is hardcoded to load grubx64.efi. As such the systemd-boot bootloader must be named as if it were GRUB.

Shims MOKlist requires keys in the DER format, since the OpenSSL key generated in the example here is in the PEM format, the key must be converted first:

root #openssl x509 -in /path/to/kernel_key.pem -inform PEM -out /path/to/kernel_key.der -outform DER
Nota
The path used here must be the path to the pem file containing the certificate belonging to the generated key. In this example both key and certificate are in the same pem file.

Then the converted certificate can be imported into Shims MOKlist:

root #mokutil --import /path/to/kernel_key.der

And finally we register Shim with the UEFI firmware. In the following command, boot-disk and boot-partition-id must be replaced with the disk and partition identifier of the EFI system partition:

root #efibootmgr --create --disk /dev/boot-disk --part boot-partition-id --loader '\EFI\BOOT\BOOTX64.EFI' --label 'shim' --unicode



Riavviare il sistema

Uscire dall'ambiente con la radice cambiata (chroot) e smontare tutte le partizioni montate. Poi si inserisca quell'unico magico comando che avvia il vero test finale: reboot.

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

Non dimenticare di rimuovere i CD avviabili, altrimenti il CD potrebbe essere avviato al posto del nuovo sistema Gentoo.

Una volta riavviato e giunti nell'ambiente Gentoo appena installato, concludere con Ultimare l'installazione di Gentoo.




Amministrazione utenti

Aggiungere un utente di uso quotidiano

Lavorare come root su un sistema Unix/Linux è pericoloso e dovrebbe essere evitato il più possibile. Perciò è fortemente raccomandato aggiungere un utente per un utilizzo quotidiano.

I gruppi di cui l'utente è membro definiscono quali attività l'utente può compiere. La seguente tabella elenca alcuni importanti gruppi:

Gruppo Descrizione
audio Permette di accedere ai dispositivi audio.
cdrom Permette di accedere direttamente ai dispositivi ottici.
floppy Permette di accedere direttamente ai dispositivi floppy.
games Permette di eseguire i giochi.
portage Permette di accedere alle risorse soggette a restrizioni di portage.
usb Permette di accedere ai dispositivi USB.
video Permette di accedere all'hardware per la cattura dei video e di usare l'accelerazione hardware.
wheel Permette di usare il comando su.

Per esempio, per creare un utente chiamato larry che sia membro dei gruppi wheel, users e audio, prima accedere come root (solo root può creare utenti), poi eseguire useradd:

Login:root
Password: (Inserire la password di root)

When setting passwords for standard user accounts, it is good security practice to avoid using the same or a similar password as set for the root user.

Handbook authors recommended to use a password at least 16 characters in length, with a value fully unique from every other user on the system.

root #useradd -m -G users,wheel,audio -s /bin/bash larry
root #passwd larry
Password: (Inserire la password per larry)
Re-enter password: (Reinserire la password per conferma)

Se un utente dovesse eseguire qualche attività come root, allora può usare su - per ricevere temporaneamente i privilegi di root. Un altro modo è usare il pacchetto sudo che è, se correttamente configurato, molto sicuro.

Pulizia del disco

Rimuovere i tarball

Con l'installazione di Gentoo conclusa ed il sistema riavviato, se ogni cosa è andata bene, possiamo rimuovere dal disco rigido il tarball stage3 scaricato. La cartella in cui vengono scaricati è /.

The files are located in the / directory and can be removed with the following command:

root #rm /stage3-*.tar.bz2*

Come proseguire da qui

Dove proseguire da qui? Quali opzioni si presentano adesso? Cosa esplorare inizialmente? Gentoo fornisce ai suoi utenti molte possibilità, e perciò molte caratteristiche documentate (e meno documentate).

Documentazione

It is important to note that, due to the number of choices available in Gentoo, the documentation provided by the handbook is limited in scope - it mainly focuses on the basics of getting a Gentoo system up and running and basic system management activities. The handbook intentionally excludes instructions on graphical environments, details on hardening, and other important administrative tasks. That being stated, there are more sections of the handbook to assist readers with more basic functions.

Decisamente è il caso di dare un'occhiata alla prossima parte del Manuale di Gentoo intitolata Lavorare con Gentoo che spiega come tenere il software aggiornato, come installare più software, cosa sono le USE flag (bandiere, opzioni), come l'init del sistema Gentoo funziona, ecc.

Oltre al manuale, ci si deve sentire incoraggiati ad esplorare altri angoli del Wiki di Gentoo per trovare documentazione aggiuntiva e fornita dalla comunità. La squadra wiki di Gentoo offre anche una Panoramica degli argomenti della documentazione che elenca una buona selezione di articoli presenti proprio sul wiki. Per esempio, si fa riferimento alla Guida per la localizzazione affinché il sistema ci faccia sentire più a nostro agio.

The majority of users with desktop use cases will setup graphical environments in which to work natively. There are many community maintained 'meta' articles for supported desktop environments (DEs) and window managers (WMs). Readers should be aware that each DE will require slightly different setup steps, which will lengthen add complexity to bootstrapping.

Many other Meta articles exist to provide our readers with high level overviews of available software within Gentoo.

Gentoo online

Importante
Readers should note that all official Gentoo sites online are governed by Gentoo's code of conduct. Being active in the Gentoo community is a privilege, not a right, and users should be aware that the code of conduct exists for a reason.

With the exception of the Libera.Chat hosted internet relay chat (IRC) network and the mailing lists, most Gentoo websites require an account on a per site basis in order to ask questions, open a discussion, or enter a bug.

Forums and IRC

Ognuno è certamente il benvenuto sui nostri forum Gentoo o su uno dei nostri tanti canali Gentoo IRC.

Mailing lists

Abbiamo anche numerose mailing list (liste email) aperte a tutti i nostri utenti. Informazioni su come unirsi sono presenti in quella pagina.

Bugs

Sometimes after reviewing the wiki, searching the forums, and seeking support in the IRC channel or mailing lists there is no known solution to a problem. Generally this is a sign to open a bug on Gentoo's Bugzilla site.

Development guide

Readers who desire to learn more about developing Gentoo can take a look at the Development guide. This guide provides instructions on writing ebuilds, working with eclasses, and provides definitions for many general concepts behind Gentoo development.

Closing thoughts

Divertiti con la tua installazione!

As a reminder, any feedback for this handbook should follow the guidelines detailed in the How do I improve the Handbook? section at the beginning of the handbook.

We look forward to seeing how our users will choose to implement Gentoo to fit their unique use cases and needs.



Warning: Display title "Manuale amd64 di Gentoo Linux: Installare Gentoo" overrides earlier display title "Manuale:AMD64/Installazione".