|
|
@@ -0,0 +1,419 @@
|
|
|
+---
|
|
|
+title: "Arch Linux 安装"
|
|
|
+date: 2023-10-15T23:50:36+07:00
|
|
|
+draft: true
|
|
|
+---
|
|
|
+
|
|
|
+## 前言
|
|
|
+
|
|
|
+安装使用 Arch Linux,需要具备一定的 Linux 基础知识,至少之前使用过如 Ubuntu, Debian 之类的发行版。
|
|
|
+
|
|
|
+## 准备
|
|
|
+
|
|
|
+- 使用官方**最新**系统 iso 镜像下载地址下载 iso
|
|
|
+- 4G+ U 盘一块,一个 Rufus 或 UltraISO 工具软件
|
|
|
+
|
|
|
+## BIOS 设置
|
|
|
+
|
|
|
+- 关闭 Secure Boot
|
|
|
+- 开启 UEFI
|
|
|
+- 调整启动顺序为U盘启动
|
|
|
+
|
|
|
+## 安装
|
|
|
+
|
|
|
+### 连接网络
|
|
|
+
|
|
|
+完成 BIOS 设置后,重启计算机, 进入命令行安装界面
|
|
|
+
|
|
|
+#### 故障排除
|
|
|
+
|
|
|
+```shell
|
|
|
+rfkill unblock all
|
|
|
+```
|
|
|
+
|
|
|
+#### 列出设备
|
|
|
+
|
|
|
+```shell
|
|
|
+ip link show
|
|
|
+```
|
|
|
+
|
|
|
+#### 启动网卡
|
|
|
+
|
|
|
+```shell
|
|
|
+ip link set <wlan0> up
|
|
|
+
|
|
|
+iwctl
|
|
|
+
|
|
|
+>>device list
|
|
|
+>>station wlan0 scan
|
|
|
+>>station wlan0 get-networks
|
|
|
+>>station wlan0 connect <WiFi-SSID>
|
|
|
+>>quit
|
|
|
+
|
|
|
+ping google.com
|
|
|
+```
|
|
|
+
|
|
|
+### 设置系统时间
|
|
|
+
|
|
|
+```shell
|
|
|
+timedatectl set-ntp true
|
|
|
+```
|
|
|
+
|
|
|
+### 磁盘分区
|
|
|
+
|
|
|
+假设为全新安装,从一整块未分区硬盘开始
|
|
|
+
|
|
|
+```shell
|
|
|
+# 查看硬盘信息
|
|
|
+lsblk
|
|
|
+
|
|
|
+fdisk -l
|
|
|
+```
|
|
|
+
|
|
|
+此时,命令输出硬盘假设为 `/dev/sda` 或类似的名称,SSD 会不同,以实际环境为准为以下命令做替换
|
|
|
+
|
|
|
+```shell
|
|
|
+fdisk /dev/sda
|
|
|
+```
|
|
|
+
|
|
|
+此时进入 fdisk 命令环境,使用 fdisk 快捷键操作
|
|
|
+
|
|
|
+```shell
|
|
|
+g # 使用 gpt 格式
|
|
|
+
|
|
|
+F # 列出未分配空间
|
|
|
+
|
|
|
+p # 打印已分配分区
|
|
|
+
|
|
|
+# 开始划分 EFI 分区
|
|
|
+n # 新建分区
|
|
|
+
|
|
|
+# 接下来分区号,起始扇区为默认值即可;在“终止扇区”提示处输入 +500M Enter
|
|
|
+
|
|
|
+t # 设置分区类型
|
|
|
+L # 列出受支持的分区类型 如无意外选择 1 为 EFI System
|
|
|
+
|
|
|
+## 接下来用近似的操作划分 / 和 /home 分区
|
|
|
+## / 的分区类型为 23 Linux root(x86_64)
|
|
|
+## /home 分区类型为 48 Linux home
|
|
|
+## 如果有其他的分区方案,操作类似
|
|
|
+
|
|
|
+w # 应用分区设置并退出
|
|
|
+```
|
|
|
+
|
|
|
+#### 格式化分区
|
|
|
+```shell
|
|
|
+fdisk -l # 查看分区设置,假设 /dev/sda1 为 EFI 分区; /dev/sda2 为 / 分区; /dev/sda3 为 /home
|
|
|
+
|
|
|
+mkfs.fat -F32 /dev/sda1 # 格式化 EFI 分区
|
|
|
+mkfs.ext4 /dev/sda2
|
|
|
+mkfs.ext4 /dev/sda3
|
|
|
+```
|
|
|
+
|
|
|
+#### 挂载分区
|
|
|
+
|
|
|
+```shell
|
|
|
+mount /dev/sda2 /mnt
|
|
|
+
|
|
|
+mkdir /mnt/boot
|
|
|
+mount /dev/sda1 /mnt/boot
|
|
|
+
|
|
|
+mkdir /mnt/home
|
|
|
+mount /dev/sda3 /mnt/home
|
|
|
+
|
|
|
+mount # 检查挂载
|
|
|
+```
|
|
|
+
|
|
|
+### 安装过程
|
|
|
+
|
|
|
+#### 安装基本包
|
|
|
+
|
|
|
+```shell
|
|
|
+pacstrap /mnt base base-devel linux linux-firmware dhcpcd networkmanager vim
|
|
|
+```
|
|
|
+
|
|
|
+#### 生成 fstab 配置文件
|
|
|
+
|
|
|
+```shell
|
|
|
+genfstab -L /mnt >> /mnt/etc/fstab
|
|
|
+
|
|
|
+cat /mnt/etc/fstab # 检查文件
|
|
|
+```
|
|
|
+
|
|
|
+#### Chroot
|
|
|
+
|
|
|
+```shell
|
|
|
+arch-chroot /mnt
|
|
|
+```
|
|
|
+
|
|
|
+#### 安装包
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S dialog wpa_supplicant ntfs-3g netctl git konsole dolphin sudo
|
|
|
+```
|
|
|
+
|
|
|
+#### 设置时区
|
|
|
+
|
|
|
+```shell
|
|
|
+ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
|
+hwclock --systohc
|
|
|
+```
|
|
|
+
|
|
|
+### 设置语言
|
|
|
+
|
|
|
+```
|
|
|
+vim /etc/locale.gen
|
|
|
+```
|
|
|
+
|
|
|
+找到 en_US.UTF-8 UTF8, zh_CH.UTF-8 UTF-8, zh_HK.UTF-8 UTF-8, zh_TW.UTF-8 UTF-8 四行,去掉行首 # 号
|
|
|
+
|
|
|
+```shell
|
|
|
+locale-gen
|
|
|
+```
|
|
|
+
|
|
|
+打开 `/etc/locale.conf` 输入
|
|
|
+
|
|
|
+```shell
|
|
|
+LANG=en_US.UTF-8
|
|
|
+```
|
|
|
+
|
|
|
+#### 设置主机名
|
|
|
+
|
|
|
+```shell
|
|
|
+echo <hostname> >> /etc/hostname
|
|
|
+```
|
|
|
+
|
|
|
+编辑 /etc/hosts, 输入以下内容
|
|
|
+
|
|
|
+```shell
|
|
|
+127.0.0.1 localhost
|
|
|
+::1 localhost
|
|
|
+127.0.0.1 <hostname>.localdomain <hostname>
|
|
|
+```
|
|
|
+
|
|
|
+#### 设置 root 密码
|
|
|
+
|
|
|
+```shell
|
|
|
+passwd
|
|
|
+```
|
|
|
+
|
|
|
+#### 新建用户
|
|
|
+
|
|
|
+```shell
|
|
|
+useradd -m -G wheel <username>
|
|
|
+
|
|
|
+passwd <username>
|
|
|
+
|
|
|
+vim /etc/sudoers
|
|
|
+
|
|
|
+## 找到 `%wheel ALL=(ALL:ALL) ALL` 取消注释保存退出
|
|
|
+```
|
|
|
+
|
|
|
+#### 安装处理器微码
|
|
|
+
|
|
|
+```shell
|
|
|
+echo /proc/cpuinfo | grep 'model name' # 检查处理器
|
|
|
+
|
|
|
+pacman -S intel-ucode # intel CPU
|
|
|
+pacman -S amd-ucode # amd CPU
|
|
|
+```
|
|
|
+
|
|
|
+#### 配置系统引导
|
|
|
+
|
|
|
+本例不包含双系统的情况
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S grub efibootmgr
|
|
|
+
|
|
|
+# 部署 grub
|
|
|
+grub-install --target=x86_64-efi --efi-director=/boot --bootloader-id=grub
|
|
|
+
|
|
|
+# 生成配置
|
|
|
+grub-mkconfig -o /boot/grub/grub.cfg
|
|
|
+
|
|
|
+# 检查
|
|
|
+cat /boot/grub/grub.cfg
|
|
|
+```
|
|
|
+
|
|
|
+#### 交换文件
|
|
|
+
|
|
|
+```shell
|
|
|
+# 创建 8G 交换文件
|
|
|
+dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress
|
|
|
+
|
|
|
+chmod 600 /swapfile
|
|
|
+
|
|
|
+mkswap /swapfile
|
|
|
+
|
|
|
+swapon /swapfile
|
|
|
+
|
|
|
+# 在 /etc/fstab 文件追加新行
|
|
|
+/swapfile none swap defaults 0 0
|
|
|
+```
|
|
|
+
|
|
|
+#### 安装图像系统
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S plasma sddm
|
|
|
+
|
|
|
+systemctl enable sddm
|
|
|
+
|
|
|
+reboot
|
|
|
+```
|
|
|
+
|
|
|
+#### 安装 yay
|
|
|
+
|
|
|
+```shell
|
|
|
+git clone https://aur.archlinux.org/yay.git
|
|
|
+cd yay
|
|
|
+makepkg -si
|
|
|
+yay
|
|
|
+```
|
|
|
+
|
|
|
+#### Virtualbox Extension
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S virtualbox-guest-utils
|
|
|
+systemctl enable vboxservice.service
|
|
|
+```
|
|
|
+
|
|
|
+#### 中文环境
|
|
|
+
|
|
|
+```shell
|
|
|
+# 中文字体
|
|
|
+sudo pacman -S adobe-source-han-sans-cn-fonts
|
|
|
+sudo pacman -S adobe-source-han-serif-cn-fonts
|
|
|
+sudo pacman -S noto-fonts-sc
|
|
|
+sudo pacman -S wqy-microhei
|
|
|
+sudo pacman -S wqy-zenhei
|
|
|
+sudo pacman -S wqy-bitmapfont
|
|
|
+sudo pacman -S ttf-arphic-ukai
|
|
|
+sudo pacman -S ttf-arphic-uming
|
|
|
+sudo pacman -S opendesktop-fonts
|
|
|
+sudo pacman -S ttf-hannom
|
|
|
+
|
|
|
+# 输入法
|
|
|
+pacman -Rs $(pacman -Qsq fcitx) # 卸载 fcitx4
|
|
|
+pacman -S fcitx5 fcitx5-gtk fcitx5-qt
|
|
|
+pacman -S fcitx5-configtool
|
|
|
+pacman -S fcitx5-chinese-addons
|
|
|
+pacman -S fcitx5-rime
|
|
|
+reboot
|
|
|
+```
|
|
|
+
|
|
|
+打开 `~/.config/fcitx5/profile` 输入
|
|
|
+
|
|
|
+```shell
|
|
|
+# Default IM settings
|
|
|
+[Groups/0]
|
|
|
+# Group Name
|
|
|
+Name=Default
|
|
|
+# Layout
|
|
|
+Default Layout=us
|
|
|
+# Default Input Method
|
|
|
+DefaultIM=pinyin
|
|
|
+
|
|
|
+[Groups/0/Items/0]
|
|
|
+# Name
|
|
|
+Name=keyboard-us
|
|
|
+# Layout
|
|
|
+Layout=
|
|
|
+
|
|
|
+[Groups/0/Items/1]
|
|
|
+# Name
|
|
|
+Name=pinyin
|
|
|
+# Layout
|
|
|
+Layout=
|
|
|
+
|
|
|
+[GroupOrder]
|
|
|
+0=Default
|
|
|
+```
|
|
|
+
|
|
|
+检查环境
|
|
|
+
|
|
|
+```shell
|
|
|
+echo ${XDG_SESSION_TYPE}
|
|
|
+```
|
|
|
+
|
|
|
+编辑文件,设置环境变量
|
|
|
+
|
|
|
+```shell
|
|
|
+# X11 和 Wayland 环境输入 ~/.pam_environment
|
|
|
+GTK_IM_MODULE=fcitx5
|
|
|
+QT_IM_MODULE=fcitx5
|
|
|
+XMODIFIERS="@im=fcitx5"
|
|
|
+
|
|
|
+# X11 输入 ~/.xprofile
|
|
|
+# export fcitx5 environment variables
|
|
|
+export GTK_IM_MODULE=fcitx5
|
|
|
+export QT_IM_MODULE=fcitx5
|
|
|
+export XMODIFIERS="@im=fcitx5"
|
|
|
+
|
|
|
+# 并酌情设置 ~/.bashrc 或 ~/.profile 或 ~/.bash_profile
|
|
|
+# 添加以上 3 个环境变量
|
|
|
+
|
|
|
+# 添加自动启动 ~/.config/autostart/fcitx5.desktop
|
|
|
+[Desktop Entry]
|
|
|
+Name=Fcitx5
|
|
|
+GenericName=Fcitx5 Input Method
|
|
|
+Comment=Start Fcitx5
|
|
|
+Exec=fcitx5
|
|
|
+Icon=fcitx
|
|
|
+Terminal=false
|
|
|
+Type=Application
|
|
|
+Categories=System;Utility;
|
|
|
+StartupNotify=false
|
|
|
+X-GNOME-Autostart-Phase=Applications
|
|
|
+X-GNOME-AutoRestart=false
|
|
|
+X-GNOME-Autostart-Notify=false
|
|
|
+X-KDE-autostart-after=panel
|
|
|
+X-KDE-StartupNotify=false
|
|
|
+X-GNOME-Autostart-enabled=true
|
|
|
+# 或者输入到 ~/.xprofile
|
|
|
+fcitx5 &
|
|
|
+```
|
|
|
+
|
|
|
+重启后,在系统设置里添加 pinyin 输入法
|
|
|
+
|
|
|
+设置皮肤
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S fcitx5-material-color
|
|
|
+```
|
|
|
+
|
|
|
+配置 ~/.config/fcitx5/conf/classicui.conf
|
|
|
+
|
|
|
+```shell
|
|
|
+# We choose one theme, such as `Pink`, 'Blue', 'Black', etc.
|
|
|
+Theme=Material-Color-Pink
|
|
|
+```
|
|
|
+
|
|
|
+[参考](https://jeffreytse.net/computer/2020/11/19/how-to-use-fcitx5-elegantly-on-arch-linux.html)
|
|
|
+
|
|
|
+### 其他
|
|
|
+
|
|
|
+#### 滚动更新
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -S <package-name> # 安装
|
|
|
+pacman -Rcns <package-name> # 删除软件
|
|
|
+pacman -Syu # 更新系统
|
|
|
+```
|
|
|
+
|
|
|
+滚动更新出现 错误的处理
|
|
|
+
|
|
|
+```shell
|
|
|
+pacman -Syy
|
|
|
+pacman -S archlinux-keyring
|
|
|
+pacman-key --init
|
|
|
+pacman-key --populate archlinux
|
|
|
+pacman-key --refresh-keys
|
|
|
+pacman -Syu
|
|
|
+```
|
|
|
+
|
|
|
+#### 显卡驱动
|
|
|
+[参考](https://arch.icekylin.online/guide/rookie/graphic-driver.html)
|
|
|
+
|
|
|
+#### 故障处理
|
|
|
+
|
|
|
+插入 Arch Linux 系统的安装盘启动, 做分区格式化以后同样的挂在操作,比如本文中把 / 挂载到 /mnt,EFI分区挂载到 /boot,/dev/sda3 挂在到 /home,然后可以执行急救操作.
|