Home / About / The Way I Work / Gentoo Linux on a Thinkpad X260

Installation Notes

Gentoo Linux on a Thinkpad X260

An archive of the steps taken to install and configure Gentoo Linux on a Thinkpad X260 using GNU+Linux. Last updated on 11 May 2020

OS: Gentoo Base System release 2.6 x86_64
Host: 20F6CTO1WW ThinkPad X260
Kernel: 5.4.38-gentoo
Packages: 831 (emerge)
Shell: bash 5.0.17
Resolution: 1920x1080
WM: dwm
Theme: Arc [GTK2/3]
Icons: Blue-Maia [GTK2/3]
Terminal: urxvt
Terminal Font: Hack
CPU: Intel i7-6600U (4) @ 2.600GHz
GPU: Intel Skylake GT2 [HD Graphics 520]
Memory: 1170MiB / 15420MiB


Thinkpad X260 Specs

THINKPAD X260
X260 Hardware Manual
X260 User Guide
X260 Platform Specifications



Installation Notes - Gentoo Linux


PREPARE THE DISK
root # cfdisk /dev/sda

/dev/sda1  *   256M    83 linux
/dev/sda2      465.5G  83 linux


FORMAT BOOT PARTITION
root # mkfs.ext4 -j -T small /dev/sda1
LOAD THE DM-CRYPT MODULE
root # modprobe dm-crypt
CREATE LUKS VOLUME
root # cryptsetup luksFormat /dev/sda2
root # cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/sda2
UNLOCK LUKS VOLUME
root # cryptsetup luksOpen /dev/sda2 cryptmain
Enter your password.
You will now have access to your partition in /dev/mapper/cryptmain. Keep in mind the name “cryptmain” was chosen randomly and is just the name of the file that will represent the unlocked partition. You can change it every time you unlock it if you want.

CREATE THE PHYSICAL VOLUME AND VOLUME GROUP
root # pvcreate /dev/mapper/cryptmain
root # vgcreate vg /dev/mapper/cryptmain
CREATE TWO LOGICAL VOLUMES IN OUR NEW VOLUME GROUP [VGNAME].
root # lvcreate --size 2G --name swap vg
root # lvcreate --extents 100%FREE --name root vg
root # vgchange --available y
FIND THE REMAINING SPACE AVAILABLE WITH THE FOLLOWING COMMAND.
root # vgdisplay
If you look at the value for the field "PE Total" you will see how much space is available for allocation. Other fields can also be helpful to such as "allocated" and "free".

At this point you now have two logical volumes for swap and root respectively. You can now format them as you normally would.
root # mkswap /dev/mapper/vg-swap
root # mkfs.ext4 /dev/mapper/vg-root
At this point the rest of the gentoo handbook applies as normal.
root # swapon /dev/mapper/vg-swap

root # mount -t ext4 /dev/mapper/vg-root /mnt/gentoo
root # mkdir -p /mnt/gentoo/boot
root # mount -t ext4 /dev/sda1 /mnt/gentoo/boot
SET DATE AND TIME
root # date MMDDhhmmYYYY
Download and install stage3 into /mnt/gentoo Start sshd, set root passwd, create user and passwd
DOWNLOADING THE STAGE TARBALL
root # cd /mnt/gentoo
root # links https://www.gentoo.org/downloads/mirrors/
Move to the releases/amd64/autobuilds/ directory. There all available stage files are displayed (they might be stored within subdirectories named after the individual sub-architectures). Select one and press d to download.

VALIDATE THE DOWNLOAD
root # sha512sum stage3-amd64-.tar.?(bz2|xz)
UNPACK THE DOWNLOAD
root # tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
CONFIGURING COMPILE OPTIONS
root # nano -w /mnt/gentoo/etc/portage/make.conf
SELECTING MIRRORS
root # mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
Configuring the repository can be done in a few simple steps. First, if it does not exist, create the repos.conf directory:
root # mkdir --parents /mnt/gentoo/etc/portage/repos.conf
Next, copy the Gentoo repository configuration file provided by Portage to the (newly created) repos.conf directory:
root # cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

FILE: /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

[DEFAULT]
main-repo = gentoo
 
[gentoo]
location = /var/db/repos/gentoo
sync-type = rsync
sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4

COPY DNS INFO
One thing still remains to be done before entering the new environment and that is copying over the DNS information in /etc/resolv.conf. This needs to be done to ensure that networking still works even after entering the new environment. /etc/resolv.conf contains the name servers for the network.

To copy this information, it is recommended to pass the --dereference option to the cp command. This ensures that, if /etc/resolv.conf is a symbolic link, that the link's target file is copied instead of the symbolic link itself. Otherwise in the new environment the symbolic link would point to a non-existing file (as the link's target is most likely not available inside the new environment).
root # cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
MOUNTING THE NECESSARY FILESYSTEMS
root # mount -t proc /proc /mnt/gentoo/proc
root # mount --rbind /sys /mnt/gentoo/sys
root # mount --make-rslave /mnt/gentoo/sys
root # mount --rbind /dev /mnt/gentoo/dev
root # mount --make-rslave /mnt/gentoo/dev
root # mount --bind /run /mnt/gentoo/run
CHROOTING
root # chroot /mnt/gentoo /bin/bash
root # source /etc/profile
root # export PS1="(chroot) $PS1"
INSTALLING A GENTOO EBUILD REPOSITORY SNAPSHOT FROM THE WEB
root # emerge-webrsync
CHOOSING THE RIGHT PROFILE
root # eselect profile list

