Cobra MK III
Můj nový počítač
2020.05.10 - Cobra-Mk3 - instalace
2020.05.10 05:43:19 Cobra-Mk3 gentoo Gilhad

1   UEFI

  • UEFI BIOS
    • DOCP - Profile #1 (RAM=3600 MHz)
    • CSM
      • Compatibility Support Module - enabled, UEFI only, no network
    • BOOT
      • Fast - disabled
      • a pár podobných

2   Boot

Boot z Gentoo USB

passwd
/etc/init.d/sshd start
/etc/init.d/ntp-client start

3   Vzdálená instalace - příprava disku a stažení základního systému

3.1   Partišny

Login z venku a podle https://wiki.gentoo.org/wiki/Handbook:AMD64

GPT
určitě, budu používat UEFI pro spoustu systémů
/dev/nvme0n1
tady bude nový systém, (ADATA /dev/sda je instalační USB flash)
livecd ~ # parted -l
...

Error: /dev/nvme0n1: unrecognised disk label
Model: Unknown (unknown)
Disk /dev/nvme0n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

livecd ~ # parted -a optimal /dev/nvme0n1
GNU Parted 3.2
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) q

Parted je nějaký komplikovaný, fakt nechci počítat sektory ručně. Použiju raději fdisk (což jsem asi měl udělat hned)

livecd ~ # fdisk  /dev/nvme0n1

Welcome to fdisk (util-linux 2.33.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): g
Created a new GPT disklabel (GUID: 37A33C18-76C9-8C46-9708-385EE791F953).

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

Created a new partition 1 of type 'Linux filesystem' and of size 100 MiB.

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

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

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

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

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

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

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

