Skip to content

Instantly share code, notes, and snippets.

@jacky9813
Last active November 13, 2022 07:10
Show Gist options
  • Save jacky9813/8bb473869a24ce0e493a0aa0c9b577d6 to your computer and use it in GitHub Desktop.
Save jacky9813/8bb473869a24ce0e493a0aa0c9b577d6 to your computer and use it in GitHub Desktop.
Journey of Installing Gentoo Linux

My Journey of Installing Gentoo Linux

Welp, since it is Gentoo Linux, it'll never gonna be easy to install, and definitely having much more rocky process than Rocky Linux (pun intented).

Installing Gentoo Linux is just a test to my Linux knowledge and hopefully it'll help me troubleshoot problems when managing other's machine.

Anyway, the official Gentoo Installation Handbook is very helpful for getting started, mostly.

The scope of the installation

  • EFI
  • Systemd
  • No-multilib (removes 32 bit software support)
  • GPT+LVM in boot disk
  • Boot partition + swap partition + root partition only
  • XFS formatted root partition
  • Latest release of Linux Kernel, 6.0.8 to be exact
  • Have initramfs
  • Using GRUB2

Installing Virtual Box 7.0.2 and create a new Virtual Machine

Since I was using Virtual Box 6.1 before, I found out that there's a new update for the Virtual Box which strangely not able to be picked up by auto update process.

I'm trying to configure the VM as modern as possible, including EFI and using virtio as storage controller, nic and anywhere if possible.

Well... It wouldn't be a great start if EFI console shows no mapped device, is it?

Using virtio-scsi seems to having problem for the EFI firmware picking up the disks and cd drive. As I'm not familiar with configuring the firmware, I switched to a known good controller, LSILogic SAS.

Other than that, the machine works well.

Problem 1: These damn penguins blocking the screen

The boot sequence of the live ISO image will show the penguin image when booting.

This, I believe, is caused by a kernel config CONFIG_LOGO.

I was expecting these penguins will gone after the auto login. They didn't.

Workaround

I have to switch to another tty using Ctrl+Alt+F2 and switch back to tty1 to get rid of these.

Problem 2: Masked package (License)

While fetching sys-kernel/linux-firmware package, I got the message:

Calculating dependencies... done!

!!! All ebuilds that could satisfy "sys-kernel/linux-firmware" have been masked.

...(ignored)

A copy of the 'linux-fw-redistributable' license is located at '/var/db/repos/gentoo/licenses/linux-fw/redistributable'.
A copy of the 'no-source-code' license is located at '/var/db/repos/gentoo/licenses/no-source-code'.

...(ignored)

The message indicates that I haven't agreed to some licenses.

Solution

These licenses can be found inside @BINARY-REDISTRIBUTABLE.

As I don't want to allow all binary redistributable package installed without acknowledged, I choose to create a file in /etc/portage/package.license/sys-kernel_linux-firmware with the content:

sys-kernel/linux-firmware @BINARY-REDISTRIBUTABLE

Problem 3: Masked package again! (keyword)

Here we go again! Another package being masked!

When trying to get package sys-kernel/vanilla-sources (the original Linux kernel), here what I got:

!!! All ebuilds that could satisfy "sys-kernel/vanilla-sources" have been masked.
!!! One of the following masked packages is required to complete your request:
- sys-kernel/vanilla-sources-6.0.8::gentoo (masked by: ~amd64 keyword)

... (ignored)

Solution

As the error mentioned, it is being masked by the ~amd64 keyword. So another file is created : /etc/portage/package.accept_keyworkds/sys-kernel_vanilla-sources

sys-kernel/vanilla-sources ~amd64

Problem 4: Kernel config

As there might be thousands of kernel compile options, it is quite overwhelmingly hard to figure out what each option is doing.

So I reviewed what I'm going to have:

  • System-wise:
    • Initramfs
    • systemd
    • EFI
    • No multilib
  • Filesystem-wise:
    • LVM
    • XFS
    • VFAT (for /boot)
  • Hardware-wise:
    • virtio-net, which is recognized as Red Hat, Inc. Virtio network device
    • LSILogic SAS, which is recognized as Broadcom / LSI SAS1068 PCI-X Fusion-MPT SAS in lspci
    • AMD Ryzen 5000 series CPU, assigned 8 vCPUs to the VM.
    • A VirtualBox VM
  • Preferences:
    • Ger rid of the penguin
    • Kernel includes .config
    • Enable support of FUSE (Filesystem in Userspace)
    • Enable support of other filesystems

