archlinux setup

A brief archlinux install guide.

Final setup will be: archlinux + i3wm, booted with efi.

Before the install…

NOTES:

  • this is for gpt partitions and efi boot. And the device name here is only a reference.
  • Also note that: if you are installing the new system from a existing system, you can simply use rsync to migrate system, see wiki for details. If you want a fresh new install, the package arch-install-scripts is needed, which includes the tools like arch-chroot and genfstab etc.
  • Before you get started, use lsblk to list out the disks and identify onto which disk you want to install the system.

Make sure the system clock is accurate before the install.

1
2
timedatectl set-ntp true
timedatectl status

Make sure internet is available. A wired connection is recommended. See wiki for details.

Preparing the disk.

THIS TUTORIAL IS DEDICATED TO UEFI + GPT setup, if you have an older machine that only support BIOS/MBR, the partitions and bootloader part should be different.

Disk Partition & Formatting

If you already have the partitions simply skip this section.
use tool cgdisk to make partitions.

1
2
3
cgdisk DEVICENAME
# the DEVICENAME is often something like /dev/sda, find this with lsblk.
# Partitioning will typically wipe your disk so don't fuck up.

for further disk info you can use fdisk -l /dev/sdx.

The minimal partitions should look like this (swap is optional).

Partition Mount Point Type Size (typical) Device Name
boot /boot Efi System 256-512MB /dev/sda1
swap linux swap 2 * Memory Size /dev/sda2
root / linux filesystem as large as needed /dev/sda3

If you already have another OS with EFI(e.g. you want dual booting), you can continue using an existing boot partition.

Disk formatting

Formatting the boot and root partition

1
2
mkfs.vfat -F32 /dev/sda1
mkfs.ext4 /dev/sda3

Use swap partition (Optional)

1
2
mkswap /dev/sda2
swapon /dev/sda2

Note: package dosfstools may be needed for vfat file system.

Mount the Disk

1
2
3
4
mount /dev/sda3 /mnt
mkdir -p /mnt/home 
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot

System Install and Basic Configs

Before the install, you may want to choose a faster mirror. Expecially when you are from CHINA… China’s gov is a total blyat… Edit /etc/pacman.d/mirrorlist and run pacman -Syy

install basic system

1
pacstrap /mnt base linux linux-firmware

config fstab

# genfstab -U /mnt >> /mnt/etc/fstab 

Note: before running genfstab, I recommend you to use lsblk or fdisk -l etc. to check if the partitions are correctly mounted.

After the system installing, genfstab should not be used anymore. Edit /etc/fstab manually afterwards if needed.

chroot into the new installed system

1
arch-chroot /mnt

basic system config

Setting Timezone

# timedatectl list-timezones
# timedatectl set-timezone Zone/SubZone

Locale and Language edit /etc/locale.gen, uncomment the language encoding that you need. e.g. I have

en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_CN.GBK GBK
zh_CN.UTF-8 UTF-8
zh_CN GB2312

then run locale-gen to generate locales..

create /etc/locale.conf and set LANG variable, e.g.

LANG=en_US.UTF-8

Network Manager I prefer Network Manager.. here we disable dhcpd(if used during the installation) and install network-manager

1
2
3
sudo pacman -S networkmanager
sudo systemctl disable dhcpcd
sudo systemctl enable NetworkManager.service

Create new user It’s not recommended to use root user on a daily basis.

useradd -G wheel username
passwd username
mkdir -m 700 /home/username
chown username:username /home/user

Then edit sudoers to grant new user root privilege. Use visudo command to edit.

username ALL=(ALL) ALL

Boatloader (fore UEFI)

Check again all the partitions are correctly mounted!

1
2
3
pacman -S grub os-prober efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck
grub-mkconfig -o /boot/grub/grub.cfg

Now you can unmount the disk and reboot. If nothing went wrong, you should be able to boot into the new system with grub.

Desktop Environment, Sound and Graphic.

install xorg

pacman -S xorg xorg-server xorg-utils xorg-xinit xorg-xfontsel xorg-font-util

install and setup i3

pacman -S i3-wm i3status i3blocks i3lock dmenu dunst

Note: packages other than i3-wm are optinal. There are also forks of i3 that you may choose from e.g. i3-gaps which gives extra gap between panels. Also I’m not going to cover the usage and detailed config of i3-wm and other utils here. This is only a setup guide.

To run i3, edit ~/.xinitrc and add at the end:

exec i3

Now run startx to launch X and i3! (A basic config will be generated during the first startup)

Sound

Alsa is installed by default, install alsa-utils for a control panel alsa-mixer.

graphic Note: this section is only for intel integrated graphic card users..

pacman -S mesa xf86-video-intel 

Preventing graphic tearing: add or edit /etc/X11/xorg.conf.d/20-intel.conf

Section "Device"
  Identifier "Intel Graphics"
  Driver "intel"

  Option "TearFree" "true"
EndSection

Then reboot..

something else

fonts Lacking proper fonts sometimes causes problems.. Here are the fonts I installed.

adobe-source-code-pro-fonts
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
wqy-bitmapfont
ttf-font-awesome
ttf-arphic-ukai
ttf-arphic-uming
ttf-dejavu
ttf-font-awesome
ttf-symbola

Terminal, shell and editor

I currently use suckless’s st terminal. The build I’m using can be found in this site’s static file page.

I also use fish as shell, ranger and nnn as file browsers, neovim as editor and plugged as its plugin manager.

Fcitx and input method

pacman -S fcitx fcitx-configtool fcitx-googlepinyin fcitx-libpinyin

then add the folling lines to .xinitrc

# fcitx input
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx

and the following to i3 config

exec --no-startup-id fcitx -d

Other useful settings

add this to .xinitrc to swap esc and caplock (for vim users)

# swap caps
setxkbmap -option caps:swapescape

also this one (which will change your life)

xset r rate 300 50 
edited 20.04.2024
created 04.06.2020
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<