Arch Linux 安裝

2024-08-02 linux Arch linux

環境

  • KVM
    • CPU: 2 core
    • RAM: 2G

環境調查事項

  • 開機方式: bios_grub or UEFI

環境規劃

硬碟

  • swap: 4G
  • bios_grub: 1M
  • /boot: 1GB

下載

wget https://linux.cs.nctu.edu.tw/archlinux/iso/2024.08.01/archlinux-2024.08.01-x86_64.iso

安裝 SOP

選擇鏡像站

可以從這裡選擇較進的鏡像站: https://archlinux.org/mirrorlist/

  • /etc/pacman.d/mirrorlist
Server = http://archlinux.cs.nycu.edu.tw/$repo/os/$arch
# 檢查網路
ping -c 3 8.8.8.8
# 檢查是否為UEFI模式開機
cat /sys/firmware/efi/fw_platform_size
# 分割硬碟
fdisk -l
# Create a GPT partition table:
# parted /dev/nvme0n1 mklabel gpt
# parted /dev/nvme0n1

# mkpart primary 1MiB 2MiB
# set 1 bios_grub on
# mkpart primary 2MiB 100%
# ctrl + D

gdisk /dev/nvme0n1

# /dev/sda1 -> 1M (boot) 1G (efi_system_partition)
# /dev/sda2 -> 4G (swap)
# /dev/sda3 -> (/)

# 檢查結果
fdisk -l

mkfs.fat -F 32 /dev/efi_system_partition
mkfs.ext4 /dev/sd(磁碟編號)(分割區編號)

# SWAP
mkswap /dev/sda2
swapon /dev/sda2

# 設定時間
timedatectl set-ntp true

mount /dev/sda3 /mnt

# 初始化根目錄
pacstrap /mnt base base-devel linux-lts

# Wi-Fi 硬體
pacstrap /mnt iw dialog wpa_supplicant

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

# 進入基礎系統

arch-chroot /mnt


# 安裝 linux 穩定版
sudo pacman -S linux-lts
# 安裝 Intel 的微碼
sudo pacman -S intel-ucode
# 安裝 AMD 的微碼
sudo pacman -S linux-firmware
# 安裝基本套件
pacman -S vim grub openssh firewalld neofetch networkmanager
# 設定時區
ln -sf /usr/share/zoneinfo/Asia/Taiwan /etc/localtime
# 將系統時間設定為 UTC
hwclock -w --utc
# 語系設定
vim /etc/locale.gen
# en_US.UTF-8
# zh_TW.UTF-8
# zh_TW.BIG5

locale-gen

vim /etc/locale.conf
# LANG=en_US.UTF-8
# LANGUAGE=en_US

# 主機名稱
echo "pollo-latitude-5310" >/etc/hostname

## 主機帳號
useradd -m -s /bin/bash -u 1000 pollochang
gpasswd -a pollochang wheel
passwd pollochang
visudo
# %wheel ALL=(ALL) ALL 取消註解


# BIOS + MBR 
grub-install /dev/vda --recheck
grub-mkconfig -o /boot/grub/grub.cfg


# efi
pacman -Sy grub efibootmgr dosfstools
mkdir -p /boot/efi
mount /dev/nvme0n1p1 /boot/efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=archgrub --recheck
# Installing for x86_64-efi platform.
# Installation finished. No error reported.
# grub-mkconfig -o /boot/grub/grub.cfg
# Generating grub configuration file ...
# Found linux image: /boot/vmlinuz-linux-lts
# Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux-lts.img
# Found fallback initrd image(s) in /boot:  intel-ucode.img initramfs-linux-lts-fallback.img
# Warning: os-prober will not be executed to detect other bootable partitions.
# Systems on them will not be added to the GRUB boot configuration.
# Check GRUB_DISABLE_OS_PROBER documentation entry.
# Adding boot menu entry for UEFI Firmware Settings ...
# done



systemctl enable sshd
systemctl enable firewalld
systemctl enable NetworkManager
sudo firewall-cmd --permanent --zone=public --change-interface=eno2 &&\
firewall-cmd --reload

# 筆電
sudo systemctl enable bluetooth

exit

reboot
# 配置系统默認编辑器: /etc/profile
export EDITOR='vim'

yay

