Install gentoo safely as stage 3 doesn't have kernel installation files

Hi I am Rupesh from India and I brought a new pc with AMD ryzen 5500GT Asus prime b450 motherboard. I have tried a number of Linux operating systems and at present I have installed successfully Fedora, Debian, and Arch Linux but I can't install gentoo safely.

I have tried the instructions specified in gentoo AMD handbook to install gentoo safely as follows

  1. I have downloaded gentoo live iso image from the official gentoo website.

  2. I created usb installation medium using dd in Arch Linux.

  3. I booted into the gentoo live environment.

  4. using Firefox web browser I have downloaded stage 3 desktop systemd tar ball.

  5. I created 40 Gb xfs partition for new gentoo root.

  6. I created 600 mb fat 32 alias vfat for gentoo efi.

  7. I created 3 gb swap partition for new gentoo

  8. I mounted 40 Gb xfs partition to /mnt/gentoo

  9. I have mounted vfat partition to /mnt/gentoo/efi

  10. I copied the stage 3 tar ball to /mnt/gentoo and extracted it as specified in handbook.

  11. I modified the fstab file and added entries for root, efi and swap.

  12. I added -march=znver3 to COMMON_FLAGS entry in /etc/portage/make.conf and made symbolic link to /etc/make.conf.

  13. rebooted my system and entered into Arch Linux and issued the following command

sudo grub-mkconfig -o /boot/grub/grub.cfg

I found something as "found gentoo on /dev/nvme0n1p18

After that I entered the following command

grub install /dev/nvme0n1

  1. I have rebooted my system and in grub I selected gentoo but I got error as kernel not found.

  2. I restarted my system and entered into gentoo live environment and searched Firefox for gentoo install kernel and found article saying to install gentoo-kernel

So I done chroot into my new gentoo and issued the following command

emerge gentoo-kernel

  1. After that I have rebooted my system and entered into Arch Linux and issued the following command

sudo grub-mkconfig -o /boot/grub/grub.cfg

After that I issued grub install in Arch Linux.

  1. After that I have restarted my system and in grub I have selected gentoo but this time I got error something as

cannot open /dev/root

  1. After that I have restarted my system and entered into gentoo live environment and searched for gentoo install kernel and this time I found an article saying that linux-firmware to install first before doing anything else.

Even though I issued the following command

emerge linux-firmware

  1. After that I have restarted my system and entered into Arch Linux and issued grub commands as before.

  2. As usually I restarted my system and in grub I have selected gentoo but unfortunately this time also I got the same error as

/dev/root: Cannot open blockdev

  1. I tried a number of times to remove the installed kernel and compile it from source from the beginning but no use I am getting the same error as

/dev/root: Cannot open blockdev

If I want to install or remove packages I must enter into gentoo live environment and do chroot and do anything.

In the gentoo live environment chroot when I issue emerge command I am getting error as the current package is masked. For example the following command

emerge linux-firmware

I have searched portage for some packages like sudo, grub, network manager etc., and mostly I found 50 percent in the repository are masked.

Upto now I have used a number of Linux operating systems and upon installing them to my system I found a working kernel all utilities like sudo, grub, network manager etc.,.

I can't understand why gentoo stage 3 tar ball doesn't have kernel installation files and grub.

At present I am getting error /dev/root cannot open blockdev and in chroot environment sometimes I am getting error as "efi directory not found".

My requirement is I want a working Linux operating system through compilation of all packages optimised for my ryzen zen3 processor. For this I included -march=znver3 in /etc/.

Another requirement is if I issue the command "emerge kde" all the packages related to kde must be downloaded and compiled properly and the system must not be in a broken state.

Kindly try to suggest how to install gentoo properly and if you want I am ready to provide diagnostic output of the commands provided by you.

Regards,
Rupesh.

Feeding your post into ChatGPT, which is often not accurate for these types of questions, yields:

ChatGPT Replies to this Question by Rupesh on Gentoo Install

