Skip to content

Instantly share code, notes, and snippets.

@ferrao
Last active October 18, 2023 23:28
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ferrao/536a43896ff6aa38ba54f2c1b86c9506 to your computer and use it in GitHub Desktop.
Save ferrao/536a43896ff6aa38ba54f2c1b86c9506 to your computer and use it in GitHub Desktop.
Arch on the Thinkpad X230

Arch Linux 2019.02.01-x86_64 on the Thinkpad X230

Documenting all my install steps

Useful Links

Live USB Boot using UEFI

  • Kernel boots fine from either USB port, but for some reason, the filesystem is not mounted if the left side USB port is used
  • Set boot mode to UEFI Only to boot in UEFI mode, double check with ls /sys/firmware/efi/efivars

Install

Wireless Networking

  • Stop dhcp on the wired network, we will use wireless:
    systemctl stop dhcpcd@enp0s25.service
    
    Interface name autocompletes with tab
  • Check driver is properly loaded
    lspci -k | grep wifi
    
  • Identify the wireless interface
    ip link
    
  • Bring the interface up
    ip link set wlp3s0 up
    ip link | grep UP
    
  • Create a new wpa_supplicant configuration file ready to use with wpa_cli:
    echo "ctrl_interface=/run/wpa_supplicant" > /etc/wpa_supplicant/wpa_supplicant.conf
    echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf
    
  • Launch wpa_supplicant: wpa_supplicant -B -i wlp3s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
  • Configure wpa_supplicant with wpa_cli:
    scan
    scan_results
    add_network
    set_network 0 ssid "MYSSID"
    set_network 0 psk "passphrase"
    enable_network 0
    save_config
    
  • Obtain an IP address
    dhcpcd wlp3s0
    ping archlinux.org
    

System Preparation

  • Update the system clock
    timedatectl set-ntp true
    timedatectl status
    
  • Partinioning the disk The bellow partition scheme was used on the default 128G SDD
    gdisk /dev/sda
    o
    n default +512M EF00
    n default +118G 8300
    n default default 8200
    c 1 EFI
    c 2 ROOT
    c 3 SWAP
    w
    
  • Create FileSystems
    mkfs.fat -F32 /dev/sda1
    mkfs.ext4 /dev/sda2
    mkswap /dev/sda3
    swapon /dev/sda3
    
  • Mount FileSystems
    mount /dev/sda2 /mnt
    mkdir /mnt/boot
    mount /dev/sda1 /boot
    
  • Install Base Software
    pacstrap /mnt base
    
  • Generate fstab
    genfstab -U /mnt >> /mnt/etc/fstab
    
  • Change root
    arch-chroot /mnt
    
  • Set timezone, locales, keyboard and fonts
    ln -sf /usr/share/zoneinfo/Europe/Lisbon /etc/localtime
    vi /etc/locale.gen (uncomment en_US.UTF-8 UTF-8 and en_US ISO-8859-1)
    locale-gen
    echo "LANG=en_US.UTF-8" > /etc/locale.conf
    loadkeys us-acentos
    echo "KEYMAP=us-acentos" > /etc/vconsole.conf
    setfont eurlatgr
    echo "FONT=eurlatgr" >> /etc/vconsole.conf
    
  • Set the root password
    passwd
    

Network Configuration

  • Set the hostname
    echo x230 > /etc/hostname
    echo "127.0.0.1    localhost x230 x230.localdomain" >> /etc/hosts
    echo "::1    localhost x230 x230.localdomain" >> /etc/hosts
    
  • Configure /etc/systemd/network/25-wired.network
    [Match]
    Name=enp0s25
    
    [Network]
    DHCP=ipv4
    
    [DHCP]
    RouteMetric=10
    
  • Configure /etc/systemd/network/25-wireless.network
    [Match]
    Name=wlp3s0
    
    [Network]
    DHCP=ipv4
    
    [DHCP]
    RouteMetric=20
    
  • Configure wpa_supplicant
    pacman -S wpa_supplicant
    wpa_passphrase SSID PASSWORD > /etc/wpa_supplicant/wpa_supplicant-wlp3s0.conf
    systemctl enable wpa_supplicant@wlp3s0
    systemctl enable systemd-networkd.service
    
  • Configure systemd-resolved Edit /etc/systemd/resolved.conf:
    FallbackDNS=4.2.2.1 1.1.1.1 8.8.8.8 9.9.9.10
    DNSSEC=allow-downgrade
    Cache=yes
    DNSStubListener=true
    ReadEtcHosts=yes
    
    Enable systemd-resolved name resolution:
    systemctl enable systemd-resolved
    
    A soft link is required for systemd-resolved to perform name resolution, if not possible at this point perform this action latter.
    ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
    