Available profile symlink targets:
  [1]   default/linux/amd64/17.1 
  [2]   default/linux/amd64/17.1/desktop *
  [3]   default/linux/amd64/17.1/desktop/gnome
  [4]   default/linux/amd64/17.1/desktop/kde

SELECT A PROFILE
root # eselect profile set 2
SYSTEM UPDATE
Updating the @world set
At this point, it is wise to update the system's @world set so that a base can be established.
root # emerge --ask --verbose --update --deep --newuse @world
TIME
root # echo "America/Chicago" > /etc/timezone
root # emerge --config sys-libs/timezone-data
LOCALE GENERATION
root # nano -w /etc/locale.gen
root # locale-gen
root # env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
INSTALL KERNEL SOURCES
root # emerge --ask sys-kernel/gentoo-sources
root # emerge --ask sys-apps/pciutils

REMINDER
Make sure nm-applet and networkmanager both have use flag "modemmanager"
------------------------------------------------------------------------
Device Drivers  --->
  [*] Multiple devices driver support (RAID and LVM)  --->
    <*>   Device mapper support
    <*>     Crypt target support
-*- Cryptographic API  --->
  <*>   AES cipher algorithms (x86_64)
------------------------------------------------------------------------
# wwan0 Sierra Modem
Code:	
Device Drivers  --->
   [*] Network device support  --->
  	USB Network Adapters  --->
 		<*> Multi-purpose USB Networking Framework
		<*>   CDC NCM support
		   CDC MBIM support
		   Simple USB Network Links (CDC Ethernet subset) 
		   USB-to-WWAN Driver for Sierra Wireless modems 

COMPILING AND INSTALLING
With the configuration now done, it is time to compile and install the kernel. Exit the configuration and start the compilation process:
root # make && make modules_install
root # make install

root # emerge cryptsetup

root # rc-update add sshd default
root # rc-update add dmcrypt boot
root # rc-update add lvm boot

root # emerge --ask sys-kernel/genkernel

root # genkernel --luks --lvm --install initramfs
root # nano -w /etc/fstab

#fstab
/dev/sda1            /boot  ext4 noauto,noatime,discard  0 2
/dev/mapper/vg-root  /      ext4 noatime                 0 1
/dev/mapper/vg-swap  none   swap sw                      0 0

HOST INFO
root # nano -w /etc/conf.d/hostname
CONFIGURING THE NETWORK
During the Gentoo Linux installation, networking was already configured. However, that was for the installation CD itself and not for the installed environment. Right now, the network configuration is made for the installed Gentoo Linux system.

All networking information is gathered in /etc/conf.d/net. It uses a straightforward yet perhaps not intuitive syntax. But don't fear, everything is explained below. A fully commented example that covers many different configurations is available in /usr/share/doc/netifrc-*/net.example.bz2.

FIRST INSTALL NET-MISC/NETIFRC:
root # emerge --ask --noreplace net-misc/netifrc
DHCP is used by default. For DHCP to work, a DHCP client needs to be installed. This is described later in Installing Necessary System Tools.

If the network connection needs to be configured because of specific DHCP options or because DHCP is not used at all, then open /etc/conf.d/net:
root # nano -w /etc/conf.d/net

FILE /etc/conf.d/net
Static IP definition
------------------------------------------------------------------------
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"

To use DHCP, define config_eth0:
FILE /etc/conf.d/netDHCP definition

config_eth0="dhcp"

AUTOMATICALLY START NETWORKING AT BOOT
To have the network interfaces activated at boot, they need to be added to the default runlevel.
root # cd /etc/init.d
root # ln -s net.lo net.eth0
root # rc-update add net.eth0 default
If the system has several network interfaces, then the appropriate net.* files need to be created just like we did with net.eth0.

If after booting the system we find out that the assumption about the network interface name (which is currently documented as eth0) was wrong, then execute the following steps to rectify this:

Update the /etc/conf.d/net file with the correct interface name (like enp3s0 instead of eth0).
Create new symbolic link (like /etc/init.d/net.enp3s0).
Remove the old symbolic link (rm /etc/init.d/net.eth0).
Add the new one to the default runlevel.
Remove the old one using rc-update del net.eth0 default.

HOSTS FILE
Next inform Linux about the network environment. This is defined in /etc/hosts and helps in resolving host names to IP addresses for hosts that aren't resolved by the nameserver.
root #nano -w /etc/hosts
FILE /etc/hosts
------------------------------------------------------------------------
# This defines the current system and must be set
127.0.0.1     tux.homenetwork tux localhost
  
