Gentoo Linux - Academy
Konfiguracja sieci
Ręczne ustawienie
ip address add 192.168.0.2/24 dev enp1s0
ip route add default via 192.168.0.1
/etc/resolv.conf
nameserver 9.9.9.9
nameserver 149.112.112.112
Serwer SSH
/etc/init.d/sshd start
Ustawienie hasa dla root'a
passwd
Przygotowanie dysku
fdisk /dev/sda
Widok podstawowy przed podziałem
Command (m for help): p
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fe4ee5f
Command (m for help):
Zakładanie partycji na /boot
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):
First sector (2048-16777215, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-16777215, default 16777215): +256M
Created a new partition 1 of type 'Linux' and of size 256 MiB.
Zakładanie partycji na SWAP
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (526336-16777215, default 526336):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (526336-16777215, default 16777215): +1G
Created a new partition 2 of type 'Linux' and of size 1 GiB.
Ustawienie typu partycji przeznaczonej na SWAP
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code or alias (type L to list all): l
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Zakładanie partycji na /
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (3,4, default 3):
First sector (2623488-16777215, default 2623488):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2623488-16777215, default 16777215):
Created a new partition 3 of type 'Linux' and of size 6.7 GiB.
Wyświetlanie tablicy partycji
Command (m for help): p
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fe4ee5f
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 526335 524288 256M 83 Linux
/dev/sda2 526336 2623487 2097152 1G 82 Linux swap / Solaris
/dev/sda3 2623488 16777215 14153728 6.7G 83 Linux
Zapis ustawień
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Zakładanie systemu plików sda1
mkfs.ext2 /dev/sda1
Uruchamianie partycji SWAPsda2
mkswap /dev/sda2
swapon /dev/sda2
Zakładanie systemu plików sda3
mkfs.ext3 /dev/sda3
Montowanie partycji
mount /dev/sda3 /mnt/gentoo/
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot/
Instalowanie plików instalacyjnych Gentoo
Ustawienie porawnej daty i godziny
date
Przygotowanie plików
Wejdź do katalogu
cd /mnt/gentoo/
Pobierz stage3
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/20250429T205022Z/stage3-amd64-openrc-20250429T205022Z.tar.xz
Wyodrębnij archiwum
tar xpvf stage3-amd64-openrc-20250429T205022Z.tar.xz
Ewentualna konfiguracja
nano /mnt/gentoo/etc/portage/make.conf
Instalowanie podstawowego systemu Gentoo
Kopiowanie informacji o DNS
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
Montowanie potrzebnych systemów plików
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
mount --make-slave /mnt/gentoo/run
Przechodzenie do nowego środowiska
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"
Montowanie partycji /boot do nowego systemu
mount /dev/sda1 /boot
Konfiguracja Portage
Aktualizacja
emerge --sync
Wybór profilu
eselect profile list
Timezone
ls -l /usr/share/zoneinfo/Europe/
ln -sf ../usr/share/zoneinfo/Europe/Warsaw /etc/localtime
Generowanie lokalizacji
nano /etc/locale.gen
locale-gen
eselect locale list
eselect locale set 2
Konfiguracja jądra Linuksa
Zainstaluj Python 3.12 (3.13 eksperymentalny i nie wspierany przez genkernel)
emerge --ask dev-lang/python:3.12
Ustawienie PYTHON_SINGLE_TARGET dla genkernel
echo "sys-kernel/genkernel python_single_target_python3_12" >> /etc/portage/package.use/genkernel
Zmaskowany pakiet sys-kernel/linux-firmware
mkdir -p /etc/portage/package.license
echo "sys-kernel/linux-firmware linux-fw-redistributable" >> /etc/portage/package.license/linux-firmware
zz-autounmask wymaga aktualizacji
etc-update
Ustaw dokładnie jedną wersję PYTHON_SINGLE_TARGET
mkdir -p /etc/portage/package.use
echo "sys-kernel/genkernel python_single_target_python3_12 -python_single_target_python3_13 -python_single_target_python3_11" > /etc/portage/package.use/genkernel
Instalacja KERNEL dla użytkowników GRUB
emerge --ask sys-kernel/genkernel
Upgrading and cleaning up
emerge --depclean
Installing the kernel sources
emerge --ask sys-kernel/gentoo-sources
Lista dostępnych KERNELi
eselect kernel list
eselect kernel set 1
ls -l /usr/src/linux
uruchom genkernel
genkernel all
Wynik:
genkernel all
* Gentoo Linux Genkernel; Version 4.3.16
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: all
* Working with Linux kernel 6.12.21-gentoo for x86_64
* Using kernel config file '/usr/share/genkernel/arch/x86_64/generated-config' ...
*
* Note: The version above is subject to change (depends on config and status of kernel sources).
* kernel: >> Initializing ...
* >> Running 'make mrproper' ...
* >> Running 'make oldconfig' ...
* >> Re-running 'make oldconfig' due to changed kernel options ...
* >> Kernel version has changed (probably due to config change) since genkernel start:
* We are now building Linux kernel 6.12.21-gentoo-x86_64 for x86_64 ...
* >> Compiling 6.12.21-gentoo-x86_64 bzImage ...
* >> Compiling 6.12.21-gentoo-x86_64 modules ...
* >> Installing 6.12.21-gentoo-x86_64 modules (and stripping) ...
* >> Generating module dependency data ...
* >> Compiling out-of-tree module(s) ...
* >> Saving config of successful build to '/etc/kernels/kernel-config-6.12.21-gentoo-x86_64' ...
* initramfs: >> Initializing ...
* >> Appending devices cpio data ...
* >> Appending base_layout cpio data ...
* >> Appending util-linux cpio data ...
* >> Appending eudev cpio data ...
* >> Appending auxiliary cpio data ...
* >> Appending busybox cpio data ...
* >> Appending modprobed cpio data ...
* >> Appending modules cpio data ...
* >> Deduping cpio ...
* >> Pre-generating initramfs' /etc/ld.so.cache ...
* >> Compressing cpio data (.xz) ...
* Kernel compiled successfully!
*
* --no-bootloader set; Skipping bootloader update ...
*
* Required kernel parameter:
*
* root=/dev/$ROOT
*
* Where $ROOT is the device node for your root partition as the
* one specified in /etc/fstab
* If you require Genkernel's hardware detection features, you MUST
* tell your bootloader to use the provided initramfs file '/boot/initramfs-6.12.21-gentoo-x86_64.img'.
* WARNING... WARNING... WARNING...
* Additional kernel parameters that *may* be required to boot properly:
* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
*
* Make sure you have the latest ~arch genkernel before reporting bugs.
Konfiguracja systemu
fstab
nano /etc/fstab
/dev/sda1 /boot ext2 defaults 0 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext3 defaults,noatime 0 1
Instalowanie narzędzi systemowych
Konfiguracja systemu rozruchowego
emerge GRUB
emerge --ask --verbose sys-boot/grub
instalacja GRUB na sda
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
Ustawienie hasła !!!
passwd