LinuxIndya | Home | Blog

Install Arch Linux on Thinkpad x220

Table of Contents

1 Introduction

So you have decided to install Arch Linux? Great. Good decision. Whatever reason you have I guess you are a bit adventurous and want to learn.

Learning Linux these days is not difficult at all, there are plenty of tutorials online and that is great but I believe that learning fundamentals and basics is very important. I have been Linux user for 20 years now and whatever I learnt was for a reason like wifi not working or volume keys not working or unable to install a program. I have always used and stuck to Fedora along with KDE or xfce and they work really nicely. These days you install Fedora and everything will work out of the box (well mostly).

When things break or when you have problems to solve or when things are easy to understand then learning happens really well. I am not leaving fedora but I am kind of switching to Arch Linux after careful consideration.

My main reasons to move are following.

  1. I want a super fast operating system that can work well on my old Laptops.
  2. I want to relearn things that I learn, almost forgot and have not been using for many years.
  3. I want to share my learnings in a form of blog or videos on my channel.
  4. Most importantly - have fun.

2 My Thinkpad configurations

In case you have the same model and want to setup Arch Linux with dwm then this tutorial will definitely help you.

Model: x220 Hard disk: 128GB SSD RAM: 4GB

3 Create the live usb drive

I downloaded the iso and created the live usb.

  • Installation process

For the installation I mostly followed the official documentation.

3.1 Boot in UEFI option

On Thinkpad x220 you have to keep the UEFI mode enabled in the BIOS. This installation is based on the assumption that you have UEFI mode enabled.

3.2 Installation Steps

Make sure you can boot from the usb. Check your boot order or when you start your Laptop press F12. Once you boot from live usb you will get the prompt and then you will have to type commands to perform the installation.

3.2.1 Verify boot mode

It is good to check whether you have booted in UEFI mode.

ls /sys/firmware/efi/efivars

3.2.2 Keyboard layout

This is kind of important especially when you have a keyboard which is in another language. Since I am in UK and I have UK keyboard so I changed the layout.

ls /usr/share/kbd/keymaps/**/*.map.gz
loadkeys uk

3.2.3 Connect to the internet

Check network interface.

ip link

Then you can use the iwctl utility to connect your wifi interface to your wifi. Alternatively you can connect the ethernet cable.

device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect SSID

Now ping your favourite site to check the connection ping www.ravisagar.in.

Update date and time.

timedatectl set-ntp true

Check status

timedatectl status

3.2.4 Create partitions

This is probably the toughest part. Don't worry it will take just 5 minutes.

First check the connected drives.

fdisk -l

Now perform fdisk on your drive. Make sure the drive is correct.

fdisk /dev/sda

Press g and create a GPT partition table because we are using UEFI.

First create the EFI partition.

Press n and add a new partition +550M

SWAP n +12G

BOOT n remaining

t: change partition type

1 (1 EFI System) 2 (19 Linux swap) 3 (20 Linux file system, default)

w: write to file system

Install base system

Install nano

pacman -S nano

edit /etc/locale.gen and uncomment enGB.UTF-8 UTF-8

create /etc/locale.conf and add this line. LANG=enGB.UTF-8

create /etc/vconsole.conf and add this line KEYMAP=uk

Edit /etc/hostname and add your hostname "ravi-x220"

Edit /etc/hosts and add matching hostname localhost ::1 localhost ravi-x220.localdomain ravi-x220

Create root password passwd

useradd -m ravisagar passwd ravisagar

usermod -aG wheel,audio,video,optical,storage ravisagar

pacman -S sudo

uncomment the line %wheel ALL=(ALL) NOPASSWD: ALL

pacman -S grub efibootmgr dosfstools os-prober mtools

mkdir /boot/EFI mount /dev/sda1 /boot/EFI

grub-install –target=x8664-efi –bootloader-id=grubuefi –recheck

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

pacman -S networkmanager emacs git systemctl enable NetworkManager

If you get Signature is unknown error then try this.

remove the /etc/pacman.d/gnupg folder and try

pacman-key –init pacman-key –populate archlinux


