This commit is contained in:
Rorik Star Platinum 2025-12-28 19:00:03 +03:00
parent 48f640b55d
commit 440a2fa01f
28 changed files with 1849 additions and 96 deletions

View file

@ -0,0 +1,303 @@
# 1) GPT + ESP + root
parted -a optimal /dev/vda mklabel gpt
parted /dev/vda mkpart ESP fat32 1MiB 513MiB
parted /dev/vda set 1 esp on
parted -a optimal /dev/vda mkpart rootfs ext4 513MiB 100%
# 2) На всякий случай перечитать таблицу (обычно хватает одного)
partprobe /dev/vda # перечитать partition table без ребута [web:137]
# (альтернатива, если вдруг /dev/vda2 не появился)
# partx -u /dev/vda && udevadm settle
# 3) ФС
mkfs.fat -F 32 /dev/vda1
mkfs.ext4 -L gentoo-root /dev/vda2
# 4) Монтирование
mount /dev/vda2 /mnt/gentoo
mkdir -p /mnt/gentoo/boot/efi
mount /dev/vda1 /mnt/gentoo/boot/efi
cd /mnt/gentoo
# 5) stage3
Да: **сначала нужно скачать stage3**, а уже потом выполнять `tar xpvf ...` (в каталоге `/mnt/gentoo`). Команда `tar ...` просто распаковывает tarball stage3 в будущий rootfs, после этого следующий шаг — подготовить `make.conf`, смонтировать `/proc /sys /dev /run` и зайти в chroot (там уже будет `emerge`).[1][2]
## Шаг 1 — скачать stage3 (OpenRC, headless)
Ты сейчас в `/mnt/gentoo`, это правильно. Дальше:
```sh
cd /mnt/gentoo
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-openrc/latest-stage3-amd64-openrc.txt
cat latest-stage3-amd64-openrc.txt
```
В этом файле будет имя актуального tarballа (строка с `stage3-amd64-openrc-...tar.xz`).[1]
Скачать сам tarball (подставь имя из файла):
```sh
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-openrc/<ИМЯ_ТАРБОЛЛА>.tar.xz
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-openrc/<ИМЯ_ТАРБОЛЛА>.tar.xz.DIGESTS
```
## Шаг 2 — распаковать stage3
Теперь да, выполняешь:
```sh
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
```
Эта команда — стандартный способ распаковки stage3 с сохранением xattrs и владельцев.[3][1]
## Шаг 3 — базовая подготовка до chroot
1) DNS в будущую систему:
```sh
cp -L /etc/resolv.conf /mnt/gentoo/etc/
```
2) (Опционально, но обычно делают сразу) `make.conf` пока хотя бы с `MAKEOPTS`:
```sh
nano -w /mnt/gentoo/etc/portage/make.conf
# например:
# MAKEOPTS="-j6"
```
`/etc/portage/make.conf` — основной файл глобальных настроек Portage.[4]
## Шаг 4 — смонтировать псевдо-ФС и зайти в chroot
```sh
mount -t 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
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"
```
Такой набор монтирований — типовой для корректной работы внутри chroot (установка пакетов, udev-сокеты и т.д.).[2]
Скажи, на каком шаге остановишься (скачал/распаковал stage3 или уже вошёл в chroot) — и дальше дам точный минимальный набор команд: профиль, `emerge --sync`, базовые пакеты (dhcpcd+netifrc+openssh), kernel + GRUB под UEFI.
[1](https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-openrc/)
[2](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_AMD64/Installation/Base/de.html)
[3](https://www.reddit.com/r/Gentoo/comments/z3lmdq/first_time_installing_gentoo/)
[4](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/etc/portage/make.html)
[5](https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-nomultilib-openrc/)
[6](https://gentoo.osuosl.org/releases/amd64/autobuilds/current-stage3-amd64-desktop-openrc/)
[7](https://mirrors.mit.edu/gentoo-distfiles/releases/amd64/autobuilds/current-stage3-amd64-openrc/)
[8](https://mirror.telepoint.bg/gentoo/releases/amd64/autobuilds/current-stage3-amd64-desktop-openrc/)
[9](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_AMD64/Installation/Base/ja.html)
[10](http://gentoo.osuosl.org/releases/amd64/autobuilds/)
[11](https://www.youtube.com/watch?v=HwY0IMfiiTA)
[12](http://www.mirrorservice.org/sites/distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-openrc/)
[13](https://www.reddit.com/r/linuxquestions/comments/16lublb/issue_w_gentoo_ab_halfway_through_installation/)
[14](https://www.reddit.com/r/Gentoo/comments/1acnqma/recover_from_gentoo_installation_mistake/)
[15](http://mirrors.lug.mtu.edu/gentoo/releases/amd64/autobuilds/)
[16](https://soso-cod3v.tistory.com/168)
[17](https://stephane-cheatsheets.readthedocs.io/en/latest/distros/gentoo-based/gentoo_installation/)
[18](https://mirror.kumi.systems/gentoo/releases/amd64/autobuilds/current-stage3-amd64-desktop-openrc/)
[19](https://www.reddit.com/r/linux/comments/ndvutp/tutorial_encrypted_gentoo_installation_guide/)
[20](https://www.scribd.com/document/86619356/Gentoo-Linux-AMD64-Handbook)
[21](http://ftp.riken.jp/Linux/gentoo/releases/amd64/autobuilds/)
Ты уже в chroot, значит дальше цель — чтобы система **первый раз загрузилась** и ты смог зайти по `ssh -p 2222 root@127.0.0.1`.
## Portage sync (репозиторий)
Сначала создай конфиг основного репозитория и синхронизируй дерево ebuildов:[1]
```sh
mkdir -p /etc/portage/repos.conf
cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf
emerge --sync
```
(Если `cp` ругнётся, покажи вывод `ls -la /usr/share/portage/config/` — подберём правильный путь.)
## Минимальная “голова” системы
Дальше быстрые обязательные настройки (без них можно, но потом больнее дебажить):
```sh
echo "Europe/Moscow" > /etc/timezone
emerge --config sys-libs/timezone-data
echo "gentoo-vm" > /etc/hostname
# локали (пример)
nano -w /etc/locale.gen # раскомментируй en_US.UTF-8 UTF-8 (и при желании ru_RU.UTF-8)
locale-gen
eselect locale list
eselect locale set <номер>
env-update && source /etc/profile
```
## Сеть + SSH на OpenRC (под твой SLiRP NAT)
Поставь минимальный сетевой стек и SSH:
```sh
emerge --ask net-misc/netifrc net-misc/dhcpcd net-misc/openssh
```
Настрой DHCP на интерфейсе (имя смотри так: `ip link`, обычно будет `enp0s1`/`eth0`):
```sh
IF=enp0s1 # поменяй на своё
ln -s /etc/init.d/net.lo /etc/init.d/net.${IF}
echo "config_${IF}=\"dhcp\"" >> /etc/conf.d/net
rc-update add net.${IF} default
rc-update add sshd default
```
Формат `config_<iface>="dhcp"` — это штатная схема netifrc.[2]
Если вообще ничего не прописывать, netifrc часто и так поднимает DHCP на интерфейсах без явной конфигурации, но лучше зафиксировать явно, чтобы было предсказуемо.[3]
## Ядро + GRUB (UEFI)
Тут два пути:
1) Самый быстрый для “headless и без приключений”: поставить готовое ядро (`sys-kernel/gentoo-kernel-bin`) и дальше GRUB.
2) Если хочешь кастом/zen — это отдельный длинный шаг, лучше после первого успешного SSH.
GRUB ставится по handbook примерно так (у тебя ESP смонтирован в `/boot/efi`):[4]
```sh
emerge --ask sys-boot/grub sys-boot/efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Gentoo
emerge --ask sys-kernel/gentoo-kernel-bin
// возможно придется обновить конфиг: etc-update
grub-mkconfig -o /boot/grub/grub.cfg
```
## fstab (чтобы монтировалось после ребута)
Сгенерируй UUID и пропиши:
```sh
blkid
nano -w /etc/fstab
```
(Я вставил что то вроде этого)
```
# /etc/fstab: static file system information.
#
# See the manpage fstab(5) for more information.
#
# NOTE: The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3
# filesystems. This just tells the kernel to use the ext4 driver.
#
# NOTE: You can use full paths to devices like /dev/sda3, but it is often
# more reliable to use filesystem labels or UUIDs. See your filesystem
# documentation for details on setting a label. To obtain the UUID, use
# the blkid(8) command.
# <fs> <mountpoint> <type> <opts> <dump> <pass>
#LABEL=boot /boot ext4 defaults 1 2
#UUID=58e72203-57d1-4497-81ad-97655bd56494 / xfs defaults 0 1
#LABEL=swap none swap sw 0 0
#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
UUID=3733ce80-bdb7-477d-a0bf-7a70122fa071 / ext4 defaults 0 1
UUID=66FA-9048 /boot/efi vfat umask=0077 0 2
```
а потом:
```
mount -a
findmnt /boot/efi
```
Минимально:
- root (`/dev/vda2`) → `/` ext4
- ESP (`/dev/vda1`) → `/boot/efi` vfat
## Финиш: пароль, выход, ребут
```sh
useradd -m -G wheel -s /bin/bash <user>
passwd <user>
emerge --ask app-admin/sudo
visudo
```
В `visudo` раскомментируй строку (или добавь), чтобы wheel мог sudo:
`%wheel ALL=(ALL:ALL) ALL`
```
passwd root
exit
umount -l /mnt/gentoo/dev{/shm,/pts,}
cd /
umount -R /mnt/gentoo
reboot
```
Сейчас напиши вывод двух команд из chroot:
```sh
ls /sys/firmware/efi
ip link
```
По ним скажу точно: нужно ли отдельно монтировать `efivarfs`, и как именно называется твой сетевой интерфейс для `net.<iface>`.
[1](https://github.com/dudekmichal/gentoo/blob/master/readme.md)
[2](https://github.com/gentoo/netifrc/blob/master/doc/net.example.Linux.in)
[3](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_PPC/Full/Networking/zh-cn.html)
[4](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_AMD64/Installation/Bootloader/en.html)
[5](https://github.com/sergibarroso/gentoo_install)
[6](https://www.reddit.com/r/Gentoo/comments/17sztdp/how_to_speed_up_emerge_sync_synchronizing_with/)
[7](https://github.com/dudekmichal/gentoo)
[8](https://www.reddit.com/r/Gentoo/comments/9ua7lm/question_about_fully_amd64_installation/)
[9](https://blog.csdn.net/qq_40738478/article/details/129191358)
[10](https://www.reddit.com/r/Gentoo/comments/ffim09/installation_cannot_upgrade_portage_update_world/)
[11](https://gist.github.com/CDA0/4b1c2ee20cb68bdd4e72fb452fde9941)
[12](https://www.reddit.com/r/Gentoo/comments/ha2v6q/how_does_portage_and_its_config_files_work/)
[13](https://www.reddit.com/r/Gentoo/comments/1hj03zd/network_address_assigned_and_internet_connection/)
[14](https://www.reddit.com/r/Gentoo/comments/k7zpm3/grubinstall_error/)
[15](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/etc/portage/repos.conf/it.html)
[16](https://wiki.archlinux.org/title/GRUB)
[17](https://www.reddit.com/r/Gentoo/comments/x0ke6i/problem_with_portage/)
[18](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Netifrc.html)
[19](https://www.reddit.com/r/Gentoo/comments/dfqah8/grub_efi_error_handbook/)
[20](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_AMD64/Full/Installation.html)
# timezone
`echo "Europe/Moscow" | sudo tee /etc/timezone`[](https://www.semirocket.science/noteblog/2023/03/gentoo-how-to-change-time-zone/)-
- `sudo emerge --config sys-libs/timezone-data`
отключить hwlock:
/etc/conf.d/hwlock:
```
# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as
# Greenwich Mean Time). If that clock is set to the local time, then
# set CLOCK to "local". Note that if you dual boot with Windows, then
# you should set it to "local".
clock="UTC"
# If you want the hwclock script to set the system time (software clock)
# to match the current hardware clock during bootup, leave this
# commented out.
# However, you can set this to "NO" if you are running a modern kernel
# and using NTP to synchronize your system clock.
clock_hctosys="NO"
# If you do not want to set the hardware clock to the current system
# time (software clock) during shutdown, set this to no.
#clock_systohc="NO"
# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here. Alpha users may wish to use --arc or --srm here.
clock_args=""
```
# docker в группу (чтобы не писать sudo)
`sudo usermod -aG docker $USER`
# как я hurl качал (или keywords amd64 и ~amd64)
```bash
sudo mkdir -p /etc/portage/package.accept_keywords
echo "net-misc/hurl ~amd64" | sudo tee /etc/portage/package.accept_keywords/hurl
sudo emerge -av net-misc/hurl
```