pacman -S git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si # 不可以使用 root

常用開發工具

sudo pacman -S git wget

桌面安裝

sudo pacman -Sy xorg
sudo pacman -Sy xf86-video-intel # intel 內顯
pacman -S plasma-meta krusader
# qt6-multimedia-ffmpeg 選這個
# qt6-multimedia-gstreamer
# jack: 專業音樂處理
# pipewire-jack: 通用

# 字體
# 思源字體全系列
sudo pacman -Sy $(pacman -Ssq noto-fonts)
# 文泉驛全系列
sudo pacman -Sy $(pacman -Ssq wqy-)

sudo systemctl enable sddm

# 32 位元支持
sudo vim /etc/pacman.conf
# 去掉註解 [multilib]

sudo pacman -Syu

sudo systemctl disable iwd

sudo pacman -Sy gtk3 webkit2gtk
git clone https://github.com/bertvandepoel/tabby.git
cd tabby
make -j $(nproc) && sudo make install

# 遠端桌面
pacman -S xrdp xorgxrdp-glamor pulseaudio-module-xrdp
  • 會有一大堆奇怪的選擇
[root@archlinux-desktop ~]# pacman -S plasma-meta krusader
resolving dependencies...
:: There are 2 providers available for qt6-multimedia-backend:
:: Repository extra
   1) qt6-multimedia-ffmpeg  2) qt6-multimedia-gstreamer

Enter a number (default=1): ^C
Interrupt signal received

[root@archlinux-desktop ~]# pacman -S plasma-meta krusader
resolving dependencies...
:: There are 2 providers available for qt6-multimedia-backend:
:: Repository extra
   1) qt6-multimedia-ffmpeg  2) qt6-multimedia-gstreamer

Enter a number (default=1): 1
:: There are 2 providers available for jack:
:: Repository extra
   1) jack2  2) pipewire-jack

Enter a number (default=1): 2
:: There are 10 providers available for ttf-font:
:: Repository extra
   1) gnu-free-fonts  2) noto-fonts  3) ttf-bitstream-vera  4) ttf-croscore  5) ttf-dejavu
   6) ttf-droid  7) ttf-ibm-plex  8) ttf-input  9) ttf-liberation  10) ttf-mona-sans

Enter a number (default=1): 1
:: There are 2 providers available for emoji-font:
:: Repository extra
   1) noto-fonts-emoji  2) ttf-joypixels

Enter a number (default=1): 1

遠端桌面

xrdp + xorg

yay -S xrdp
sudo pacman -S xorg-server xorg-xinit xorg-apps
sudo firewall-cmd --permanent --add-port=3389/tcp
sudo firewall-cmd --reload
  • ~/.xinitrc

添加你希望啟動的桌面環境。對於 KDE,你可以添加以下行

exec startplasma-x11
sudo systemctl enable xrdp --now

常用軟體安裝

yay -S google-chrome nmon forticlient-vpn balena-etcher
ibus-daemon -drxR
sudo pacman -U ./tabby-1.0.211-linux-x64.pacman
sudo pacman -S zsh fcitx5 fcitx5-configtool fcitx5-gtk fcitx5-qt fcitx5-chewing remmina freerdp

/usr/bin/libreoffice

export XMODIFIERS="@im=fcitx"
export QT_IM_MODULE="fcitx"

安裝驅動程式

sudo pacman -S bluez bluez-utils bluedevil fwupd vulkan-intel mesa sof-firmware ntfs-3

touchpad

X11 環境

sudo pacman -S touchegg
yay touch

筆電電源管理

sudo pacman -S power-profiles-daemon

更換 GRUB

sudo cp . /usr/share/grub/themes/Distro -rf
  • /etc/default/grub
#GRUB_THEME=
GRUB_THEME="/usr/share/grub/themes/Distro/theme.txt" #修改后

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

日常維護

# 更新數據庫
sudo pacman -Syyu
sudo pacman -Syu

錯誤處理

yay: error while loading shared libraries: libalpm.so.14: cannot open shared object file: No such file or directory

  • 原因: pacman 7 之後移除 libalpm.so.14

  • 解決方式:

建一個軟連結騙他吧

sudo ln -s /usr/lib/libalpm.so.15.0.0 /usr/lib/libalpm.so.14

參考資料