The X220 will not boot /efi/*/*.efi unless signed(?) into BIOS, you have to copy it to /efi/boot/bootx64.efi or /EFI/boot/bootx64.efi

exit umount -l /mnt

Post Installation

Connect to the internet

$ nmcli device wifi list $ nmcli device wifi connect SSID password password

3.2.5 You can also use nmtui which is a terminal based utility but with a UI.

3.2.6 More than one wifi device

List all devices

nmcli device status

To connect to a specific wifi device

nmcli device connect wlp3s0

If the Laptop's in built wifi doesn't work then disconnect it.

nmcli device disconnect wlp3s0

3.2.7 Driver for rtl88x2bu wifi adaptors

I bought this usb wifi dongle and trying to make it work https://github.com/cilynx/rtl88x2bu

I had to install dkms package

How to install this driver?

git clone https://github.com/cilynx/rtl88x2bu
cd rtl88x2bu/

3.2.8 I had to update kernel headers

sudo pacman -S kernel-headers

3.3 display manager

Install dwm, dmenu and st


sudo pacman -S make gcc pkg-config

4 Set your wallpaper

pacman -S wallpaper xwallpaper –stretch ~/projects/ravisagar-wallpapers/2020-11-10burnham-park-hall.jpg

man xwallpaper to check other options

5 Create .xinitrc file in your home directory.

You need to start the window manager automatically and also other application and this file is for that purpose.

Create a file ~/.xinitrc with the following content in your home directory.


# Set keyboard layout
setxkbmap gb &

# Statusbar loop
while true; do
    sh ~/.xsetroot.sh
    sleep 1m    # Update time every minute
done &

## Autostart section
pcmanfm & 

# This is copy paste
autocutsel -fork &
autocutsel -selection PRIMARY -fork &

# Dropbox
dropbox start -i &

#Set configure monitor
xrandr --output VGA-1 --auto --left-of LVDS-1

#Set random wallpaper

# Make IntelliJ work on Arch Linux with dwm
wmname LG3D

#Environment variables
export YOUTUBE_API_KEY="AIzaSyCwR3kiuBQNf_0-QRcxOfRanFgV9egiOSY"
export JIRATUTORIAL_AUTH="cmF2aXNhZ2FyQGdtYWlsLmNvbTpoZk9LUFdQdUJ3UGxjSE1vcHdkdzM2MzY="
#Xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &
exec dunst &
exec sxhkd &
exec ksnip &
exec dwm

Refer to this page for more details: https://wiki.archlinux.org/index.php/Dwm

6 Install Yay helper

I don't honestly know what it is but when I tried installing brave using pacman it didn't work and the brave website said that you need to run yay -S brave-bin

Update system packages

sudo pacman -S fakeroot

sudo pacman -Syy

sudo git clone https://aur.archlinux.org/yay-git.git

$ sudo chown -R ravisagar:ravisagar yay-git

$ cd yay-git

$ makepkg -si

7 Install brave browser

You would need yay to install brave browser.

~yay -S brave-bin~

8 File manager

Ranger seems to be good so install that.

sudo pacman -S ranger

I mostly use emacs as a file browser when dealing with text based files.

Setup ranger.

ranger --copy-config=all

It will generate the following files in ~/.config/ranger/

  • rc.conf
  • rifle.conf
  • scope.sh
  • commands.py
  • commandsfull.py

8.1 Enable previews in ranger

In your rc.conf set user_preview_script to true and restart ranger. It will then start using scope.sh to generate the image previews which is a shell script that uses w3m.

8.2 Install w3m


sudo pacman -S w3m

8.3 Install mpv

mpv is a command line utility for media consumption. Let us install it.

sudo pacman -S mpv

8.4 Few tips to use ranger effectively

  • Show hidden files on the fly: :set show_hidden true.
  • rifle.conf is the file that tell ranger which utility to use for opening files based on their extension or MIME type. Do take a look at it.

9 Display Manager - dwm basics

I am still getting used to it but I think I know enough to use it for most of my work. It is great and get things really fast. I think if you know shortcuts then you can start using it quickly.

There is a Mod key which is by default the ALT key.

  • Mod-Shift-Q to kill dwm and then restart using startx, there is a better way to do it by adding some lines in your .xinintrc
  • Mod-1, Mod-2, Mod-x will switch the workspace on top
  • Mod-Shift-x will move the current window to that workspace
  • Mod-shift-Enter will open st
  • Mod-j and Mod-k will cycle through all the windows
  • Mod-Shift-c will close current window
  • Mod-Tab works as usual but between workspaces
  • Mod-l increase size of active window
  • Mod-h decrease size of active window
  • Mod-Enter will swap will main the second window in the ring as active
  • Mod-i to increment the main and Mod-d to decrement the main window. If you pres Mod-d then the split will become horizontal and you will have to press Mod-i to return to vertical split.
  • Mod-B toggle the top bar.

Mulitple monitors? no problem.

  • Mod-, previous screen
  • Mod-. next screen
  • Mod-Shift-, move application to previous screen
  • Mod-Shit-. move application to next screen

You can watch my video or look at this very good tutorial here.

10 Audio

sudo pacman -S alsa-utils

10.1 Make sure the volume up/down and mute works.

Make changes in your /usr/src/dwm/config.h as per the code below and the run sudo make clean install

Link to github.

11 Statusbar

cat /proc/net/wireless cat /sys/class/powersupply/BAT0/capacity Create a script put it in .xinitrc and sleep the script for 1 min.

Now the cool thing is that you can also run this whenever you want, you don't have to wait for 1 minute. This is needed for things like volumne control and brightness.

In the while loop of your .xinitrc just place this instead.

sh .xsetroot.sh

Then in your home directory create this file and put the xsetroot command from your .xinitrc file to this file.

Take a look at my .xsetrootrc file.


dwm_alsa () {
    STATUS=$(amixer sget Master | tail -n1 | sed -r "s/.*\[(.*)\]/\1/")
    VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")

    printf "$STATUS $VOL"

brightness=$(cat /sys/class/backlight/acpi_video0/brightness)
power=$(cat /sys/class/power_supply/BAT0/capacity)%
currentsong=$(ncmpcpp --current-song -q)
#currentdate=$(date -d '7 hours ago')
memoryusage=$(free -h | awk '/^Mem:/ {print $3 "/" $2}')
currentweather=$(curl -s wttr.in/"Burnham,UK"?format="%t")

xsetroot -name "$currentsong | \
$memoryusage | \
$brightness | \
$power | \
$currentweather | \

We are also calling ncmpcpp --current-song -q to get the current song.

However we are not done yet. We need to call .xsetroot.sh when we press volumne up/down or brightness up/down buttons.

super + shift + a
      st alsamixer -c 1
super + shift + e
      ~/Dropbox/./emacs_portable.sh & disown & exit
super + e
      st em
	sh ~/.xsetroot.sh
	sh .xsetroot.sh
	sh .xsetroot.sh
	mpc {prev,next};
alt + {Left,Right}
	mpc {prev,next}
alt + {Up,Down}
      	mpc {stop,toggle}
	mpc {toggle,stop}
alt + {KP_Add,KP_Subtract}
	mpc volume {+2,-2}
alt + k
    st ~/.local/bin/search-youtube-dmenu.sh
super + {w,KP_Add,KP_Subtract}
      show-webcam {show,zoom_in,zoom_out}
super + c

11.1 TODO Modify .xsetroot.sh to display volume and mute properly

11.2 TODO Modify sxhkd file above so that the volume up/down and mute keys updates the statusbar properly

12 Dropbox

Yes I use dropbox mainly for syncing my org files. Emacs isone such tools that solves lot of my problems and I need Emacs on my main machine as well as secondary machine.

Update repository

sudo pacman -Sy

Download dropbox from the repository.

mkdir ~/downloads
git clone https://aur.archlinux.org/dropbox.git
cd dropbox
makepkg -s
sudo pacman -U dropbox*.pkg.tar.xz

If you get errors with the keys then do this.

gpg --recv-keys --keyserver hkp://p80.pool.sks-keyservers.net:80 FC918B335044912E

Start dropbox

dropbox-cli start

It will give you a unique url that you can copy and paste in your browser and it will authenticate.

You will then get a folder Dropbox in your home directory.

Check dropbox is running.

dropbox-cli status

To start dropbox when you start x add this in your .xinitrc

dropbox start -i &

13 Hotkeys

It is always great to start you favourite application or do something quickly by using hotkeys. I use sxhkd for doing that, it is light weight but works great and it seems quite powerful too.

Install sxhkd.

pacman -S sxhkd

Create a file /.config/sxhkd/sxhkdrc and copy some bindings from this site.

Now if you run sxhkd and try some key bindings but we need to run it automatically when startx is started so we will use our dear /.xinintrc. So add exec sxhkd & before exec dwm

cat /home/ravisagar/.config/sxhkd/sxhkdrc
super + shift + a
      st alsamixer -c 1
super + shift + e
      st ~/Dropbox/./emacs_portable.sh
	sh .xsetroot.sh
	sh .xsetroot.sh
	sh .xsetroot.sh
	mpc {prev,next}
alt + {Left,Right}
	mpc {prev,next}
alt + {Up,Down}
      	mpc {stop,toggle}
	mpc {toggle,stop}
alt + {KP_Add,KP_Subtract}
	mpc volume {+2,-2}

Check this blog as well. You can also check my video on Simple X Hotkey Daemon.

If you want to know the keys then use the xev in your terminal and press the keys.

14 Multiple displays with dwm

It is simple, first check connected displays with xrandr command.

Mirror output

xrandr --output VGA-1 --auto --same-as LVDS-1 --mode 1024x768

Extend the desktop

xrandr --output VGA-1 --auto --right-of LVDS-1

Smoothly turn off the second monitor.

xrandr --output VGA-1 --auto --right-of LVDS-1 --off

More details here.

14.1 TODO Ultrabase and second monitor

One thing that I have yet to configure is to automatically turn on/off the extended display when laptop is lifted from the ultrabase, mount/umount the external drive and set the keyboard layout again when laptop is placed on ultrabase using setxkbmap gb. I am sure there is a script that I can run when ultrabase is detected.

15 Directories

15.1 TODO Create .local/bin and keep your scripts there

15.2 TODO Add .local/bin to your path

16 Connecting to my local samba server

I mentioned in one of my previous blog that I have a samba server where I keep my files. So let us connect to it.

Install smbclient

sudo pacman -S smbclient

Create /etc/samba/smb.conf empty file because it is needed by smbclient.

List the public share on your hostname.

smbclient -L ravi-netbook -U%

Before you can mount this samba share you will have to load the cifs kernel module.

sudo modprobe cifs

I just realised that I don't have ssh.

sudo pacman -S openssh

Create a directory to mount this samba location.

sudo mkdir /mnt/ravi-netbook

Modify your /etc/fstab and add an entry for your mount

//ravi-netbook/public /mnt/mountpoint cifs _netdev,username=myuser,password=mypass 0 0

Enable and start the Network Manage wait online service.

sudo systemctl start NetworkManager-wait-online.service
sudo systemctl enable NetworkManager-wait-online.service

Now reboot your computer and test if this network storage is mounted or not.

16.1 TODO I am still trying to figure out the permission but worst case scenario I can always use sudo. No ideal but I Will fix it later.

17 Mount external hard drive of type ntfs in rw mode

If your external hard disk is formatted using ntfs then you might face problems writing to it after mounting it, however there is a solution. It is possible mount with read write access if you can install ntfs-3g.

sudo pacman -S ntfs-3g

Now mount as usual and enjoy. More details can be found here.

18 Installing development tools

Let us install some tools I need for development and automation.


sudo pacman -S groovy

It will ask you to select the source. Just press enter few times and you should be ok.f

19 Install Signal on Arch Linux

It is surprisingly easy.

sudo pacman -S signal-desktop

I faced problem when startin signal and I had to upadate my Arch linux.

sudo pacman -Syu

20 Install and configure zsh

sudo pacman -S zsh
sudo pacman -S zsh-completions

21 Install Zoom

Clone the repository and install it.

git clone https://aur.archlinux.org/zoom.git
cd zoom
makepkg -si

Uninstall Zoom

sudo pacman -Rs zoom

Upgrade by repeating the steps.

22 Install kdenlive


sudo pacman -S kdenlive

If you get an error then update the system.

sudo pacman -Syu

23 Install slack

It is easy as well.

git clone https://aur.archlinux.org/slack-desktop.git
cd slack-desktop/
makepkg -sri

All done now, use the slack command to run it.

24 Install ksnip

I was using scrot since November last year and it works nicely for taking quick screenshots but I was looking for something a bit more advanced. Especially tool where I can make annotations on the screenshots and do bit of editing on the fly. I was initially thinking of using Nimbus Chrome(Brave) extension but I didn't like the way it was asking for lot of permissions. So I found ksnip and let us install it.

git clone https://aur.archlinux.org/ksnip.git
cd ksnip/
makepkg -si
  • Shortcut to take screenshot using Shift + R from the active ksnip window
  • After opening ksnip, close it and then you can take screenshot using Ctrl + Shift + R

25 Install sxiv

I found this nice image viewer.

sudo pacman -S sxiv

26 Install fzf

27 Install jq

28 Install fonts

These fonts are quite good.

ttf-font-awesome adobe-source-code-pro-fonts

Install them using pacman.

28.1 Install fonts manually

I have my own collection of fonts from many year and wanted to use them.

Download the fonts to ~/.local/share/fonts/ directory. You can have fonts in their own directory and without directories, Arch linux will and should be able to recognise them.

You can also run fc-cache if needed but for me it worked without running it.

29 Change terminal fonts st

Modify this line in your /usr/src/st/config.h

static char *font = "Source Code Pro:pixelsize=12:antialias=true:autohint=true";

30 Transparency using Xcompmgr

Add this in your ~/.xinintrc

xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &

31 Show keystrokes on screen

Sometimes it is cool to show your keystrokes on the screen. It is possible using the following utility.

sudo paman -S screenkey

32 Install dunst

This is great for sending notifications.

After installing the package just copy the dunstrc file from Github and copy it to ~/.config/dunst/dunstrc

33 Install wget

34 Set colours of dwm based on wallpaper

Install python-pywal

35 Install tmux

Watch this video from BugsWriter.

36 Install figlet and lolcat for visual improvements of the terminal

clear; while true; do echo "Learn Linux" | figlet | lolcat; sleep 1; done

37 Install gimp

This is a must have for image editing.

Install resynthesizer.

Details here.

sudo pacman -S flatpak
flatpak install flathub org.gimp.GIMP
flatpak search org.gimp.GIMP.Plugin
flatpak install org.gimp.GIMP.Plugin.Resynthesizer

Run GIMP using this command.

flatpak run org.gimp.GIMP

38 Install inkscape

Again really good for vector graphics and comics.

39 Install unzip

40 Install cowsay

41 Install bc

42 Install mediainfo

Command line utility to get the media info.

43 Install xclip

44 Install sqlite3

This is needed for org-roam

45 Install tmux

46 Install youtube-dl

Check available formats that are available for download.

youtube-dl -F https://youtu.be/WiCRo1xto-A

You will get format code for various audio and video with different quality.

For example download the audio only.

youtube-dl -f 140 https://youtu.be/WiCRo1xto-A

Download video only.

youtube-dl -f 137 https://youtu.be/WiCRo1xto-A

Using youtube-dl you can download the best quality video and audio and merge them. First format should be of a video.

youtube-dl -f 137+140 https://youtu.be/WiCRo1xto-A

You can also create an alias is needed so we don't have to type these codes all the times. I think the code remains the same but even if they change we can write a shell script to pick the code based on the resolution we want.

alias ytdl="youtube-dl -f 137+140"

I hope it helped.

47 Install graphviz

This is needed for org-roam to generate graphs.

48 Install slock

git clone https://git.suckless.org/slock
cd slock
sudo make install

If you run slock now it will most probably not work. So modify the config.h file and enter your username an group. Check your groups using groups. Simple utility.

49 Install rsync

50 Manage partitions using fdisk

Check existing devices, partitions and types.

sudo fdisk -l

Check attached disks.


Connect to the disk your want to manage.

sudo fdisk /dev/sdd

Follow the fdisk commands to list, delete or create partitions. Press w to write changes.

Create a file system or format a partition.

mkfs.ntfs /dev/sdd1

or for linux file systems.

mkfs.ext4 /dev/sdd1

51 Install Poppler

If you want to convert pdf to text then you can use pdftotext from https://github.com/jalan/pdftotext but on Arch Linux this utility is part of poppler which you can install easily using pacman :).

sudo pacman -S poppler

52 Install simple-mtpfs

Mount android devices on Arch linux.

Install automake first.

sudo pacman -S automake
git clone https://aur.archlinux.org/simple-mtpfs.git
cd simple-mtpfs/
makepkg -si

Check connected devices. Make sure to allow in the phone for usb conennections.

simple-mtpfs -l

Mount the device.

simple-mtpfs --device 1 /srv/public/poco_x3

You might need to sudo the command if you don't see the files.

Unmount using fusermount -u mountpoint

53 PDF readers and utilities

I am trying zathura and it looks good.

sudo pacman -S zathura
sudo pacman -S zathura-pdf-poppler

Try emacs key bindings? https://gist.github.com/kmaed/3168313

54 Create pdf from multiple images

convert *.jpg -quality 50 output.pdf

Use the quality argument to create smaller sized files.

55 Convert pdf to png

convert -verbose -density 300 -trim input.pdf -quality 100 -flatten output.png

For multiple pages do this. Specify page number-1 along with input file name.

convert -verbose -density 300 -trim input.pdf[0] -quality 100 -flatten output.png

If you get error that "convert: attempt to perform an operation not allowed by the security policy `PDF' @error/constitute.c/IsCoderAuthorized/408" then do this.

sudo emacs /etc/ImageMagick-7/policy.xml

Find and edit the line <policy domain="coder" rights="none" pattern="PDF" /> to <policy domain="coder" rights="read|write" pattern="PDF" />

56 Convert docx to pdf using soffice

soffice --headless --convert-to pdf document.docx

57 Convert pdf to black and white

gs \
 -sDEVICE=pdfwrite \
 -sColorConversionStrategy=Gray \
 -dProcessColorModel=/DeviceGray \
 -dCompatibilityLevel=1.4 \
 -dBATCH \
 -dPDFSETTINGS=/default \
 -sOutputFile=output.pdf \

58 Reduce pdf size

gs \
 -sDEVICE=pdfwrite \
 -dCompatibilityLevel=1.4 \
 -dBATCH \
 -dPDFSETTINGS=/default \
 -sOutputFile=output.pdf \

Controls and features specific to PostScript and PDF input -dPDFSETTINGS=configuration

Presets the "distiller parameters" to one of four predefined settings:

/screen selects low-resolution output similar to the Acrobat Distiller (up to version X) "Screen Optimized" setting. /ebook selects medium-resolution output similar to the Acrobat Distiller (up to version X) "eBook" setting. /printer selects output similar to the Acrobat Distiller "Print Optimized" (up to version X) setting. /prepress selects output similar to Acrobat Distiller "Prepress Optimized" (up to version X) setting. /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

Reference: https://askubuntu.com/questions/113544/how-can-i-reduce-the-file-size-of-a-scanned-pdf-file

59 Combine or unite pdf files

pdfunite 1.pdf 2.pdf output.pdf

I was creating a consolidated pdf file containing all the past bills in reverse order so I used this simple command.

BILLS="$(ls -r *ravi*)"; pdfunite $BILLS phone-bills-ravi-2021-2020-2019.pdf

Use ls -r *ravi* to list the files in reverse order. The command is storing this reverse sorted list in a variable and then using the variable in the pdfunite command to combine them. Cool.

60 Install Godot

git clone https://aur.archlinux.org/godot.git
cd godot/
makepkg -si

61 Update Arch

Simple command.

sudo pacman -Syu

You might get error related to corrupt keyring, then try this command.

sudo pacman -S archlinux-keyring

If you get errors related to npm then try this.

npm r -g npm

62 Error: Failed to retrieve packages

When installing packages if you see this error then instead of doing sudo pacman -S dkms do sudo pacman -Syu dkms and it will update the databases.

You can also update your mirrors by doing sudo pacman-mirrors -g

63 Install linux-headers

While install dkms and usb wifi driver I was also getting error related to missing linux-headers-5.15.3-arch1-1 so all I had to do was to install them using sudo pacman -S linux-headers and reboot the computer and then usb wifi drivers worked perfectly :)