Boot Loader

  • Install packages
    pacman -S grub efibootmgr intel-ucode
    grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
    grub-mkconfig -o /boot/grub/grub.cfg
    
  • Exit chroot and reboot

System Configuration

Unprivileged User

useradd -m ferrao -G wheel
pacman -S sudo
visudo 
%wheel ALL=(ALL) ALL
passwd ferrao

Console Typematic Rate

  • Add to /etc/systemd/system/kbdrate.service:
[Unit]
Description = Keyboard repeat rate in tty.

[Service]
Type = oneshot
RemainAfterExit = yes
StandardInput = tty
StandardOutput = tty
ExecStart = /usr/bin/kbdrate -s -d 200 -r 60
 
[Install]
WantedBy = multi-user.target

Install AUR

pacman -S --needed base-devel
pacman -S vim git
su - ferrao
git clone https://aur.archlinux.org/aur.git
cd aurutils
makepkg -si
cd ..

Aur packages can be fetched with aur fetch <package> and installed with makepkg -si

Configure Power Management

sudo pacman -S acpid acpi lm_sensors
sudo systemctl enable acpid
sudo sh -c 'echo "options snd_hda_intel power_save=1" > /etc/modprobe.d/audio_powersave.conf'

TODO: laptop-mode-tools

Configure Fan Control

aur fetch thinkfan
cd thinkfan
makepkg -si
sudo sh -c 'echo "START=yes" > /etc/default/thinkfan'
sudo sh -c 'echo "options thinkpad_acpi experimental=1 fan_control=1" > /etc/modprobe.d/thinkpad-acpi.conf' 
sudo cp /usr/share/doc/thinkfan/examples/thinkfan.conf.simple /etc/thinkfan.conf

Edit /etc/thinkfan.conf:

tp_fan /proc/acpi/ibm/fan
hwmon /sys/class/thermal/thermal_zone0/temp

(0,     0,      42)
(1,     40,     47)
(2,     45,     52)
(3,     50,     57)
(4,     55,     62)
(5,     60,     72)
(6,     65,     77)
(7,     70,     80)
(127,   75,     32767)

Enable fan control:

sudo systemctl enable thinkfan
systemctl status thinkfan

Requires reloading all acpi and thinkpad related modules to get thinkfan working properly, should be ok at next reboot.

Configure LCD Panel Light Controls

  • Edit /etc/mkinitcpio.conf and make sure we have:
MODULES=(i915)
  • Edit /etc/default/grub and set the following line:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=video acpi_osi=\"!Windows 2012\""
    

Boot Splash

  • Fetch and install plymouth
aur fetch plymouth plymouth-theme-dark-arch

Edit /etc/plymouth/plymouth.conf:

Theme=dark-arch
ShowDelay=1

Add plymouth to HOOKS after base udev on /etc/mkinitcpio.conf and rebuild ram image and boot loader:

sudo mkinitcpio -p linux
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo reboot

Install Usefull Software

sudo pacman -S openssh dnsutils tcpdump lynx i7z neofetch htop lsof udisk2 bc mlocate

Alias

For some reason the halt command does not shutdow the machine, shutdown command is required

alias reboot="sudo reboot"
alias halt="sudo shutdown -h now" 

GUI Configuration

Xorg

  • Uncomment the multilib repo in /etc/pacman.conf
  • Install the xorg server