ChatGPT Generates: (Use With Caution!!)

Hi Rupesh,

It sounds like you've been working diligently to get Gentoo installed, but you're running into several issues with your setup. I'll try to help guide you through this process step by step.

Understanding the Problems:

  1. Kernel Not Found: This usually occurs because the kernel is not installed, or the bootloader (GRUB in this case) is not pointing to the correct kernel.

  2. Cannot Open /dev/root: This error typically indicates that the system is unable to locate the root filesystem. This might be due to missing kernel parameters or issues with the kernel configuration.

  3. Masked Packages: In Gentoo, packages are sometimes masked because they are considered unstable or testing versions. Masked packages need to be unmasked before you can install them.

Steps to Resolve:

1. Verify Kernel Installation and Configuration:

After chrooting into your Gentoo installation, make sure you have installed the kernel properly. Here’s how you can proceed:

emerge gentoo-sources
cd /usr/src/linux
make menuconfig
  • Ensure that the necessary drivers for your hardware are selected.
  • Make sure XFS, VFAT, and your disk controllers are built into the kernel (not as modules).
  • Enable EFI Stub support if you're using EFI.
  • Set the root filesystem type to XFS.

After configuring:

make -j$(nproc)
make modules_install
make install

This will compile and install the kernel.

2. Configure GRUB Properly:

If your root filesystem is on /dev/nvme0n1p18, you need to ensure that GRUB is configured correctly:

  • Update /boot/grub/grub.cfg by running:

    grub-mkconfig -o /boot/grub/grub.cfg
    
  • Ensure that the root= parameter in the GRUB configuration points to your root partition (/dev/nvme0n1p18).

Example of the GRUB entry in /boot/grub/grub.cfg:

linux   /boot/vmlinuz-5.x.x-gentoo root=/dev/nvme0n1p18 ro

3. Handle Masked Packages:

If you encounter masked packages, you can unmask them manually. For example:

echo "sys-kernel/linux-firmware ~amd64" >> /etc/portage/package.accept_keywords
emerge linux-firmware

If a package is hard-masked, you will need to unmask it by adding it to /etc/portage/package.unmask.

4. Reinstall GRUB:

After ensuring the kernel is correctly installed, reinstall GRUB:

grub-install /dev/nvme0n1
grub-mkconfig -o /boot/grub/grub.cfg

5. EFI Issues:

Make sure the EFI partition is mounted correctly during chroot:

mount /dev/nvme0n1p1 /boot/efi

If the EFI directory is not found, check that it's created and mounted properly.

6. Test Booting:

After following these steps, reboot the system and try to boot into Gentoo. If you still face issues, check the boot logs by appending init=/bin/bash to the kernel line in GRUB to manually mount and inspect the root filesystem.

7. Post-Installation:

Once Gentoo is booting properly, you can proceed with installing your desktop environment and other packages:

emerge kde-plasma/plasma-meta

Ensure that you have all necessary use flags and configurations in /etc/portage/make.conf.

Final Note:

Gentoo is powerful because of its flexibility, but this also means the installation process can be tricky. Following the handbook carefully and ensuring each step is completed correctly is key. If you run into specific errors, providing the exact error messages will help in troubleshooting further.

Feel free to provide output of any command if something goes wrong, and I'll assist you further.

ChatGPT Generated: Use With Caution!

Yes, configuring Grub on a Gentoo install can be very tricky depending what hardware and BIOS you have. It can be different on every platform!!

I reckon that it's the Grub install/configuration that's tripping you up. It's extremely easy to get it wrong. Frequently it's not an automatic process.

Read this and understand it:
https://wiki.gentoo.org/wiki/GRUB

Good luck.

If you have root=/dev/nvme0n1p18 in the linux line in grub.cfg then
also have /dev/nvme0n1p18 for the / entry in the /etc/fstab, otherwise the remount of / would fail.

Thanks for your suggestions.