# Optional definition of extra systems on the network
192.168.0.5   jenny.homenetwork jenny
192.168.0.6   benny.homenetwork benny

ROOT PASSWORD
Set the root password using the passwd command.
root # passwd
INIT AND BOOT CONFIGURATION
Review the settings and change where needed.
root # nano -w /etc/rc.conf
root # nano -w /etc/conf.d/keymaps
root # nano -w /etc/conf.d/hwclock
If the hardware clock is not using UTC, then it is necessary to set clock="local" in the file. Otherwise the system might show clock skew behavior.

SYSTEM LOGGER
root # emerge --ask app-admin/metalog
root # rc-update add metalog default
CRON DAEMON
root # emerge --ask sys-process/cronie
root # rc-update add cronie default
FILE INDEXING
In order to index the file system to provide faster file location capabilities, install sys-apps/mlocate.
root # emerge --ask sys-apps/mlocate
REMOTE ACCESS
To be able to access the system remotely after installation, add the sshd init script to the default runlevel:
root # rc-update add sshd default
FILESYSTEM TOOLS
Depending on the filesystems used, it is necessary to install the required file system utilities (for checking the filesystem integrity, creating additional file systems etc.). Note that tools for managing ext2, ext3, or ext4 filesystems (sys-fs/e2fsprogs) are already installed as a part of the @system set.

The tools to install if a certain filesystem is used:
-----------------------------------------------------------------------
Filesystem Package
Ext2,3, and 4 --------- sys-fs/e2fsprogs
XFS ------------------- sys-fs/xfsprogs
ReiserFS -------------- sys-fs/reiserfsprogs
JFS ------------------- sys-fs/jfsutils
VFAT (FAT32, ...) ----- sys-fs/dosfstools

INSTALLING A DHCP CLIENT
Gentoo recommends the use of net-misc/dhcpcd although many other DHCP clients are available through the Gentoo repository.

NetworkManger prefers DHCP:
root # emerge --ask net-misc/dhcp
BOOTLOADER
When using an older BIOS system supporting only MBR partition tables, no additional configuration is needed in order to emerge GRUB:
root # emerge --ask --verbose sys-boot/grub:2
INSTALL
Next, install the necessary GRUB2 files to the /boot/grub/ directory via the grub-install command. Presuming the first disk (the one where the system boots from) is /dev/sda, when using BIOS:
root # grub-install /dev/sda
CONFIGURE
Next, generate the GRUB2 configuration based on the user configuration specified in the /etc/default/grub file and /etc/grub.d scripts. In most cases, no configuration is needed by users as GRUB2 will automatically detect which kernel to boot (the highest one available in /boot/) and what the root file system is. It is also possible to append kernel parameters in /etc/default/grub using the GRUB_CMDLINE_LINUX variable.
FILE: /etc/default/grub
----------------------------------------------------------------------------------------------------------
GRUB_CMDLINE_LINUX="net.ifnames=0"
GRUB_CMDLINE_LINUX=dolvm crypt_root=/dev/sda2  real_root=/dev/mapper/vg-root rootfstype=ext4 root_trim=yes"

GENERATE THE FINAL GRUB2 CONFIGURATION:
root # grub-mkconfig -o /boot/grub/grub.cfg
REBOOT
root # exit
root # cd
root # umount -l /mnt/gentoo/dev{/shm,/pts,}
root # umount -R /mnt/gentoo
root # reboot
AFTER REBOOT
root # useradd -m -G users,wheel,audio -s /bin/bash rob
root # passwd rob


lspci Output

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers (rev 08) 00:02.0 VGA compatible controller: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07) 00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21) 00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21) 00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21) 00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller [AHCI mode] (rev 21) 00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1) 00:1c.2 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #3 (rev f1) 00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21) 00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21) 00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21) 00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21) 00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection I219-LM (rev 21) 02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01) 04:00.0 Network controller: Intel Corporation Wireless 8260 (rev 3a)


make.conf

# 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}" # # 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 # MAKEOPTS="-j3" VIDEO_CARDS="intel" INPUT_DEVICES="libinput wacom" # USE="-consolekit -systemd -gnome -qt4 -qt5 -kde -obex -ldap \ elogind gtk xinerama pulseaudio networkmanager alsa" # # # GENTOO_MIRRORS="https://gentoo.ussg.indiana.edu/ http://gentoo.ussg.indiana.edu/ https://gentoo.osuosl.org/ \ http://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/ https://mirrors.rit.edu \ /gentoo/ http://mirrors.rit.edu/gentoo/ ftp://mirrors.rit.edu/gentoo/ rsync://mirrors.rit.edu/gentoo/ \ https://mirror.sjc02.svwh.net/gentoo/ http://mirror.sjc02.svwh.net/gentoo/ \ http://gentoo.mirrors.tds.net/gentoo http://gentoo.cs.utah.edu/" #


Kernel Config

Here is my config file for kernel-config-5.4.38-gentoo