These gaves me some hint of what I should do.

Solution

Upon reading some other articles for configuring the kernel, I found out that the kernel option is very different in 6.0.8.

I'll have to find the same option in a different location, which is very tideous tbh.

These are the requirements for my environment:

  • System-wise:
    • Initramfs
      • Package sys-kernel/dracut installed.
      • General Setup/[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
      • General Setup/[*] Support inital ramdisk/ramfs compressed using <any> <= Enable all compression method is recommended
    • systemd
      • Required options:
        • Package sys-apps/systemd is installed.
        • General Setup/BPF subsystem/[*] Enable bpf() system call
        • General Setup/[*] Control Group support/[*] Support for eBPF programs attached to cgroups
        • General Setup/[ ] Enable deprecated sysfs features to support old userspace tools
        • General Setup/[*] Configure standard kernel features (expert users)/[*] open by fhandle syscalls
        • General Setup/[*] Configure standard kernel features (expert users)/[*] Enable eventpoll support
        • General Setup/[*] Configure standard kernel features (expert users)/[*] Enable signalfd() system call
        • General Setup/[*] Configure standard kernel features (expert users)/[*] Enable timerfd() system call
        • [*] Networking Support
        • Device Drivers/Generic Driver Options/[*] Maintain a devtmpfs filesystem to mount at /dev
        • File systems/[*] Inotify support for userspace
        • File systems/Pseudo filesystems/[*] /proc file system support
        • File systems/Pseudo filesystems/[*] sysfs file system support
      • Recommended options:
        • General Setup/[*] Namespaces support/[*] Network namespace
        • General architecture-dependent options/[*] Enable seccomp to safely execute untrusted bytecode
        • [*] Enable the block layer/[*] Block layer SG support v4 helper lib
        • [*] Networking Support/Networking options/<*> The IPv6 protocol
        • Device Drivers/Generic Driver Options/[ ] Support for uevent helper
        • Device Drivers/Firmware Drivers/[*] Export DMI identification via sysfs to userspace
        • File systems/<*> Kernel automounter support (supports v3, v4 and v5) <== Could be selected by <*> Old Kconfig name for Kernel automounter support
        • File systems/Pseudo filesystems/[*] Tmpfs virtual memory file system support (former shm fs)
        • File systems/Pseudo filesystems/[*] Tmpfs POSIX Access Control Lists
        • File systems/Pseudo filesystems/[*] Tmpfs extended attributes
    • EFI
      • Processor type and features/[*] EFI runtime service support
      • Processor type and features/[*] EFI stub support
      • Processor type and features/[*] EFI mixed-mode support
      • [*] Enable the block layer/Partition Types/[*] Advanced partition selection
      • [*] Enable the block layer/Partition Types/[*] EFI GUID Partition support
      • Device Drivers/Firmware Drivers/[*] Mark VGA/VBE/EFI FB as generic system framebuffer
      • Device Drivers/Graphics support/Frame buffer Devices/<*> Support for frame buffer devices/[*] EFI-based Framebuffer Support
      • File systems/Pseudo filesystems/<*> EFI Variable filesystem
    • No multilib
      • Binary Emulations/[*] IA32 Emulation becomes not relevant.
  • Filesystem-wise:
    • LVM
      • Package sys-fs/lvm2 installed.
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> Device mapper support
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> Crypt target support
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> Snapshot target
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> Mirror target
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> Multipath target
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> I/O Path Selector based on the number of in-flight I/Os
      • Device Drivers/[*] Multiple devices driver support (RAID and LVM)/<*> I/O Path Selector based on the service time
    • XFS
      • Package sys-fs/xfsprogs installed
      • File systems/<*> XFS filesystem support
      • File systems/[*] XFS POSIX ACL support
    • VFAT (for /boot)
      • Package sys-fs/dosfstools installed
      • File systems/DOS/FAT/EXFAT/NT Filesystems/`<*> VFAT (Windows-95) fs support
  • Hardware-wise:
    • virtio-net, which is recognized as Red Hat, Inc. Virtio network device
      • Device Drivers/[*] Network device support/[*] Network core deiver support
      • Device Drivers/[*] Network device support/<*> Virtio network driver
    • LSILogic SAS, which is recognized as Broadcom / LSI SAS1068 PCI-X Fusion-MPT SAS in lspci
      • Device Drivers/SCSI device support/<*> SCSI device support
      • Device Drivers/SCSI device support/<*> SCSI disk support
      • Device Drivers/SCSI device support/<*> SCSI CDROM support
      • Device Drivers/SCSI device support/<*> SCSI generic support
      • Device Drivers/SCSI device support/SCSI low-level drivers/<*> Legacy MPT2SAS config option <= Which should will also select -*- LSI MPT Fusion SAS 3.0 & SAS 2.0 Device Driver
      • There're some caveats here, which will be solved in problem 6.
    • AMD Ryzen 5000 series CPU, assigned 8 vCPUs to the VM.
      • Processor type and features/[*] Symmetric multi-processing support
      • Processor type and features/Processor family (Generic-x86-64) <= I'm not sure if the option Opteron/Athlon64/Hammer/K8 can be used or not.
      • Processor type and features/(32) Maximum number of CPUs <= It is good as long as it's greater than 8.
      • Processor type and features/[*] Multi-core scheduler support
      • Processor type and features/[*] CPU microcode loading support
      • Processor type and features/[*] AMD microcode loading support
      • [*] Miriagtions for speculative execution vulnerabilities
    • A VirtualBox VM
      • Processor type and features/Linux guest support/[*] Enable paravirtualization code
      • Processor type and features/Linux guest support/[*] KVM Guest support (including kvmclock)
      • Device Drivers/Graphics support/<M> DRM driver for VMware Virtual GPU <= As I'm using VMSVGA as the display driver.
      • Device Drivers/Graphics support/<M> Virtual Box Graphics Card <= Just to be safe
      • Device Drivers/HID support/-*- HID bus support
      • Device Drivers/HID support/<*> Generic HID driver
      • Device Drivers/HID support/[*] Battery level reporting for HID devices
      • Device Drivers/HID support/USB HID support/<*> USB HID transport layer
      • Device Drivers/[*] USB support/<*> xHCI HCD (USB 3.0) support
      • Device Drivers/[*] USB support/<*> EHCI HCD (USB 2.0) support
      • Device Drivers/[*] USB support/<*> OHCI HCD (USB 1.1) support
      • Device Drivers/[*] USB support/<*> UHCI HCD (most Intel and VIA) support
      • Device Drivers/[*] USB support/<*> USB Mass Storage support <= In case of trying to pass USB stick devices into the VM.
      • Device Drivers/[*] USB support/<*> USB Attached SCSI
      • Device Drivers/[*] Virtualization drivers/<M> Virtual Box Guest integration support <= Either <*> or <M> is ok here
      • Device Drivers/[*] Virtualization drivers/<M> EFI secret area srcurityfs support <= Not sure the use of it
      • File systems/[*] Miscellaneous filesystems/<M> VirtualBox guest shared folder (vboxsf) support
  • Preferences:
    • Ger rid of the penguin
      • Device Drivers/Graphics support/[ ] Bootup logo
    • Kernel includes .config
      • General setup/<*> Kernel .config support
      • General setup/[*] Enable access to .config through /proc/config.gz
    • Enable support of FUSE (Filesystem in Userspace)
      • File systems/<M> FUSE (Filesystem in Userspace) support
    • Enable support of other common filesystems
      • File systems/<M> Second extended fs support
      • File systems/[*] Ext2 extended attributes
      • File systems/[*] Ext2 POSIX Access Control Lists
      • File systems/<M> The Extended 3 (ext3) filesystem
      • File systems/[*] Ext3 POSIX Access Controls Lists
      • File systems/<M> JFS filesystem support
      • File systems/[*] JFS POSIX Access Control Lists
      • File systems/<M> Btrfs filesystem support
      • File systems/[*] Btrfs POSIX Access Control Lists
      • File systems/CD-ROM/DVD Filesystems/<*> ISO 9660 file system support
      • File systems/CD-ROM/DVD Filesystems/[*] Microsoft Joliet CDROM extensions
      • File systems/CD-ROM/DVD Filesystems/<*> UDF file system support
      • File systems/DOS/FAT/EXFAT/NT Filesystems/<M> exFAT filesystem support
      • File systems/DOS/FAT/EXFAT/NT Filesystems/<M> NTFS Read-Write file system support <= The one that the help message mentioned NTFS version 3.1.
      • File systems/DOS/FAT/EXFAT/NT Filesystems/[ ] 64 bits per NTFS clusters <= As Microsoft Windows will not able to access the filesystem with this enabled.
      • File systems/DOS/FAT/EXFAT/NT Filesystems/[*] activate support of external compressions lzx/xpress

References:

Problem 5: Stuck on loading initramfs

After reboot, GRUB menu shows up, selected the Gentoo Linux option. It started to load kernel and initramfs.

That's it. No output after Loading initramfs.

Unlike the live CD is able to pickup EFI VGA as frame buffer, it seems there's some problem with the graphics settings.

Workaround

Enabling the simple frame buffer in the kernel config seems to work for now.

  • Device Drivers/Graphics support/< > Simple framebuffer driver
  • Device Drivers/Graphics support/Frame buffer Devices/<*> Support for frame buffer devices/<*> Simple framebuffer support
  • Device Drivers/Graphics support/Console display driver support/[*] Framebuffer Console support

=====

Alternatively, the live CD also has /proc/config.gz enabled, which can be used as reference as well.

Problem 6: dracut-initqueue: starting timeout scripts

Now I can see what's going on for my booting. I saw it started dracut initqueue and stuck at there.

After around 16 minutes, it starts spitting out the message:

[  992.100683] dracut-initqueue[255}: Warning: dracut-initqueue: timeout, still waiting for following initqueue hooks:
[  992.101900] dracut-initqueue[255]: Warning: /lib/dracut/hooks/initqueue/finished/devexists-\x2fdev\x2fmapper\x2fgentoo--vg-gentoo--root.sh: "if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
[  992.102870] dracut-initqueue[255]:     [ -e "/dev/mapper/gentoo--vg-gentoo--root" ]
[  992.103592] dracut-initqueue[255]: fi"
[  992.103875] dracut-initqueue[255]: Warning: dracut-iniqueue: starting timeout scripts
[  992.104679] dracut-initqueue[255]L Warning: Could not boot.
         Starting Dracut Emergency Shell...
Warning: /dev/mapper/gentoo--vg-gentoo--root does not exist

Which indicates that it's not able to find the root LVM volume.

Solution

After entering the emergency shell, I started out finding the logical volume (gentoo-root), volume group (gentoo-vg) and physical volume (should be /dev/sda2).

lvm lvs => Nothing

lvm vgs => Nothing

lvm pvs => Sill nothing

ls /dev/sd* => Also nothing!

The fact that /dev/sd* does not exist, makes me think I've selected the wrong driver (oops).

So I went back to the kernel config, select all LSI driver as module.

  • Device drivers/SCSI device support/[*] SCSI low-level drivers/[*] LSI Logic New Generation RAID Device Drivers
  • Device drivers/SCSI device support/[*] SCSI low-level drivers/<M> LSI Logic Legacy MegaRAID Driver
  • Device drivers/SCSI device support/[*] SCSI low-level drivers/<M> LSI Logic MetaRAID SAS RAID Module
  • Device drivers/SCSI device support/[*] SCSI low-level drivers/{M} LSI MPT Fusion SAS 3.0 & SAS 2.0 Device Driver
  • Device drivers/SCSI device support/[*] SCSI low-level drivers/<M> Legacy MPT2SAS config option

After digging around, I found these

  • Device drivers/[*] Fusion MPT device support
  • Device drivers/[*] Fusion MPT device support/<M> Fusion MPT ScsiHost drivers for SPI <= Probably not needed
  • Device drivers/[*] Fusion MPT device support/<M> Fusion MPT ScsiHost drivers for SAS

Which was disable before, great...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment