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

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 myhostname.localdomain myhostname

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


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

Install dwm, dmenu and st


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

    #remainingBattery = $(cat /sys/class/power_supply/BAT0/capacity)+"%"
    xsetroot -name "$(cat /sys/class/power_supply/BAT0/capacity)% | $( date +"%F %R" )"
    sleep 1m    # Update time every minute
done &

## Autostart section
pcmanfm & 

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

# Dropbox
dropbox start -i &

xwallpaper --stretch ~/projects/ravisagar-wallpapers/2020-11-10_burnham-park-hall.jpg

exec sxhkd &
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 packman -S fakeroot

sudo pacman -Syy

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

$ sudo chown -R tecmint:tecmint 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.

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)
xsetroot -name "$currentsong | $brightness | $power | $( date )"

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
      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}

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.

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%
	Sharename       Type      Comment
	---------       ----      -------
	public          Disk      Public Folder
	IPC$            IPC       IPC Service (Samba 4.4.14)
SMB1 disabled -- no workgroup available

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

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

25 Install