Home

last update: 2020-02-27 at 14:00:16 CET

Installing Gentoo On A Alienware 17 R1

The Alienware family is IMO a nice desktop replacement where space is scarce. Ive bought a used one in great shape.

Pros
  • Great extensibility

  • Great connectivity

  • Good processing quality

Cons
  • Heavy weight

Hardware

lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
00:04.0 Signal processing controller: Intel Corporation Device 0c03 (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5)
00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #4 (rev d5)
00:1c.4 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #5 (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM87 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
00:1f.6 Signal processing controller: Intel Corporation 8 Series Chipset Family Thermal Management Controller (rev 05)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204M [GeForce GTX 980M] (rev a1)
08:00.0 Ethernet controller: Qualcomm Atheros Killer E220x Gigabit Ethernet Controller (rev 10)
09:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader (rev 01)
09:00.1 SD Host controller: Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader (rev 01)
0a:00.0 Network controller: Intel Corporation Wireless 7260 (rev 73)
Note
prefixing a command with $ means it should be executed as the current user. No prefix means root
grep "model name" /proc/cpuinfo|uniq
model name      : Intel(R) Core(TM) i7-4940MX CPU @ 3.10GHz

Installation

Note
These are raw notes taken from my installation. Depending on your setup things may be different. Because I am not a gentoo expert there are surely better ways of doing this or that ;)

Preparartion

Follow the instructions from:

I used a Linux Mint Live USB-Stick to boot the system for installation

Disk Partitioning

Note
Later I added an additional 1TB drive that caused drive identifiers to change
parted -a optimal /dev/sda

(parted) print
Model: ATA SAMSUNG SSD PM85 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size   File system  Name  Flags
 1      17.4kB  134MB   134MB                     msftres
 2      701MB   1016MB  315MB  ntfs               diag
 3      1016MB  1121MB  105MB  fat32              boot, esp
 4      1121MB  255GB   254GB  ntfs               msftdata
 5      255GB   256GB   937MB  ntfs               hidden, diag

(parted) mklabel gpt

(parted) unit mib

(parted) mkpart primary 1 2
(parted) name 1 grub
(parted) set 1 bios_grub on
(parted) print
Model: ATA SAMSUNG SSD PM85 (scsi)
Disk /dev/sda: 244198MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End      Size     File system  Name  Flags
 1      1.00MiB  2.00MiB  1.00MiB               grub  bios_grub


(parted) mkpart primary 3 131
(parted) name 2 boot
(parted) mkpart primary 131 1155
(parted) name 3 swap
(parted) mkpart primary 1155 -1
(parted) name 4 rootfs

(parted) set 2 boot on
(parted) print
Model: ATA SAMSUNG SSD PM85 (scsi)
Disk /dev/sda: 244198MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End        Size       File system  Name    Flags
 1      1.00MiB  2.00MiB    1.00MiB                 grub    bios_grub
 2      3.00MiB  131MiB     128MiB                  boot    boot, esp
 3      131MiB   1155MiB    1024MiB                 swap
 4      1155MiB  244197MiB  243042MiB               rootfs

Filesystems

mkfs.ext2 /dev/sda2
mkfs.btrfs /dev/sda4
mkswap /dev/sda3
swapon /dev/sda3

Stage3 Setup

mkdir /mnt/gentoo && mount /dev/sda4 /mnt/gentoo
cp Downloads/stage3-amd64-20181113T214502Z.tar.xz /mnt/gentoo/ && cd $_
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
vim /mnt/gentoo/ETC/portage/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="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
MAKEOPTS="-j8"

# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"

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

GENTOO_MIRRORS="http://distfiles.gentoo.org"
mkdir --parents /mnt/gentoo/etc/portage/repos.conf
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

mount --types 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

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

mkdir /boot
mount /dev/sda2 /boot

emerge --sync

elselect news read
elselect news list
elselect news purge

eselect profile list

..
[16]  default/linux/amd64/17.0/desktop (stable)
..

eselect profile set 16
emerge -av --update --deep --newuse @world
emerge --info | grep ^USE
less /usr/portage/profiles/use.desc
ls /usr/share/zoneinfo/Europe
echo "Europe/Berlin" > /etc/timezone
emerge --config sys-libs/timezone-data

