Lucashemi

How to install arch

2022-10-14

Intro

There are a lot of people that I know that like linux and stuff but they don't want to install arch because they think it's too hard, but it's not at all and I'm gonna prove it to you. You just need to type a few commands to install arch, of course after that there is the whole configuration part but I have some repositories in my git server that can help you get up and running really fast. If you like the way it is just use it, if you don't like a particular part tweak it up or make your own, It's not really hard too.

Arch installation guide

Obviuosly you can just read the arch install guide, you might think that it's confusing and that there are so many links and stuff but if you actually put some effort you will see that it's not that complicated. But I know you are lazy and just want to copy and paste stuff so thats why I`m making this guide.

How to install arch

Installation Image

First you need an arch iso image, go to the arch download page and download the iso, choose the closest mirror for a better download speed.

Optionally you can verify the signature, generally it's a waste of time but it's a good security practice, I’m not gonna cover it in this tutorial cause it's not the focus of tutorial if you really want to just follow the installation guide in the link above.

After that you need an usb to put the image on, then just plug it on your pc and use rufus, batch or ventoy to make it bootable, again I’m not gonna cover how to do that if you don’t know something google it. Then reboot your pc and boot from the pendrive.

Keyboard

You need to change the keyboard layout if it is not from the United States. To show all layouts:

ls /usr/share/kbd/keymaps/**/*.map.gz | less

Ps: <> in this tutorial means you gotta change the template to something else. Eg.: To load a layout:

loadkeys <layoutname>

If youre using a brazilian kb you may just type:

loadkeys br-abnt2.

Verify boot mode

In case you don't know if you are using uefi or not:

ls /sys/firmware/efi/efivars

If the command outputs an error you're not.

Connect to the internet

If you are using an ethernet cable you it don't need to do anything, if you’re gonna be using wifi enter: iwctl , a new prompt will appear in there then follow these commands:

device list

station <device> scan

station <device> get-networks

station <device> connect <SSID>

After typing your wifi password, you can leave iwctl by hiting CTRL+D, now to test your internet do a ping google.com if youre receiving packets you’re fine, just press CTRL+C to quit else if youre not then you screwed up something try connecting again.

Update system clock

timedatectl status

Partition the disks

Now this is the "hardest" part of the installation, type: fdisk -l to display all of your disks, it's probably in sda that you want to install arch, you need to change it if you’re installing in another disk like sdb.

Type: fdisk /dev/<sdX>

You’re going to make the /mnt partition (main) and a swap partition if you want, if you’re using uefi you need another partition for it.

Now type m to show all the options available, you probably want to delete all the partitions you have with the d command and then type n to make a new one and type p for primary, partition number 2 (the number doesn’t really matter but I like to make the swap first), the size of the blocks are standard so just hit enter, the starting block too enter, now I like to do the swap partition first I recommend 2GB for a swap so type +2G and hit enter. Now make the same process but just press enter on everything basically(put partion number 1 instead of 2) and don't forget to make an efi partition (3) before the main one, allocate 300MB (+300M) for it. Then you need to change the partition type with t the main partition is Linux (82), the swap is solaris (83) and the efi is efi system(idk the number), then you can add a bootable flag in the main partition with a.

Format the partitions

note that your partitions and disk might be different so adjust accordingly

The main partition is ext4:

mkfs.ext4 /dev/<sdX1>

Format the swap:

mkswap /dev/<sdX2>

And if you have an efi partition:

mkfs.fat -F 32 /dev/<sdX3>

Mount the file systems

mount /dev/<sdX1> /mnt

swapon /dev/<sdX2>

If you have efi:

mount --mkdir /dev/<sdX3> /mnt/boot

Mirrors

You need the reflector program to test and select the closest mirrors, if you’re in Brazil you can use my config:

reflector --country Brazil --sort rate --latest 5 –save /etc/pacman.d/mirrorlist

Ps. You might want to delete the last one from this list in the mirrorlist file cause it's not working anymore.

Install essential packages

Use the pacstrap command to install some nice packages to your arch installation:

pacstrap -K /mnt base linux linux-firmware sudo curl wget grub efibootmgr git dhcp dhcpcd networkmanager vim man-db man-pages wpa_supplicant

If you don’t know vim change it to nano. You can add more packages if you want but these are the basic packages that you’re going to need. You can change it if you know what youre doing though.

Fstab

Generate the fstab:

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

Chroot

Now you’re going to enter the actual system(don't remove the usb yet):

arch-chroot /mnt

Time zone

List time zones:

timedatectl list-timezones

Then type: ln -sf /usr/share/zoneinfo/<Region>/<City> /etc/localtime

Tip: hit tab to autocomplete the Region and City. Another Tip: If you are in Brazil change Region to America and City to Sao_paulo

Now type: hwclock --systohc

To generate the hardware clock file.

Localization

vim /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and other needed locales.

Generate the locales: locale-gen

Then vim /etc/locale.conf

Put this line in there:

LANG=en_US.UTF-8

If you change your keyboard layout earlier you need to make it permanent vim /etc/vconsole.conf

KEYMAP=br-abnt2

Network Configuration

vim /etc/hostname

Set the name of your machine in there then save and quit.

Now vim /etc/hosts

And paste this in there, just change the hostname to the hostname you wrote in the last file:

127.0.0.1 localhost

::1 localhost

127.0.1.1 hostname

This file is for referencing these ips to your own machine your pc needs to identify itself in the network.

Ps. The ips are separated by tabs and there are no blank lines in this file.

Enable network manager for later:

systemctl enable NetworkManager.service

Initramfs

Make the init file:

mkinitcpio -P

Users

Change the root password:

passwd

Make a new user (change username to yours):

useradd -m -G wheel username

Uncomment vim /etc/sudoers:

%wheel ALL=(ALL) NOPASSWD: ALL

(Just delete the hastag before the line above)

You might need to give writing permission to it by the way:

chmod +w /etc/sudoers

Finally set the password for the user you created:

passwd username

Bootloader

Install amd-ucode or intel-ucode depending on your cpu brand:

sudo pacman -S amd-ucode

For the bootloader we are going to install grub cause it's the best of it's kind:

Ps. You may change sda to sdb or sdc if youre using a different disk, type the disk name not the partition.

grub-install --target=i386-pc /dev/sda

Then type:

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

Reboot

Type:

exit

umount -R /mnt

reboot

You may remove the usb stick after it turns off. If you did everything correctly you’re going to boot into an installed arch linux.

Post-intallation

Now of course you need to install some other packages cause you don't even have xorg installed. Since this is my guide I will share my configuration. First we are going to install the necessary packages:

sudo pacman -S xorg xwallpaper xdotool python-pywal brightnessctl xcompmgr dunst pipewire pipewire-pulse pamixer noto-fonts noto-fonts-emoji noto-fonts-cjk ttf-dejavu ttf-font-awesome firefox zsh

Ps. If you have never configured zsh before just use the standard options.

dwm

git clone https://github.com/lucashemi/dwm.git

mkdir ~/.local/src && mv dwm ~/.local/src && cd ~/.local/src/dwm && sudo make install && cd

st

git clone https://github.com/lucahemi/st.git

mv st ~/.local/src && cd ~/.local/src/st && sudo make install && cd

dmenu

git clone https://github.com/lucashemi/dmenu.git

mv dmenu ~/.local/src && cd ~/.local/src/dmenu && sudo make install && cd

dwmblocks

git clone https://github.com/lucashemi/dwmblocks.git

mv dwmblocks ~/.local/src && cd ~/.local/src/dwmblocks && sudo make install && cd

yay (AUR package manager)

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

cd yay && makepkg -si && cd

install oh my zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

mv ~/.oh-my-zsh ~/.config/zsh/.oh-my-zsh

rm ~/.zshrc ~/.zsh_history

dotfiles

git clone https://github.com/lucashemi/dotfiles.git

mv dotfiles/* .

ln -s ~/.config/x11/.xinitrc .xinitrc

ln -s ~/.config/zsh/.zshrc .zshrc

To conclude

I’ve spent more time writing this than you will spend installing it so now there is no excuse to not install it in your system.