loadkeys itDISK=/dev/disk/by-id/nvme-INTEL_SSDPEKKW512G8_BTHH812205BA512D MOUNT=/mnt/gentoo ZPOOL=zroot STAGE3=[stage3 mirror address]
## 0.3 Controllare che la rete funzioni
```shell
ping -c 2 gentoo.org
Per le schede ethernet
dhcpcd enp3s0 (per il nome della scheda lo potete controllare con ip a)Per le schede WiFi
iwctl --passphrase PASSWPA2 station wlp2s0 connect YOURSSIDtimedatectl set-ntp truewipefs -af ${DISK}sgdisk -Zo ${DISK}parted --script -a optimal ${DISK} \
unit mib \
mklabel gpt \
mkpart esp 1 1025 \
mkpart rootfs 1025 100% \
set 1 boot onmkfs.vfat -F32 -n EFI ${DISK}-part1zpool create -f \
-o ashift=12 \
-o cachefile=/etc/zfs/zpool.cache \
-O normalization=formD \
-O compression=zstd \
-O acltype=posixacl \
-O relatime=on \
-O atime=off \
-o spacemap_histogram=enabled \
-o large_blocks=enabled \
-o bookmarks=enabled \
-o embedded_data=enabled \
-o empty_bpobj=enabled \
-o filesystem_limits=enabled \
-O xattr=sa \
-m none -R ${MOUNT} ${ZPOOL} ${DISK}-part2zfs create -o mountpoint=none -o canmount=off ${ZPOOL}/ROOT
zfs create -o mountpoint=none -o canmount=off ${ZPOOL}/data
zfs create -o mountpoint=/ ${ZPOOL}/ROOT/default
zfs create -o mountpoint=/home ${ZPOOL}/data/home
zfs create -o mountpoint=/var/db/repos ${ZPOOL}/data/ebuild
zfs create -o mountpoint=/var/cache/distfiles ${ZPOOL}/data/distfiles
zfs create -o mountpoint=/var/cache/ccache ${ZPOOL}/data/ccache
zfs create -V 32G -b 8192 -o logbias=throughput -o sync=always -o primarycache=metadata ${ZPOOL}/SWAPzpool set bootfs=${ZPOOL}/ROOT/default ${ZPOOL}1.8 Montaggio del filesystem (i filesystem zfs sono autogestiti e si montano nella directory specificata quando vengono creati)
mkdir -p ${MOUNT}/boot
mount ${DISK}-part1 ${MOUNT}/boot
mkswap /dev/zvol/${ZPOOL}/SWAP
swapon /dev/zvol/${ZPOOL}/SWAPmkdir -p ${ZPOOL}/etc/zfs
cp /etc/zfs/zpool.cache ${ZPOOL}/etc/zfs/zpool.cache###2.1 Scaricare lo stage 3
cd ${MOUNT}
wget ${STAGE3}
tar xvJpf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner###2.2 Montare Boot per Sistemi EFI
mkdir -p /mnt/boot/efi
mount -t vfat /dev/disk/by-id/usb...-part1 /mnt/boot/efi###2.3 Generare Fstab Generare fstab con il tool archlinux genfstab
genfstab -U -p /mnt | grep boot > /mnt/etc/fstabCopiare il resolv.conf per l'impostazione corretta dns in gentoo chroot :
cp -L /etc/resolv.conf ${MOUNT}/etc/Modificare il file make.conf
vim /mnt/etc/portage/make.conf# MAKEOPTS is equal to CPU CORE|Thread you have + 1,
# If need see how munch CPU core you have, launch the command `nproc`
# -j2 : 2 is the output of nproc, set -j1 with only 2GB RAM !
# -l2 : 2 is the output of nproc
MAKEOPTS="-j2 -l2"
# --jobs2 : 3 is the output of nproc
# --load-average=2 is the output of nproc
COMMON_FLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
EMERGE_DEFAULT_OPTS="--keep-going --jobs=2 --load-averoage=2 --autounmask-write=y --with-bdeps y --complete-graph y"
CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3"
AUTO_CLEAN="yes"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
GRUB_PLATFORMS="efi-64"
VIDEO_CARDS="i965 iris"
# Later for Xorg
INPUT_DEVICES="libinput"
# Accept stable and unstable packages
ACCEPT_KEYWORDS="amd64"emerge -av app-portage/cpuid2cpuflags
echo "*/* $(cpuid2cpuflags)" >> /etc/portage/package.use/00cpuflagsmkdir --parents /mnt/etc/portage/repos.conf
cp /mnt/usr/share/portage/config/repos.conf /mnt/etc/portage/repos.conf/gentoo.confModificare /mnt/etc/portage/repos.conf/gentoo.conf, aggiungere linee che mancano:
[DEFAULT]
sync-allow-hardlinks = yes
[gentoo]
location = /var/db/repos/gentoo
sync-type = webrsync
#sync-type = rsyncmount --rbind /dev dev
mount --rbind /proc proc
mount --rbind /sys sys
mount --make-rslave dev
mount --make-rslave proc
mount --make-rslave sys chroot ${MOUNT} /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"emaint sync --autoemerge -av mirrorselect
mirrorselect -i -o >> /etc/portage/make.confvim /etc/portage/repos.conf/gentoo.confmodificare sync-type
[gentoo]
#sync-type = webrsync
sync-type = rsyncRialnciare update
emaint sync --autoelenco completo dei flag supportati può essere trovato con cat /proc/cpuinfo ma dobbiamo installare app-portage/cpuid2cpuflags per trovare quelle usate da gentoo:
emerge -av app-portage/cpuid2cpuflags
echo "*/* $(cpuid2cpuflags)" >> /etc/portage/package.use/00cpuflags mkdir -p -v /etc/portage/package.use
mkdir -p -v /etc/portage/package.accept_keywords
mkdir -p -v /etc/portage/package.unmaske i file
touch /etc/portage/package.use/zzz_via_autounmask
touch /etc/portage/package.accept_keywords/zzz_via_autounmask
touch /etc/portage/package.unmask/zzz_via_autounmaskTroovare architettura CPU
gcc -c -Q -march=native --help=target | grep marchaggiungere ai common flag anche queste -fstack-protector-strong -Wl,-z,relro -Wl,-z,now
source /etc/profile && env-update
emerge --ask --update --deep --newuse --with-bdeps=y @world una volta finito eliminare i pacchetti vecchi con
emerge -av --depclean
eclean -d distfilesemerge -av gentoolkitdisabilitare IPV5
euse -D ipveselect profile list
eselect profile set 5echo "sys-kernel/gentoo-kernel-bin -initramfs" > /etc/portage/package.use/gentoo-kernel-bin
echo "sys-fs/zfs dist-kernel" > /etc/portage/package.use/zfs
echo "sys-fs/zfs-kmod dist-kernel" >> /etc/portage/package.use/zfs
echo "sys-boot/grub libzfs" > /etc/portage/package.use/grub
echo "app-text/ghostscript-gpl -l10n_zh-CN" > /etc/portage/package.use/ghostscript-gpl
echo "sys-fs/zfs ~amd64" > /etc/portage/package.accept_keywords/zfs
echo "=sys-fs/zfs-9999 **" >> /etc/portage/package.accept_keywords/zfs
echo "sys-fs/zfs-kmod ~amd64" >> /etc/portage/package.accept_keywords/zfs
echo "=sys-fs/zfs-kmod-9999 **" >> /etc/portage/package.accept_keywords/zfs
echo "options zfs zfs_arc_min=268435456" > /etc/modprobe.d/zfs.conf
echo "options zfs zfs_arc_max=536870912" >> /etc/modprobe.d/zfs.confemerge -av sys-kernel/linux-firmware sys-kernel/genkernel sys-kernel/gentoo-kernel-bin zfs zfs-kmodAggiungi queste righe al /etc/genkernel.conf
# cat >> /etc/genkernel.conf
BOOTLOADER="no" # add grub2 for BIOS
INSTALL="yes"
MENUCONFIG="no"
CLEAN="yes"
KEYMAP="yes"
SAVE_CONFIG="yes"
MOUNTBOOT="no"
MRPROPER="no"
ZFS="yes"
MODULEREBUILD="yes"rm -rf /etc/hostid && zgenhostid
vi /etc/genkernel.conf
genkernel initramfs --compress-initramfs --kernel-config=/usr/src/linux/.config --makeopts=-j$(nproc)Aggiungi il supporto Uefi per systemd
euse -p sys-apps/systemd -E gnuefi
emerge -av sys-apps/systemd efivarCopiare il kernel e initram in esp
cp /boot/vmlinuz* /efi/vmlinuz
cp /boot/initramfs-*.img /efi/initramfsCreare loader per Gentoo
# cat > /efi/loader/loader.conf
default gentoo
timeout 3
editor 0Aggiungere le voci corrispondenti
# cat > /efi/loader/entries/gentoo.conf
title Gentoo Linux
linux /vmlinuz
initrd /initramfs
options root=ZFS=rpool/ROOT/gentoo init=/usr/lib/systemd/systemd dozfs keymap=itinstallare il BOOTLOADER
bootctl --path /efi install
bootctl --path /efi update
```shell
## 4. Configurazione di Sistema
### 4.1 Configurazione della localizzazione
```shell
eselect locale list | grep -i en_us
eselect locale set 253
loadkey it
echo "KEYMAP=it" > /etc/vconsole.conf
ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime
hwclock --systohc
env-update && source /etc/profile && export PS1="(chroot) $PS1"4.2 Configurare fstab (qui usiamo genfstab, uno strumento di archlinux, per generare automaticamente fstab).
git clone https://github.com/26hz/install-tools.git
cd install-tools
./genfstab -U -p / >> /etc/fstabcontrollare la fat partition /boot/efi
vim /etc/fstab
UUID=<UUID efi partition> /boot/efi vfat noauto,rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2emerge -av doas cronie eix zsh lsd gentoolkit dosfstools parted neofetch ntfs3g bpytop iwd dhcpcd
systemctl enable zfs.target
systemctl enable zfs-import-cache
systemctl enable zfs-mount
systemctl enable zfs-import.targetuseradd -mG users,wheel,portage,usb,input,audio,video,sys,adm,tty,disk,lp,mem,news,console,cdrom,sshd,kvm,render,lpadmin,cron,crontab -s /bin/zsh matteo
passwd matteo
echo "permit keepenv nopass :wheel" > /etc/doas.confzfs snapshot zroot/ROOT/default@installexit
umount /mnt/gentoo/boot
umount -Rl /mnt/gentoo/{dev,proc,sys,run,}
swapoff /dev/zvol/zroot/SWAP
zfs umount -a
zpool export -f zroot
rebootvim /etc/systemd/system/[email protected][Unit]
Description=Run scrub for ZFS pool %I
[Service]
Type=simple
ExecStart=/sbin/zpool scrub %iSchedulare scrub systemd
vim /etc/systemd/system/[email protected][Unit]
Description=Run weekly scrub for ZFS pool %I
[Timer]
OnCalendar=Wed *-*-* 15:00:00
[Install]
WantedBy=timers.targetAbilitare
systemctl enable [email protected]
systemctl start [email protected]