nano -w /etc/locale.gen
en_US.UTF-8 UTF-8
locale-gen
locale -a

eselect locale list
Available targets for the LANG variable:
  [1]   C
  [2]   en_US.utf8
  [3]   POSIX
  [ ]   (free form)
eselect locale set 2

env-update && source /etc/profile && export PS1="(chroot) $PS1"

Kernel

Note
This is definitely not the best idea because a live CD kernel config includes everything (that means lots of modules) that are only necessary for a live CD. The system thats going to be installed only needs a small fraction of them. I would recommend to either use genkernel or step through the config manually
emerge --ask sys-kernel/gentoo-sources
emerge -av sys-apps/pciutils

use kernel config from mint live cd as base:

cp /boot/config-4.10.0-38-generic /mnt/gentoo/opt/
make menuconfig

load /opt/config-4.10.0-38-generic and save as .config

make -j8 && make modules_install
make install

Kernel - genkernel

todo

Initram FS

emerge -av sys-kernel/genkernel

If it complains about outstanding configuration changes run etc-upadte

emerge -av sys-fs/btrfs-progs
genkernel --install initramfs
ls /boot/initramfs*

Install Firmware

emerge -av sys-kernel/linux-firmware

/etc/fstab

Note
here /dev/sdb is now the initial 256GB drive (boot+rootfs). The drive /dev/sda is a newly added 1TB housing my data
vim /etc/fstab
/dev/sda1   /mnt/ssd     btrfs   noatime,discard      0 1
/dev/sdb2   /boot        ext2    defaults,noatime     0 2
/dev/sdb3   none         swap    sw                   0 0
/dev/sdb4   /            btrfs   noatime,discard      0 1

/mnt/ssd/databox  /home/timo/databox   none    defaults,bind   0 0
/mnt/ssd/backup   /home/timo/backup    none    defaults,bind   0 0
/mnt/ssd/pix      /home/timo/pix       none    defaults,bind   0 0

/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0
vim /etc/conf.d/hostname
vim /etc/conf.d/net
dns_domain_lo="homenetwork"

network

emerge -av --noreplace net-misc/netifrc
vim /etc/conf.d/net
config_eth0="dhcp"
cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0 default

root pass

passwd
ls /usr/share/keymaps/i386/qwertz/
vim /etc/conf.d/keymaps
keymap="de"
rc-update add keymaps boot
rc-service keymaps restart
vim /etc/conf.d/hwclock

system logger

emerge -av app-admin/sysklogd
rc-update add sysklogd default

cron daemon

emerge -av sys-process/cronie

dhcp daemon

emerge -av net-misc/dhcpcd

wireless

emerge -av net-wireless/iw net-wireless/wpa_supplicant

Run etc-update if config changes need to be applied

bootloader

emerge -av sys-boot/grub:2
grub-install /dev/sda

vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="rootfstype=btrfs"

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

user

useradd -m -G users,wheel,audio,video,usb,cdrom -s /bin/bash timo
passwd timo

wireless

vim /etc/conf.d/net
dns_domain_lo="homenetwork"
config_enp8s0="dhcp"

modules_wlp10s0="wpa_supplicant"
config_wlp10s0="dhcp"
wpa_supplicant_wlp10s0="-Dwext"
vim /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

ap_scan=1