Command (m for help): n
Partition number (4-128, default 4):
First sector (209922048-1953525134, default 209922048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (209922048-1953525134, default 1953525134): +50G

Created a new partition 4 of type 'Linux filesystem' and of size 50 GiB.

Command (m for help): p
Disk /dev/nvme0n1: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Viper M.2 VP4100
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 37A33C18-76C9-8C46-9708-385EE791F953

Device             Start       End   Sectors  Size Type
/dev/nvme0n1p1      2048    206847    204800  100M EFI System
/dev/nvme0n1p2    206848 105064447 104857600   50G Linux swap
/dev/nvme0n1p3 105064448 209922047 104857600   50G Linux filesystem
/dev/nvme0n1p4 209922048 314779647 104857600   50G Linux filesystem

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

Takže mám potřebné partišny, teď je ješte pojmenuju v partedu z CLI (NVM-SYSTEM slouží pro obecnou správu disku, NVM-SYSBCK je jeho záložní kopie - takže bootem z jednoho mám druhý plně k dispozici pro zkopírování na nově vytvářenou instalaci, bez všech pseudosystémů a otevřených souborů)

livecd ~ # parted  /dev/nvme0n1 name 1 EFIboot
livecd ~ # parted  /dev/nvme0n1 name 2 SWAP
livecd ~ # parted  /dev/nvme0n1 name 3 NVM-SYSTEM
livecd ~ # parted  /dev/nvme0n1 name 4 NVM-SYSBCK
livecd ~ # parted  /dev/nvme0n1 print
Model: Unknown (unknown)
Disk /dev/nvme0n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name        Flags
 1      1049kB  106MB   105MB                EFIboot     boot, esp
 2      106MB   53.8GB  53.7GB               SWAP
 3      53.8GB  107GB   53.7GB               NVM-SYSTEM
 4      107GB   161GB   53.7GB               NVM-SYSBCK

3.2   Formátování

Otázka na tělo, které fs potřebujeme? U nekritických bych volil ext4, ale je tam problém, když vypadne napájení a data jsou ještě v cache (a ext4 je tam drží "dlouho" - navíc rozbíjí ideu jurnálu a ordered z ext3, kdy soubor byl buď ve staré nebo nové verzi, ale ne "něco mezi tím" = mv fname.new fname už není atomické, když v dohledné době vypadne napájení.) Na druhou stranu je ext4 rychlejší, míň fragmentuje a míň "vyklepává na disk", protože víc cachuje. Na serveru (a hlavně na boxech) bych volil ext3 a ordered, na domácím počítači asi risknu ext4.

livecd ~ # mkfs.fat -F 32 /dev/nvme0n1p1
mkfs.fat 4.1 (2017.01.24)

livecd ~ # mkswap /dev/nvme0n1p2
Setting up swapspace version 1, size = 50 GiB (53687087104 bytes)
no label, UUID=c3e1c088-ee23-450f-b897-2886a370cad2

livecd ~ # mkfs.ext4 -L NVM-SYSTEM /dev/nvme0n1p3
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 13107200 4k blocks and 3276800 inodes
Filesystem UUID: c82837c8-4642-43ea-b148-072f49ec39fe
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

livecd ~ # mkfs.ext4 -L NVM-SYSBCK /dev/nvme0n1p4
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 13107200 4k blocks and 3276800 inodes
Filesystem UUID: edb20f6d-0fdb-4733-b52b-561a961bfefe
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

livecd ~ # swapon /dev/nvme0n1p2

livecd ~ # free -h
              total        used        free      shared  buff/cache   available
Mem:           31Gi       128Mi        30Gi        62Mi       290Mi        30Gi
Swap:          49Gi          0B        49Gi

livecd ~ # parted  /dev/nvme0n1 print
Model: Unknown (unknown)
Disk /dev/nvme0n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name        Flags
 1      1049kB  106MB   105MB   fat32           EFIboot     boot, esp
 2      106MB   53.8GB  53.7GB  linux-swap(v1)  SWAP
 3      53.8GB  107GB   53.7GB  ext3            NVM-SYSTEM
 4      107GB   161GB   53.7GB  ext3            NVM-SYSBCK

3.3   Mounting the root partition

livecd ~ # mount /dev/nvme0n1p3 /mnt/gentoo/

3.4   Downloading the stage tarball

livecd ~ # cd /mnt/gentoo
livecd /mnt/gentoo # links https://www.gentoo.org/downloads/mirrors/
### or
livecd /mnt/gentoo # wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20200422T214502Z/stage3-amd64-20200422T214502Z.tar.xz
### or
livecd /mnt/gentoo # wget https://mirror.bytemark.co.uk/gentoo//releases/amd64/autobuilds/20200422T214502Z/stage3-amd64-20200422T214502Z.tar.xz
livecd /mnt/gentoo # wget https://mirror.bytemark.co.uk/gentoo//releases/amd64/autobuilds/20200422T214502Z/stage3-amd64-20200422T214502Z.tar.xz.CONTENTS
livecd /mnt/gentoo # wget https://mirror.bytemark.co.uk/gentoo//releases/amd64/autobuilds/20200422T214502Z/stage3-amd64-20200422T214502Z.tar.xz.DIGESTS
livecd /mnt/gentoo # wget https://mirror.bytemark.co.uk/gentoo//releases/amd64/autobuilds/20200422T214502Z/stage3-amd64-20200422T214502Z.tar.xz.DIGESTS.asc
### anyway:
livecd /mnt/gentoo # sha512sum stage3-amd64-*.tar.xz
637f43fac14de5b301ddda84de1ee095bbdb45002c9486f7b9eb37028f28ad181f5521b0e960b1b5c07ba527f7707f1e2894feb1f3e2ad03779e44d772aeffc8  stage3-amd64-20200422T214502Z.tar.xz
livecd /mnt/gentoo # grep 637f43fac14de5b301ddda84de1ee095bbdb45002c9486f7b9eb37028f28ad181f5521b0e960b1b5c07ba527f7707f1e2894feb1f3e2ad03779e44d772aeffc8 stage3-amd64*.DIGESTS
637f43fac14de5b301ddda84de1ee095bbdb45002c9486f7b9eb37028f28ad181f5521b0e960b1b5c07ba527f7707f1e2894feb1f3e2ad03779e44d772aeffc8  stage3-amd64-20200422T214502Z.tar.xz
### or openssl dgst -r -whirlpool stage3-amd64-*.tar.xz
### dtto stage3-amd64-*.tar.xz.CONTENTS
### gpg --verify stage3-amd64-*.xz{.DIGESTS.asc,}
livecd /mnt/gentoo # tar xpf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner

3.5   Configuring compile options !!! bomb

Předně využiju možnosti podadresářů v /etcp/portage a to i pro make.conf, následně budu dávat konfigurace jednotlivých "hlavních programů" do souborů s odpovídajícími jmény. Konfigurace si dám sem už předem, aby se různé USE a podobně neměnily průběžně a pak nebyly různé verze programů a knihoven a nemuselo se toho kompilovat pořád dokola - stejně to nakonec projedu s --empty-tree pro jistotu, ale i tak si nastavím spoustu věcí "do foroty"

livecd /mnt/gentoo # mv etc/portage/make.conf etc/portage/00-make.conf
livecd /mnt/gentoo # mkdir etc/portage/make.conf
livecd /mnt/gentoo # mv etc/portage/00-make.conf etc/portage/make.conf

livecd /mnt/gentoo # cat etc/portage/make.conf/00-make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C

PORTDIR a spol vedou jinam, než jsem byl zvyklý, ale pro víc overlayů to dává lepší smysl. Jenom přidáme MAKEOPTS (mám 24 jader, dám aspoň 26, ať jsou nějaká navíc, když se čeká na I/O, zámky a podobně).

livecd /mnt/gentoo # echo 'MAKEOPTS="-j26 "'>>etc/portage/make.conf/00-make.conf
livecd /mnt/gentoo # echo 'FEATURES="${FEATURES} parallel-fetch"'>>etc/portage/make.conf/00-make.conf

3.6   Selecting mirrors

livecd /mnt/gentoo # mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf/01-mirrors
### or
livecd /mnt/gentoo # echo 'GENTOO_MIRRORS="http://ftp.fi.muni.cz/pub/linux/gentoo/ http://gentoo.ussg.indiana.edu/ http://gentoo.cs.utah.edu/" >> /mnt/gentoo/etc/portage/make.conf/01-mirrors

3.7   Oblibene USE

cat >>/etc/portage/make.conf/02-USE <<EOF
USE="\$USE -xdg"# je to zrudnost
USE="\$USE -zeroconf"# je to zrudnost
USE="\$USE -subversion"# nechci ani v gitu
USE="\$USE -ipv6"# nepouzivame
USE="\$USE mysql"# nase hlavni db
USE="\$USE -berkleydb"# nepouzivame
USE="\$USE webp"# protoze se to siri jak mor
USE="\$USE X"# Xka asi chceme
USE="\$USE -libglvnd"# asi nechceme
USE="\$USE -pulseaudio"# nechci pulseaudio
USE="\$USE mp3 vorbis"
USE="\$USE lm-sensors"
EOF

cat >>/etc/portage/make.conf/debianutils <<EOF
USE="\$USE -installkernel"      # nechci instalivate kernel prez "make install", kopiruju bzImage rucne bez magie
USE="\$USE logrotate -anacron"  # rotuju prez logrotate, anacron nepouzivam
EOF

3.8   Gentoo ebuild repository

livecd /mnt/gentoo # mkdir --parents /mnt/gentoo/etc/portage/repos.conf
livecd /mnt/gentoo # cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

bomb Bacha, pokud by se měnilo PORTDIR, je potřeba to změnit i tady

3.9   Copy DNS info

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

4   Chrooting

4.1   Mounting the necessary filesystems

mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev

chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"

df -h  /
livecd /mnt/gentoo # mount --types proc /proc /mnt/gentoo/proc
livecd /mnt/gentoo # mount --rbind /sys /mnt/gentoo/sys
livecd /mnt/gentoo # mount --rbind /dev /mnt/gentoo/dev
livecd /mnt/gentoo #
livecd /mnt/gentoo # chroot /mnt/gentoo /bin/bash
livecd / # source /etc/profile
livecd / # export PS1="(chroot) ${PS1}"
(chroot) livecd / #

(chroot) livecd / # df -h  /
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p3   49G  1.6G   45G   4% /

4.2   Updating the Gentoo ebuild repository

(chroot) livecd / # emerge --sync --quiet

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

(chroot) livecd / # eselect news list
News items:
  [1]   N  2016.06.19  L10N USE_EXPAND variable replacing LINGUAS
  [2]   N  2018.08.07  Migration required for OpenSSH with LDAP
  [3]   N  2019.05.23  Change of ACCEPT_LICENSE default
  [4]   N  2020.02.07  Python 2.7 went EOL
  [5]   N  2020.02.20  OpenSSH 8.2_p1 running sshd breakage
  [6]   N  2020.04.22  Python 3.7 to become the default target
(chroot) livecd / # eselect news read

4.3   Choosing the right profile

eselect profile list
#eselect profile set

5   Rebuild @world

@world
je set obsahující world (/var/lib/portage/world), system a profile

Teď by se měl updatnout základní systém, ale protože už jsem nastavil např. X, tak se bude dotahovat těch věcí víc

emerge --ask --verbose --update --deep --newuse @world -q --load-average=50 --jobs=20
### or without limits
emerge --ask --verbose --update --deep --newuse @world -q --load-average --jobs

5.1   Další detaily (timezone, locale, ...)

echo "Europe/Prague" > /etc/timezone
emerge --config sys-libs/timezone-data

echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen
echo "cs_CZ.UTF-8 UTF-8" >>/etc/locale.gen
locale-gen

echo >>/etc/env.d/02locale 'LANG="C"'
echo >>/etc/env.d/90gilhad_xsession 'XSESSION="fluxbox"'
echo >>/etc/env.d/02gilhad_editor 'EDITOR=vim'
echo >>/etc/env.d/02gilhad_locale 'LC_CTYPE=cs_CZ.utf8'
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"

6   Kernel

6.1   GPU

https://wiki.gentoo.org/wiki/AMDGPU a v /etc/portage/savedconfig/sys-kernel/linux-firmware-20200421 jde nastavit, co se má stahovat

mkdir /etc/portage/package.license
echo -e "sys-kernel/linux-firmware\tlinux-fw-redistributable no-source-code" >>/etc/portage/package.license/GPU
emerge -avq sys-kernel/linux-firmware
 * Messages for package sys-kernel/linux-firmware-20200421:

 * Your configuration for sys-kernel/linux-firmware-20200421 has been saved in
 * "/etc/portage/savedconfig/sys-kernel/linux-firmware-20200421" for your editing pleasure.
 * You can edit these files by hand and remerge this package with
 * USE=savedconfig to customise the configuration.
 * You can rename this file/directory to one of the following for
 * its configuration to apply to multiple versions:
 * ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/
 * [${CTARGET}|${CHOST}|""]/${CATEGORY}/[${PF}|${P}|${PN}]
 * If you are only interested in particular firmware files, edit the saved
 * configfile and remove those that you do not want.

echo "x11-drivers/xf86-video-amdgpu udev" >> /etc/portage/package.use/GPU
echo "x11-libs/libdrm video_cards_radeon" >> /etc/portage/package.use/GPU
echo 'VIDEO_CARDS="amdgpu radeonsi"' >>/etc/portage/make.conf/GPU

6.2   UEFI

https://wiki.gentoo.org/wiki/Efibootmgr potřebuje NLS ISO 8859-1 a vypnutý EFI mixed-mode support

emerge -avq sys-boot/efibootmgr
mount | grep efivars # must be RW otherwise try somthing like
# mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars
efibootmgr -v # just list entries for fun :)

6.3   kernel

emerge --ask --verbose --update --deep --newuse  -q --load-average --jobs -N sys-kernel/gentoo-sources sys-apps/pciutils
lspci
ls -al /usr/src/
cd /usr/src/linux
make menuconfig
Nastavení kernelu

Sensor driver: X570 boards (no WMI interface - use nct6775 driver instead)

(root=/dev/nvme0n1p3) Built-in kernel command string - podle skutecne partisny

Processor type and features  --->
  [*] Symmetric multi-processing support
  [ ] Support for extended (non-PC) x86 platforms
  [*] AMD ACPI2Platform devices support
  Processor family (Generic-x86-64)
  [*] Machine Check / overheating reporting
  [ ]   Intel MCE Features
  [*]   AMD MCE Features
  [*] CPU microcode loading support
    [ ]   Intel microcode loading support
    [*]   AMD microcode loading support
  Performance monitoring  --->
     < > Intel ***
     <*> AMD Processor Power Reporting Mechanism
  [*] Multi-core scheduler support
  [ ] Numa Memory Allocation and Scheduler Support
  -*- MTRR (Memory Type Range Register) support
  [*] EFI runtime service support
  [*]   EFI stub support
  [ ]     EFI mixed-mode support
  [*] Built-in kernel command line
  (root=/dev/nvme0n1p3  net.ifnames=0 vga=ask) Built-in kernel command string

Power management and ACPI options  --->
  CPU Frequency scaling  --->
    Default CPUFreq governor (ondemand)  --->
    <*>   ACPI Processor P-States driver
    <*>   AMD frequency sensitivity feedback powersave bias

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

Binary Emulations  --->
   [*] IA32 Emulation

Device Drivers --->
  NVME Support  --->
    <*> NVM Express block device
  I2C support  --->
    <*>   I2C device interface
    I2C Hardware Bus support  --->
      <M> AMD ***
      < > Intel ***
  Graphics support  --->
    <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  --->
      [*]   Enable legacy fbdev support for your modesetting driver
    < > ATI Radeon
    <*> AMD GPU
    [ ]   Enable amdgpu support for SI parts
    [ ]   Enable amdgpu support for CIK parts
    ACP (Audio CoProcessor) Configuration  --->
      [ ] Enable AMD Audio CoProcessor IP support
      Display Engine Configuration  --->
        [*] AMD DC - Enable new display engine
        [*] DCN 2.0 family
    < > Intel 8xx/9xx/G3x/G4x/HD Graphics
     Console display driver support  --->
       (160) Initial number of console screen columns (def 80)
       (64) Initial number of console screen rows (def 25)
  <*> Sound card support  --->
    <*>   Advanced Linux Sound Architecture  --->
      HD-Audio  --->
        <*> Build Realtek HD-audio codec support
      (2048) Pre-allocated buffer size for HD-audio driver (def 64)
      [ ]   USB sound devices  ----
      [ ]   PCMCIA sound devices  ----
      < >   ALSA for SoC audio support  ----
      [ ]   X86 sound devices  ----
  Generic Driver Options --->
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs
    Firmware loader  --->
      Build named firmware blobs into the kernel binary
        amdgpu/navi10_asd.bin amdgpu/navi10_ce.bin amdgpu/navi10_gpu_info.bin amdgpu/navi10_me.bin amdgpu/navi10_mec2.bin amdgpu/navi10_mec.bin amdgpu/navi10_pfp.bin amdgpu/navi10_rlc.bin amdgpu/navi10_sdma1.bin amdgpu/navi10_sdma.bin amdgpu/navi10_smc.bin amdgpu/navi10_sos.bin amdgpu/navi10_vcn.bin
      (/lib/firmware) Firmware blobs root directory
  Hardware Monitoring support --->
     <*>   AMD Family 10h+ temperature sensor
     <*>   Nuvoton NCT6775F and compatibles
  Input device support  --->
    <*>   Mouse interface
    <*>   Joystick interface
  HID support  --->
    -*- HID bus support
    <*>   Generic HID driver
      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
  [*] IOMMU Hardware Support  --->
    [*]   AMD IOMMU support
    <*>     AMD IOMMU Version 2 driver
  [ ] X86 Platform Specific Device Drivers  ----

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

File systems --->
  Pseudo Filesystems --->
      [*] /proc file system support
      [*] Tmpfs virtual memory file system support (former shm fs)
  Native Language support --->
      [*] NLS ISO 8859-1  (Latin 1; Western European Languages)

Otázka na tělo, které fs potřebujeme? (ext3/ext4 viz Formátování. ) Plus co navíc? VFAT pro USB (a jiné diskety), NTFS je potřeba dělat přez FUSE pomocí sys-fs/ntfs3g viz https://wiki.gentoo.org/wiki/NTFS

File systems --->
  < > Second extended fs support
  < > The Extended 3 (ext3) filesystem
  <*> The Extended 4 (ext4) filesystem
    [*]   Use ext4 for ext2 file systems
    [*]   Ext4 POSIX Access Control Lists
    [*]   Ext4 Security Labels
    [ ]   Ext4 debugging support
  < > Reiserfs support
  < > JFS filesystem support
  < > XFS filesystem support
  < > Btrfs filesystem support
  <*> FUSE (Filesystem in Userspace) support
  DOS/FAT/NT Filesystems  --->
    <*> MSDOS fs support
    <*> VFAT (Windows-95) fs support
    < > NTFS file system support
  CD-ROM/DVD Filesystems --->
    <*> UDF file system support

6.4   AMD microcode

potřebuje sys-kernel/linux-firmware

emerge --ask sys-kernel/linux-firmware
grep -F -m 1 "cpu family" /proc/cpuinfo|uniq
### cpu family : 23 == 0x17 == 17h

        Processor type and features  --->
          [*] CPU microcode loading support
          [ ]   Intel microcode patch loading support
          [*]   AMD microcode patch loading support
        Device Drivers  --->
          Generic Driver Options
            (amd-ucode/microcode_amd_fam17h.bin) External firmware blobs to build into the kernel binary
              (/lib/firmware) Firmware blobs root directory

6.5   Mounting the boot partition (pro kernel)

(chroot) livecd / # mount /dev/nvme0n1p1 /boot/

(chroot) livecd / # df -h  /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1   99M   512   99M   1% /boot

6.6   Compiling kernel

make -j 26
make modules_install

mkdir -p /boot/EFI/'Gentoo-NVM-SYSTEM'  # or any other name under /boot/EFI
cp /usr/src/linux/arch/x86/boot/bzImage /boot/EFI/'Gentoo-NVM-SYSTEM'/bzImage.efi
efibootmgr -c -L "Gentoo-NVM-SYSTEM" -l '\EFI\Gentoo-NVM-SYSTEM\bzImage.efi'

6.7   NTFS

emerge --ask sys-fs/ntfs3g
chmod a+x /usr/bin/ntfs-3g

6.8   vim, mc, gpm

emerge -avq --jobs --load-average --newuse -DuN vim app-misc/mc sys-libs/gpm
rc-update add gpm default
################################################################################
# cat .mc/ini
################################################################################
[Misc]
timeformat_recent=%d.%m.     %H:%M
timeformat_old=%d.%m.%Y %H:%M
### or
timeformat_recent=      %m.%d %H:%M
timeformat_old=%Y.%m.%d %H:%M

6.9   fstab a spol

vim /etc/fstab
### /dev/nvme0n1p3      /       ext4    noatime 0 1
### /dev/nvme0n1p2      none    swap    sw      0 0
for i in   1 2 3 4 5 6 7 8 9 ; do mkdir -p /mnt/nvme0n1/$i;  >/mnt/nvme0n1/$i/.keep  ; echo -e >>/etc/fstab "/dev/nvme0n1p$i\t/mnt/nvme0n1/$i\tauto\tnoauto,noatime\t0 0";   done
for i in 0 1 2 3 4 5 6 7 8 9 ; do mkdir -p /mnt/nvme0n1/1$i; >/mnt/nvme0n1/1$i/.keep ; echo -e >>/etc/fstab "/dev/nvme0n1p1$i\t/mnt/nvme0n1/1$i\tauto\tnoauto,noatime\t0 0"; done

vim /etc/conf.d/hostname
### hostname="cobra-mk3"

echo 'config_eth0="dhcp"' >>/etc/conf.d/net

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

rc-update add sshd default

vim /etc/hosts
### 127.0.0.1   localhost cobra-mk3 cobra-mk3.iam.god
### 10.0.1.3    merle merle.iam.god

vim /etc/inittab
### --noclear za kazdy terminal

passwd

#vim /etc/rc.conf
#vim /etc/conf.d/keymaps
#vim /etc/conf.d/hwclock

emerge -avq --jobs --load-average app-admin/sysklogd sys-process/cronie sys-apps/mlocate net-misc/dhcpcd net-misc/ntp # net-misc/ntpclient

rc-update add sysklogd default
rc-update add cronie default
rc-update add ntp-client default


updatedb

6.10   ssh

mkdir ~/.ssh
cd ~/.ssh
scp gilhad@merle:root@cobra-mk3.key.pub .
cat root\@cobra-mk3.key.pub  >>authorized_keys
mkdir ids
cat >>config <<EOF
IdentityFile ~/.ssh/ids/%r@%h.key
IdentityFile ~/.ssh/ids/%u@%l--%r@%h.key

HOST kenshin
  ForwardX11 yes
  ForwardX11Trusted yes
EOF
scp gilhad@merle:gilhad@merle.key .     # docasne vytvoreno na merle, spravne je to vytvorit na cobra-mk3 a dotlacit to obracene
chmod 600 ~/.ssh/* ~/.ssh/ids/*
chmod 700 ~/.ssh ~/.ssh/ids

6.11   Reboot

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

7   PROBLEMY !!! bomb

  • System nebootuje, proste NVMe nejde vybrat.

    bzImage.efi jde spustit z GRUB2 na flasce linux (hd2,1)/EFI/Gentoo-NVM-SYSTEM/bzImage.efi - nebo jiny hdx - a bezi to, ale v EFI to vybrat nejde

    • Řešení - je potřeba říct, z jaké EFI partišny to má bootovat (default je z té připojené) - " -d /dev/nvme0n1p1"
      efibootmgr -b 0 -c -L "NVM-Gentoo-NVM-SYSTEM" -l '\EFI\Gentoo-NVM-SYSTEM\bzImage.efi' -d /dev/nvme0n1p1
      
  • HDD WD Red podivne klepe a vrci jako maly vrtulnik
    • vraceno ve 14 dnech (technik v CZC zkusil taky a vrtel nad tim hlavou, ze tohle nezazil)

7.1   HDD Seagate Baracuda 8TB

emerge -avq --jobs --load-average  sys-block/parted sys-apps/hdparm sys-fs/dosfstools
fdisk /dev/sda
g
n
(Enter=part.no 1)
(Enter=first sec. 2048)
+100M
t
1 ('EFI System')
p
Device     Start    End Sectors  Size Type
/dev/sda1   2048 206847  204800  100M EFI System
parted /dev/sda print
Model: ATA ST8000DM004-2CX1 (scsi)
Disk /dev/sda: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name  Flags
 1      1049kB  106MB  105MB                     boot, esp
mkfs.fat -F 32 /dev/sda1
mkdir -p /mnt/sda/{1,2,3,4,5,6,7,8,9,this}
for i in 1 2 3 4 5 6 7 8 9 this; do >/mnt/sda/$i/.keep ; done
mkdir -p /mnt/nvme0n1/{1,2,3,4,5,6,7,8,9,this}
for i in 1 2 3 4 5 6 7 8 9 this; do >/mnt/nvme0n1/$i/.keep ; done
cp /usr/src/linux/arch/x86/boot/bzImage /boot/bzImage.efi
mount /dev/sda1 /boot
mkdir -p /boot/EFI/'Gentoo-NVM-SYSTEM'
cp /usr/src/linux/arch/x86/boot/bzImage /boot/EFI/'Gentoo-NVM-SYSTEM'/bzImage.efi
efibootmgr -c -L "Gentoo-NVM-SYSTEM" -l '\EFI\Gentoo-NVM-SYSTEM\bzImage.efi'
reboot

OK je to blbý jak facka na břicho, ale bootujeme bez flešky !!!

8   FINALIZACE systému

reboot z flašky a zkopíruju si výsledky

fdisk /dev/sda
# sda2 +10G Linux (default)
# sda3 +10G Linux (default)

mkfs.ext4 -L SDA2-SYSTEM /dev/sda2      # odsud by melo jit bootovat
mkfs.ext4 -L SDA-BCK-NVM-SYSTEM /dev/sda3       # 1:1 kopie SYSTEM z NVMe/SYSTEM

mkdir /mnt/gentoo2
mkdir /mnt/gentoo3
mkdir /mnt/gentoo4
mount /dev/nvme0n1p3 /mnt/gentoo/
mount /dev/nvme0n1p4 /mnt/gentoo2/
mount /dev/sda2 /mnt/gentoo3
mount /dev/sda3 /mnt/gentoo4

rsync -ra /mnt/gentoo/* /mnt/gentoo2
rsync -ra /mnt/gentoo/* /mnt/gentoo3
rsync -ra /mnt/gentoo/* /mnt/gentoo4

umount /mnt/gentoo/
umount /mnt/gentoo2/
umount /mnt/gentoo3/
umount /mnt/gentoo4/

8.1   Provoznění bootu z HDD

Chrootnu do /dev/sda2, v kernelu změním root=/dev/sda2, kernel přeložím a vrazím do /boot/Gentoo-SDA2 (a obdobne pro Gentoo-NVM-SYSBCK)

mount /dev/sda2 /mnt/gentoo
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev

chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"

df -h  /

mount /dev/sda1 /boot
vim /etc/fstab
# /dev/sda2      /       ext4    noatime 0 1

cd /usr/src/linux
make menuconfig
Processor type and features  --->
  [*] Built-in kernel command line
  (root=/dev/sda2 net.ifnames=0 vga=ask) Built-in kernel command string
make -j 26
make modules_install

mkdir -p /boot/EFI/'Gentoo-SDA2'      # or any other name under /boot/EFI
cp /usr/src/linux/arch/x86/boot/bzImage /boot/EFI/'Gentoo-SDA2'/bzImage.efi
efibootmgr -c -L "Gentoo-SDA2" -l '\EFI\Gentoo-SDA2\bzImage.efi'

umount /boot

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

9   Next steps

9.1   Další potřebnosti

spoustu programů potřebuju mít k ruce, tady je stáhnu na jednu hromadu (a pak si dám předchozí reistalační kolečko ještě jednou - a sjednotím i názvy disků, systémů a spol.

emerge -avqN sys-process/iotop net-fs/sshfs sys-apps/hdparm

9.2   Nastavení EFI, když ho něco zboří

################################################################################
# cat ebm
################################################################################
#!/bin/bash -x

efibootmgr -B -b 0
efibootmgr -B -b 1
efibootmgr -B -b 2

mount /dev/nvme0n1p1 /boot/
efibootmgr -b 0 -c -L "NVM-Gentoo-NVM-SYSTEM" -l '\EFI\Gentoo-NVM-SYSTEM\bzImage.efi' -d /dev/nvme0n1p1
efibootmgr -b 1 -c -L "NVM-Gentoo-SDA2" -l '\EFI\Gentoo-SDA2\bzImage.efi' -d /dev/nvme0n1p1
efibootmgr -b 2 -c -L "NVM-Gentoo-NVM-SYSBCK" -l '\EFI\Gentoo-NVM-SYSBCK\bzImage.efi' -d /dev/nvme0n1p1
umount /boot

mount /dev/sda1 /boot/
if ( df /boot | grep -q /dev/sda1  ) ; then
        echo SDA
        efibootmgr -B -b 3
        efibootmgr -B -b 4
        efibootmgr -B -b 5

        efibootmgr -c -L "SDA-Gentoo-NVM-SYSTEM" -l '\EFI\Gentoo-NVM-SYSTEM\bzImage.efi' -d/dev/sda1
        efibootmgr -c -L "SDA-Gentoo-SDA2" -l '\EFI\Gentoo-SDA2\bzImage.efi' -d/dev/sda1
        efibootmgr -c -L "SDA-Gentoo-NVM-SYSBCK" -l '\EFI\Gentoo-NVM-SYSBCK\bzImage.efi' -d/dev/sda1
fi
umount /boot

efibootmgr -o 0,1,2

efibootmgr -D

9.3   Pro testování emerge:

################################################################################
# cat /etc/portage/make.conf/00-make.conf
################################################################################
..........
##### Alt++ settings
MAKEOPTS="-j24 -l"
EMERGE_DEFAULT_OPTS="--jobs  --load-average "
PORTAGE_NICENESS=19
#PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
FEATURES="${FEATURES} -merge-sync parallel-fetch -parallel-install -ebuild-locks"


################################################################################
# cat to_build.sh
################################################################################
#!/bin/bash
emerge -pq  -e "$@" |sed "s/.*] */ =/"|tr -d \\r\\n

################################################################################
# cat timetest
################################################################################
time emerge -vqe1 --nodeps `./to_build.sh @world`

################################################################################
# cat load_check.sh
################################################################################
#!/bin/bash
SL=10
if [ $# == 1 ] ; then SL=$1 ; fi
echo "              total        used        free      shared  buff/cache   available               total        used        free      load average"
while true; do (free -h|grep -v total;uptime |sed "s/.*average:/ == /")|tr  \\r\\n "  ";echo;sleep $SL;done

10   BRANCH: TeachMePCB comp

už nutně potřebuju počítač pro TeachMePCB, kde jsem asi dva týdny pozadu a Ryoga je zoufalost, takze zkopnu NVM-Gentoo-NVM-SYSBCK a celkem neřízeně a nedokumentovaně ho použiju 2020.05.15-cobra-mk3-TeachMePCB.html

11   app-portage/cpuid2cpuflags

emerge -avq app-portage/cpuid2cpuflags
cpuid2cpuflags