---
# System prepended metadata

title: archlinux-2022.08.05
tags: [OS]

---

# archlinux-2022.08.05

[TOC]

## sites

+ [Official Installation Guide](https://wiki.archlinux.org/title/Installation_guide_(正體中文))

---

## Disk Partition

### Disk Partition Table

| No. | Size |        Code (Type)         |   Flags   |
| --- | ---- | -------------------------- | --------- |
|  1  |   1M | ef02(bios boot partition)  | bios_grub |
|  2  | 512M | ef00(EFI system partition) |   boot    |
|  3  |  10G | 8200(linux swap)           |   swap    |
|  4  |  -1M | 8300(linux file system)    |   root    |

### Format Partition

```shell
$ mkfs.vfat -F32 -n EFI /dev/sda1  <- EFI partition (fat32)
$ mkswap -L swap /dev/sda3         <- swap
$ mkfs.ext4 -L root /dev/sda4      <- root (ext4)
```

### Mount Disk
```shell
$ mount /dev/sda4 /mnt
$ mkdir /mnt/boot
$ mount /dev/sda2 /mnt/boot
$ swapon /dev/sda3
```

---

## Install System

### Internet Connection
```shell
$ iwctl
[iwd]# device list
[iwd]# station <device> get-networks
[iwd]# station <device> connect SSID
or -> [iwd]# station <device> connect-hidden SSID

[iwd]# station <device> show
```

### Add 交大 arch mirrorlist
```shell
$ vim /etc/pacman.conf
```
```clike
[core]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist

[extra]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist

[community]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist
```

### Install
```shell
$ pacstrap /mnt base base-devel linux-lts linux-firmware efibootmgr intel-ucode
```

---

## chroot to the new system

### gen fstab
```shell
$ genfstab -U -p /mnt >> /mnt/etc/fstab
```

### chroot
```shell
$ arch-chroot /mnt
```

---

## new system settings

### Add 交大 arch mirrorlist
```shell
$ vim /etc/pacman.conf
```
```clike
[core]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist

[extra]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist

[community]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist
```

### Install some packages
```shell
$ pacman -S vim pkgfile bash-completion sudo
```

### set timezone
```shell
$ ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
hwclock --systohc
```

### locale

uncomment `en_US.UTF-8` `zh_TW.UTF-8` `zh_TW.BIG5` in `/etc/locale.gen`

```shell
$ echo LANG=en_US.UTF-8 >> /etc/locale.locale.conf
$ locale-gen
```

### hostname
```shell
$ echo <myhostname> >> /etc/hostname

$ vim /etc/hosts
 127.0.0.1  localhost.localdomain     localhost
 ::1        localhost.localdomain     localhost
 127.0.1.1  <myhostname>.localdomain  <myhostname>
```

### set password
```shell
$ passwd
```

### configure mkinitcpio
```shell
$ vim /etc/mkinitcpio.conf
```
+ Add 'ext4' to MODULES
+ Add 'resume' to HOOKS after 'udev'

### generate initrd image
```shell
$ mkinitcpio -p linux-lts
```

### set bootloader
```shell
$ pacman -S grub-bios os-prober efibootmgr
$ grub-install --efi-directory=/boot --bootloader-id=grub
$ grub-mkconfig -o /boot/grub/grub.cfg
```

### net tools

#### install
```shell
$ pacman -S net-tools dhclient dhcp dhcpcd wpa_supplicant wireless-tools iw iwd dialog networkmanager network-manager-applet
```

#### run service
```shell
$ systemctl enable NetworkManager.service
$ systemctl enable wpa_supplicant.service
$ systemctl enable dhcpcd.service
```

### exit & reboot
```shell
$ exit
$ umount -R /mnt
$ swapoff -a
$ reboot
```

---

## Post Installation
Login as `root` with the root password from above.

### configure network
```shell
$ iwctl
[iwd]# device list
[iwd]# station <device> get-networks
[iwd]# station <device> connect SSID
or -> [iwd]# station <device> connect-hidden SSID

[iwd]# station <device> show
```

#### Add DNS server
```shell
$ vim /etc/resolv.conf
```
添加以下至少 1 種 DNS
+ nameserver 168.95.192.1 #中華電信
+ nameserver 168.95.1.1   #中華電信
+ nameserver 8.8.8.8      #Google
+ nameserver 8.8.4.4      #Google

### Add User
```shell
$ vim /etc/sudoers
```
uncomment the `%wheel ALL=(ALL) ALL`

```shell
$ groupadd <myusername>
$ useradd -m -g <myusername> -G wheel,storage,power,network,uucp -s /bin/bash <myusername>
$ passwd <myusername>
```

### Enable Multilib
allow users to run 32-bit application on 64-bit installation of Arch Linux
uncomment the `[multilib]` section in `/etc/pacman.conf`
```clike
[multilib]
Include = /etc/pacman.d/mirrorlist
```

### Desktop environment

#### Wayland
```shell
$ pacman -S weston xorg-server-xwayland
```

#### Display manager
Use GNOME display manager
```shell
$ pacman -S gdm
$ systemctl enable gdm.service
```

#### Install GNOME DE
```shell
$ pacman -S gnome gnome-extra
```

### reboot
```shell
$ reboot
```

---

## Others

### fonts

#### 中文字體
```shell
$ sudo pacman -S noto-fonts-cjk
```

#### meslo
```shell
$ sudo yay -S nerd-fonts-meslo ttf-meslo-nerd-font-powerlevel10k
```


### gnome tweaks
```shell
$ sudo pacman -S gnome-tweaks
```

### fcitx5

#### Installation
```shell
$ sudo pacman -S fcitx5-im fcitx5-chewing fcitx5-mozc fcitx5-lua
```

#### IM
Add the following to `/etc/environment`
```clike
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
```
> GLFW_IM_MOCULE 只能用 ibus

### AUR

#### yay
```shell
$ cd ~/.local/src
$ git clone https://aur.archlinux.org/yay.git
$ cd yay
$ makepkg -si
```

### aurman
```shell
$ cd ~/.local/src
$ git clone https://aur.archlinux.org/aurman.git
$ cd aurman
$ makepkg -si
```

#### aur package error
if encounter
```shell
AUR package fails to verify PGP/GPG key: "unknown public key",
One or more PGP signatures could neo be verified!
```

##### Solution
if get
```shell
... ... FAILED (unkown public key <key-id>)
```

then
```shell
$ gpg --recv-key <key-id>
```