network={
        ssid="p4radise"
        psk="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
cd /etc/init.d
ln -s net.lo net.wlp10s0
rc-update add net.wlp10s0 default

/etc/init.d/net.wlp10s0 start

NTP

emerge -av net-misc/ntp
rc-service ntp-client start
rc-update add ntp-client default

ConsoleKit

vim /etc/portage/make.conf
USE="consolekit"

emerge -av --changed-use --deep @world

/etc/init.d/consolekit start
rc-update add consolekit boot

$ vim ~/.xinitrc
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session openbox-session

Xorg

vim /etc/portage/make.conf
INPUT_DEVICES="libinput synaptics"
VIDEO_CARDS="nouveau"

emerge -av x11-base/xorg-drivers
emerge -av x11-base/xorg-server
env-update && source /etc/profile

OpenBox

echo "x11-wm/openbox imlib" >> /etc/portage/package.use/openbox

emerge -av x11-wm/openbox
mkdir -p /home/timo/.config/openbox
cp /etc/xdg/openbox/* /home/timo/.config/openbox/ -v
chown -R timo:timo /home/timo/.config/

$ startx

emerge -av media-gfx/feh
vim /home/timo/.config/openbox/autostart
source $HOME/.fehbg &

# run this command in an x-session (creates ~/.fehbg):
$ feh --bg-scale /home/timo/gentoo_wallpaper.jpg

emerge -av obconf
emerge -av x11-terms/xterm-327

Openbox Menu

Note
To automatically generate a right-click openbox menu obmenu-generator does a good job. Later I decided to have my own menu.xml which is cleaner
emerge -av x11-misc/obmenu-generator
$ obmenu-generator -i -s
config/openbox/menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu>
    <menu id="root-menu" label="OpenBox 3">
    <item label="Terminal"> <action name="Execute">
        <execute>lxterminal</execute>
    </action> </item>
    <item label="File Manager"> <action name="Execute">
        <execute>pcmanfm</execute>
    </action> </item>
    <item label="Firefox"> <action name="Execute">
        <execute>firefox-bin</execute>
    </action> </item>
    <item label="Epiphany"> <action name="Execute">
        <execute>epiphany</execute>
    </action> </item>
    <item label="Thunderbird"> <action name="Execute">
        <execute>thunderbird-bin</execute>
    </action> </item>
    <item label="Tor Browser"> <action name="Execute">
        <execute>/home/timo/prg/tor-browser_en-US/Browser/start-tor-browser</execute>
    </action> </item>
    <separator/>
    <item label="Blender"> <action name="Execute">
        <execute>blender</execute>
    </action> </item>
    <item label="Gimp"> <action name="Execute">
        <execute>gimp</execute>
    </action> </item>
    <item label="Darktable"> <action name="Execute">
        <execute>darktable</execute>
    </action> </item>
    <separator/>
    <item label="Pulse Audio"> <action name="Execute">
        <execute>pavucontrol</execute>
    </action> </item>
    <item label="Alsamixer"> <action name="Execute">
        <execute>alsamixer</execute>
    </action> </item>
    <separator/>
    <menu id="40" label="OpenBox">
         <menu id="client-list-menu"/>
         <item label="Reconfigure"> <action name="Reconfigure"/> </item>
         <separator/>
         <item label="Exit"> <action name="Exit"/> </item>
         </menu>
    </menu>
</openbox_menu>

Keyboard Layout

emerge -av x11-apps/setxkbmap
vim /home/timo/.config/openbox/autostart
setxkbmap de

Display Manager

vim /etc/conf.d/xdm
DISPLAYMANAGER="slim"

emerge -av x11-misc/slim
rc-update add xdm default
rc-service xdm start

vim /etc/slim.conf
login_cmd           exec /bin/bash -login ~/.xinitrc %session

File Manager

emerge -av x11-misc/pcmanfm

Tint2

add USE flags battery to /etc/portage/make.conf

emerge -av --changed-use --deep @world

echo "x11-misc/tint2 tint2conf" >> /etc/portage/package.use/tint2
emerge -av tint2

vim /home/timo/.config/openbox/autostart
(sleep 2s && tint2) &

tint2conf
emerge -av app-office/orage

Laptop Special Keys

emerge -av xev

Brightness

test setting through kernel

echo 100 > /sys/class/backlight/intel_backlight/brightness
echo 5237 > /sys/class/backlight/intel_backlight/brightness
emerge -av sys-power/acpilight
rc-update add acpilight boot
/etc/init.d/udev restart
vim .config/openbox/rc.xml
  <!-- Keybindings for screen bightness  -->
  <keybind key="XF86MonBrightnessUp">
    <action name="Execute">
      <command>xbacklight +10</command>
    </action>
  </keybind>
  <keybind key="XF86MonBrightnessDown">
    <action name="Execute">
      <command>xbacklight -10</command>
    </action>
  </keybind>

Pulseaudio

vim /etc/portage/make.conf
USE="pulseaudio"

emerge -av --changed-use --deep @world

emerge -av media-sound/pavucontrol media-sound/paprefs
etc-update

gpasswd -d timo audio

emerge -av media-libs/alsa-utils
emerge -av media-plugins/alsa-plugins

Tools

emerge -av app-portage/gentoolkit app-admin/sudo app-portage/cpuid2cpuflags
emerge -av www-client/firefox-bin www-client/chromium www-client/epiphany
emerge -av mail-client/thunderbird-bin
emerge -av lxde-base/lxterminal app-text/evince
emerge -av media-video/mpv
emerge -av media-gfx/imagemagick media-gfx/eog media-gfx/exiv2

emerge -av app-portage/eix
eix-update

emerge -av net-misc/youtube-dl
emerge -av x11-apps/xrandr lxde-base/lxrandr

Darktable

The following REQUIRED_USE flag constraints are unsatisfied:
    cpu_flags_x86_sse3

cpuid2cpuflags
vim /etc/portage/make.conf
CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"

emerge -av --changed-use --deep @world
emerge -av media-gfx/darktable

Nvidia Proprietary Driver

Getting this to work was a bit tricky for me. Someone has written an excellent wiki page: https://wiki.gentoo.org/wiki/NVIDIA/Optimus I highly recommend reading it

vim /etc/portage/make.conf
VIDEO_CARDS="nvidia intel i965"
USE="udev nvidia acpi glamor"
kernel config
grep -i firmware /usr/src/linux/.config
CONFIG_PREVENT_FIRMWARE_BUILD=y
CONFIG_FIRMWARE_IN_KERNEL=y
[b]CONFIG_EXTRA_FIRMWARE="i915/skl_dmc_ver1_26.bin"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"[/b]
# Altera FPGA firmware download module
# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set
# CONFIG_FIRMWARE_EDID is not set
# Firmware Drivers
CONFIG_FIRMWARE_MEMMAP=y
# CONFIG_GOOGLE_FIRMWARE is not set
# EFI (Extensible Firmware Interface) Support
# CONFIG_TEST_FIRMWARE is not set
vim  /etc/modprobe.d/blacklist.conf
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist nvidia
blacklist rivatv
blacklist evbug
emerge -av --changed-use --deep @world
emerge -av x11-drivers/nvidia-drivers
Note
if kernel is rebuild run emerge @module-rebuild to rebuild the nvidia kernel modules
mkdir /etc/modules-load.d/
vim /etc/modules-load.d/nvidia.conf
nvidia
rc-update add modules boot
vim /etc/default/grub
GRUB_GFXMODE=1920x1080
grub-mkconfig -o /boot/grub/grub.cfg
mkdir -p /usr/lib/X11/xdm
vim /usr/lib/X11/xdm/Xsetup_0
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
mkdir /etc/X11/xdm/
vim /etc/X11/xdm/xdm-config
DisplayManager._0.setup: /usr/lib/X11/xdm/Xsetup_0
vim  /etc/portage/make.conf
CONFIG_PROTECT="/usr/lib/X11/xdm/Xsetup_0"
vim /home/timo/.xinitrc
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session openbox-session
/etc/X11/xorg.conf
nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 415.18

Section "ServerLayout"

   #Screen 1 "nvidia"
   #Screen 0 "intel"
   #Inactive "nvidia"
    Identifier     "layout"
    Screen      0  "nvidia" 0 0
    Inactive       "intel"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "InputDevice"
    # generated from data in "/etc/conf.d/gpm"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "Monitor"
   # in millimeters
    Identifier     "builtin"
    DisplaySize     382    214
EndSection

Section "Device"

   # Change the BusID if necessary. Tips: (lspci | grep -E "VGA|3D") (Change 01:00.0 to 1:0:0)
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:00:0"
EndSection

Section "Device"

   #Driver "intel"
   # Change BusID if necessary. Tips: (lspci | grep -E "VGA|3D") (Change 00:02.0 to 0:2:0)
   #Option "AccelMethod" "none"
   # The next three options help to reduce tearing, but reduce performance
    Identifier     "intel"
    Driver         "modesetting"
    Option         "AccelMethod" "sna"
   #Option "AccelMethod" "uxa"
    Option         "TearFree" "True"
    Option         "Tiling" "True"
    Option         "SwapbuffersWait" "True"
    BusID          "PCI:0:02:0"
EndSection

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "builtin"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "Yes"
    Option         "ConnectedMonitor" "DFP-0"
    Option         "CustomEDID" "DFP-0:/sys/class/drm/card0-eDP-1/edid"
    Option         "UseEDID" "true"
#   Option "AccelMethod" "none"
    SubSection     "Display"
        Depth       24
        Modes      "nvidia-auto-select"
    EndSubSection
EndSection

Section "Screen"
    Identifier     "intel"
    Device         "intel"
    Monitor        "builtin"
EndSection
lspci | grep VGA
echo "busid=0:02:0" > /etc/directfbrc
eselect opengl set nvidia
eselect opencl set nvidia
emerge -av  x11-apps/mesa-progs
media-libs/opencv cuda opencl
media-libs/openimageio opencv
media-libs/opensubdiv cuda opencl ptex tbb
Troubleshoot

see:

dmesg
xrandr --listproviders
less /var/log/Xorg.0.log

Blender

vim /etc/portage/package.use/blender
media-gfx/blender cycles boost openexr tiff openimageio player game-engine bullet fftw openal jemalloc opensubdiv openvdb openvdb-compression
vim /etc/portage/make.conf
USE="ffmpeg X opengl threads tiff fftw openexr expat"
emerge -av media-gfx/gimp media-gfx/blender
emerge -av dev-util/nvidia-cuda-toolkit

gPhoto2

/etc/portage/make.conf
USE="gphoto2"
emerge -av --changed-use --deep @world
emerge -av gphoto2

To import images from a camera, plug it in, change to the image import directory, and run

$ mkdir pics && cd $_
$ gphoto2 --get-all-files

Update The System

emerge --sync
# emerge -avuDN --with-bdeps y world
# sadly the nvidia drivers often make problems
# emerge -avuDN --exclude=x11-drivers/nvidia-drivers --with-bdeps y world
# OR
emerge -avuDN --exclude=x11-drivers/nvidia-drivers --exclude=xorg-server --exclude=xorg-drivers --with-bdeps y world

etc-update
emerge @module-rebuild
# depclean also wipes /usr/src/linux which is often needed by an upgrade
emerge -pv --depclean --exclude gentoo-sources
emerge -av --depclean --exclude gentoo-sources
revdep-rebuild
eclean -d distfiles

Update The Kernel

make olddefconfig

Generates a new configuration with default values from the ARCH supplied defconfig file while, at the same time, maintaining all the previous options set in the .config file found at /usr/src/linux/.config. This is a fast and safe method for upgrading a config file that has all the configuration options it needs for hardware support while at the same time gaining bug fixes and security patches.

https://wiki.gentoo.org/wiki/Kernel/Configuration#Configuration_tools
— unknown author

Use emerge -av meld to compare old/new kernel .config

emerge -av --update --deep --with-bdeps=y --newuse sys-kernel/gentoo-sources
# your old kernel-config is here
ls /usr/src/linux/.config
# this is your new kernel
cd /usr/src/linux-4.19.66-gentoo
make olddefconfig
# quick check the differences
meld .config /usr/src/linux/.config
# set your new kernel
eselect kernel list
eselect kernel set 1
# compile
make modules_prepare
make -j8
make modules_install
make install
emerge -av @module-rebuild

If you use an initrd run (I dont use it):

genkernel --install --no-ramdisk-modules initramfs

Whenever a new kernel is installed, GRUB2 must be reconfigured to recognize it

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

The new kernel should now be added to the bootloader. Before rebooting check the configuration generated by grub-mkconfig. If the new kernel is not the default set it with GRUB_DEFAULT=X

vim /boot/grub/grub.cfg
grep gnulinux /boot/grub/grub.cfg
# set #GRUB_DEFAULT=2
vim /etc/default/grub

Here is the current config I use on this system (still improving ;)

Troubleshooting

If the new kernel fails to boot and the error messages tell you something about cannot mount root fs or anything regarding filesystems, you most likely have forgotten to:

  • compile the SATA controller device drivers not as module (*)

  • compile the root filesystem not as module (*)

grep -i btrfs /usr/src/linux/.config
CONFIG_BTRFS_FS=y
...

grep -i sata /usr/src/linux/.config
CONFIG_SATA_AHCI=y
...

# go back to cd /usr/src/linux and
make menuconfig