sudo pacman -S xorg xorg-xinit xf86-video-intel xf86-video-fbdev mesa mesa-demos lib32-mesa vulkan-intel libva-intel-driver xterm xorg-xclock xorg-twm xbindkeys ttf-liberation ttf-ubuntu-font-family ttf-fira-mono ttf-freefont adobe-source-code-pro-fonts ttf-freefont adobe-source-sans-pro-fonts ttf-linux-libertine xorg-fonts-type1 xorg-fonts-misc ttf-bitstream-vera ttf-dejavu bdf-unifont ttf-font-awesome libxcb xcb-util xcb-util-keysysm xcb-util-wm upower notification-daemon udiskie xdotool
  • Edit /etc/X11/xinit/xserverrc and start the server with:
exec /usr/bin/X -dpi 125.37 -nolisten tcp "$@"
  • Let Xorg start as root, required for xf86-video-fbdev:
sudo sh -c 'echo "needs_root_rights = yes" > /etc/X11/Xwrapper.conf'
  • Configure automont by adding to /etc/X11/xinit/xinitrc:
udiskie &

Keyboard

  • Configure the X typematic rate by adding to /etc/X11/xinit/xinitrc:
xset r rate 200 60
  • Configure the keyboard by adding /etc/X11/xorg.conf.d/00-keyboard.conf:
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbVariant" "altgr-intl"
EndSection

Sound

  • Instal alsa utils
sudo pacman -S alsa-utils alsa-plugins alsa-firmware
  • Map X events to alsa commands on ~/.xbindkeysrc:
# ALSA
"amixer set Master toggle"
  XF86AudioMute

"amixer set Master 5%-"
  XF86AudioLowerVolume

"amixer set Master 5%+"
  XF86AudioRaiseVolume
  • Execute xbindkeys on /etc/X11/xinit/xinitrc before any window manager

TrackPoint

  • Configure Trackpoint with libinput and xorg by setting /etc/X11/xorg.conf.d/20-trackpoint.conf
Section "InputClass"
    Identifier "trackpoint"
    Driver "libinput"
    MatchProduct "TPPS/2 IBM TrackPoint"
    MatchDevicePath "/dev/input/event*"

    Option "NaturalScrolling" "false"

    # adaptive or flat 
    Option "AccelProfile" "adaptive"

    # float between -1 and 1
    Option "AccelSpeed" "0.5"
EndSection

Dual Head

pacman -S arandr

BSPWM Window Manager

  • Fetch and install required packages
sudo pacman -S bspwm sxhkd polybar kitty rofi dunst libnotify feh compton gtk3 gtk2 qt5-base qt4 arc-gtk-theme arc-icon-theme gtk-engine-murrine ranger xdg-utils atool
  • Add compton -Cb to /etc/X11/xinit/xinitrc
  • Execute the bspwm binary on /etc/X11/xinit/xinitrc
  • Copy configuration files
mkdir ~/.config
mkdir ~/.config/bspwm
mkdir ~/.config/sxhkd
cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm
cp /usr/share/doc/bspwm/examples/sxhkdrc ~/.config/sxhkd
ranger --copy-config=all
@betanaught
Copy link

Hi @ferrao, thanks for putting this together. I've been referencing as I go through the Arch wiki install page (as I have an x230 as well) and it's quite helpful. I believe you may have a typo when mounting the boot partition: 'mount /dev/sda1 /boot' should be 'mount /dev/sda1 /mnt/boot' because you have not changed to the new root directory yet. Please let me know if I'm misunderstanding something. Also you have close quotation marks after the output files in your echo statements when configuring wpa_supplicant.

@ferrao
Copy link
Author

ferrao commented Apr 28, 2020

Hi @betanot, I'm glad my gist was useful to you. I just wrote it down at the same time I was setting up my system, which was quite some time ago, so not sure about the boot partition thing, but what you are saying makes sense.

Regarding the extra quotation marks, I have removed those, thank you for your suggestions and I hope you enjoy your x230 as much as I do, I also have a repo containing all my config files, feel free to have a look here

@betanaught
Copy link

@ferrao, in the end, I was not able to make it work with GRUB, so I switched over to systemd-boot, but now I have a working system! I kept a list of my commands as you did and I will most likely forget about it and someone will shoot me a github message in a few months noting some typeos ;). I'll definitely take a look at your config files. Thanks again for sharing this!

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