Compiling the Linux Kernel! Gentoo!


Yesterday at around 10 am I embarked on a journey. A journey I've heard can be long and arduous. And it was. I installed Gentoo GNU+Linux for the first time, including compiling my own custom Linux kernel. It is the fear of every new Gnu+Linux user - having to ask for help in an online forum and recieving a smug, condescending "Did you look at the Wiki?" from the recluse nerd with an anime profile picture and a profile comment that simply says "I use Arch." So too do Arch users cower in fear, trembling, as the Gentoo chad comments on their post - "I use Gentoo, btw." All jokes aside, Gentoo always seemed to be in a league of its own within the Gnu+Linux community - except for the masochists who have tried LFS. I have always heard of the hours or days long compile times in Gentoo, the crazyness of customizing your own kernel, and the panic that sets in when your system doesn't boot after a days long compile session. All this has some grain of truth to it, and it does scare most away from even trying Gentoo. But, it is an experience that I believe everyone should have. And not only us nerdy computer people, everyone. Installing Gentoo does not only teach you about your system, but also teaches you about all the crap (spyware?) that is in it without you even knowing! While my level of understanding and appreciation for Gnu+Linux skyrocketed the first time I installed Arch from scratch, installing Gentoo was a whole other experience.

The journey began at 10 am. The night before, a Friday night, I was watching an ASMR install video that youtube decided to recommend to me. I was not really paying attention, but it popped up while YT was playing in the background so I decided not to skip it. Little did I know it was around two hours long…but I was focused and hence ended up watching the whole thing. Later that night, before going to bed, I decide to look up some installation experiences on youtube, and watched Brodies, Mental Outlaws, and DistroTubes videos. I was convinced - this is something I want to try asap. The next morning, barely awake myself, I wake up my main computer and proceed to download the livecd from the Gentoo website. I made my morning espresso, took my dog out, and at 10:40 I was ready to begin. I decided to not follow any videos, and instead just do it from the Gentoo installation manual, just as I had done with Arch. The manual is incredible, first of all. The amount of information and options it gives you is…heartwarming. It is nice to see the dedication of the devs, that they spent so much time to give as many people as many options as seems feasible for an install manual. There is no one way to install Gentoo - after all, the beauty of it is its versatility. From different init systems to different bootloaders, from varying dhcp daemons to completely different kernel options…there is so much to explore here! I decided to go the more "standard" route, that is, Gentoo with the custom kernel, OpenRC init, and Grub2. Because I am installing in a VM, I also decided to stick to MBR partitioning, as the complexity is rather low compared to other options.

Choosing the kernel options can be daunting for those who have not done it before - like me. The Gentoo manual provides some guidance, but there is so much more to it. Mental Outlaw has a video explaining almost all options with granular detail, that was crucial for me to understand what I was doing and to build a kernel that would hopefully work on my VM. I started out deselecting the obvious things that I did not need, like GPU support, Nvidia drivers, wireless networking support, etc. Once I cleared enough of what I did not need, and added in what I did need (mostly filesystem support), it was finally time for the moment all Gentoo-virgins get excited for. Compiling the kernel for the first time.

With all the settings configured, I saved and issued the command - make && make modules_install. Boom, off it went! Thankfully I assigned this VM 8 GB and 4 cores, which greatly sped up the compiling process. This paired with the lightweight options (as light as I knew how to make during this first ever kernel customization) meant that the compile time for my kernel was a little over 20 minutes. Not bad at all. Also, make sure to include the proper MAKEOPTS in your portage make.conf. This will very seriously impact your compilation times. As I had chosen 8 GB RAM and 4 CPU threads, it was simple to set the number of parallel compilations to 4. The rule here according to the Gentoo wiki is RAM divided by two or CPU threads, whichever is smaller.

With the kernel finally compiled, the bootloader installed and configured, it was time to leave the chroot environment, unmount the installation media, and boot the machine for the first time. The whole process to this point took more or less 4 hours, so I was noticeably tired. I was crossing my fingers that everything would work…and….my boot failed. I had made a mistake with the initramfs, so, back to the chroot environment to try and fix it. After around two hours tinkering with my configuration I decided I had enough for the day. Six hours sitting in front of a computer trying to install Gentoo on a VM is definitely a "take me to the psych ward" sign. I needed a break - and season 4 of Stranger Things had just come out so..

The next day I go back into the system and slowly, but surely, am able to get a working, bootable, Gentoo Gnu+Linux instance. Finally. With this step done, I install Vim, Xorg, and AwesomeWM. Wow, the compilation time of those three programs took around two hours! I bet the culprit here is XORG and VIM. Also, I got the chance to explore and try ¨doas¨, the BSD sudo alternate. It is incredible. I love how simple and "unbloated" the config is. I have heard a lot about doas before. As a very basic sudo user, that is, I only use it to run commands with escalated priviledges - nothing else - doas is a great alternative. Finally after around 8 hours between compile times and problem-solving time, I had a working Gentoo installation with a graphical environment.

As I said in the beginning of this post, this is something I think (although I know it's not realisitc) everyone should do at least once. Installing Gentoo, and especially configuring and understanding all the USE flags has shown me how much bloat and unecessary code-base there is in everything we use. It felt so good to use USE="-gnome -kde -intel", etc and know that my system was being compiled as I intended it to be. I don't use gnome, so why have the code-base to support it? There is the obvious downside to compile times and having to fix your system in case something breaks (simply reinstalling is not feasible), but in general I see Gentoo as more of a mentality than a distro in itself.

Now…will I continue to use Gentoo? Will I install it on bare metal soon? I am not sure. I don't think I am ready for it yet, but, maybe a couple weeks only using it would change my mind.