1 Arch Linux 的安装
ATTENTION
本教程以 BIOS/MBR 引导模式为例,UEFI 引导模式请参考 Arch Linux UEFI 安装教程。本教程以 Arch Linux 2025.04.01 版本为例,其他版本请自行调整。
1.1 前置工作
1 2 3
| $ ls /sys/firmware/efi/efivars
$ iwctl
|
运行 iwctl
进行联网(如果是有线网络,可直接跳到 ping archlinux.org
这一步)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| [iwctl]# device list
[iwctl]# station wlan0 scan
[iwctl]# station wlan0 get-networks
[iwctl]# station wlan0 connect XXX
[iwctl]# exit
$ ping archlinux.org
$ reflector --country China --save /etc/pacman.d/mirrorlist
$ systemctl stop reflector
$ vim /etc/pacman.d/mirrorlist
$ timedatectl set-ntp true
$ timedatectl status
$ pacman -Syy
|
1.2 分区挂载
WARNING
此过程必须慎重(尤其是对于双硬盘/多硬盘等存有大量或高价值数据者),严重者可能会丢失所有数据!
此处使用 SATA 硬盘为例
如果你使用的是 NVMe 硬盘,请将 /dev/sda
替换为 /dev/nvme0n1
或者其他对应的设备名称。
第一种方法:使用 cfdisk (方便快捷,推荐新手使用)
第二种方法:使用 fdisk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| $ fdisk /dev/sda
Command (m for help): o
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): First sector (2048-X, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-X, default X): +10G
Command (m for help): t
Hex code or alias (type L to list all): 82
Command (m for help): n
Command (m for help): w
|
进入 cfdisk 程序,并且对第一块硬盘进行编辑操作(得看你这里是第几块硬盘安装系统,如果是第二块就 sdb ,第三块就 sdc …以此类推)。
进入以后你会看到你的分区信息。
操作方法(按键盘上下键选择分区,左右键选择功能):
- 如果你想删除分区,请将光标移到
delete
并按下回车
- 如果你想创建分区则移到列表下的 free space 按
new
- 如果是调节你想要的分区的大小,请按
resize
- 更改分区类型按
type
请准备两个空闲分区来安装 Arch Linux 。
准备一个任意大小(建议 20GB 以上)的分区(假设为 sda1 ,请根据实际情况判断),和一个等于你的 RAM (运行内存) 容量的 3/4 或全部的分区(假设为 sda2 ,请根据实际情况判断)。
将 sda1 的分区类型改为 83 Linux
, sda2 的分区类型改为 82 Linux Swap/Solaris
更改完毕后按左右键选择 write 按回车, 输入yes
,再按一下。
至此, arch 的分区工作就完成了。
1.3 安装 Arch linux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| $ pacstrap /mnt linux linux-firmware linux-headers base base-devel vim bash-completion iwd dhcpcd networkmanager
$ genfstab -U /mnt >> /mnt/etc/fstab
$ cat /mnt/etc/fstab
$ arch-chroot /mnt
$ pacman -Syy
$ pacman -S grub amd-ucode intel-ucode
$ lsblk
$ grub-install /dev/sda
$ grub-mkconfig -o /boot/grub/grub.cfg
$ systemctl enable iwd dhcpcd
$ passwd root
|
1.4 重启并进入下一步工作
1 2 3 4 5 6 7 8
| $ exit
$ umount /mnt
$ reboot
|
至此,Archlinux的基本安装就已经结束了。但是还没完,因为还要配置、本地化和安装桌面环境等操作。
2 Arch Linux 的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| $ iwctl
$ ping archlinux.org
$ vim /etc/hostname
arch
$ vim /etc/hosts
127.0.0.1 localhost ::1 localhost 127.0.1.1 arch.localdomain arch
$ timedatectl set-timezone Asia/Shanghai && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && hwclock --systohc
$ timedatectl set-ntp true
$ timedatectl status
$ vim /etc/skel/.bashrc
export EDITOR='vim'
$ cp -a /etc/skel/. ~/
$ reboot
$ useradd --create-home arch
$ passwd arch
$ usermod -aG adm,wheel,storage arch
$ id arch
$ visudo
$ reboot
$ vim /etc/locale.gen
$ locale-gen
$ vim /etc/locale.conf
LANG=en_US.UTF-8
$ reboot
$ vim /etc/pacman.conf
[archlinuxcn] Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
$ pacman -Syy
$ pacman -S archlinuxcn-keyring
$ rm -rf /etc/pacman.d/gnupg && pacman-key --init && pacman-key --populate archlinux && pacman-key --populate archlinuxcn
$ pacman -Syy
$ pacman -S mesa lib32-mesa xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau xf86-video- ati
$ pacman -S mesa lib32-mesa xf86-video-intel vulkan-intel lib32-vulkan-intel
$ pacman -S alsa-utils alsa-plugins alsa-oss alsa-firmware sof-firmware alsa-ucm- conf pulseaudio pulseaudio-alsa pulseaudio-bluetooth
$ systemctl enable bluetooth
$ reboot
|
3 安装 KDE 桌面环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| $ pacman -Syy
$ pacman -S ttf-dejavu ttf-liberation noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-emoji-blob noto-fonts-extra adobe-source-han-sans-otc-fonts adobe- source-han-serif-otc-fonts wqy-bitmapfont wqy-microhei wqy-microhei-lite wqy- zenhei ttf-arphic-extra ttf-arphic-ukai ttf-arphic-uming
$ pacman -S plasma plasma-meta konsole dolphin kate ark gwenview vlc firefox firefox-i18n-zh-cn packagekit-qt5
$ systemctl enable sddm
$ systemctl disable iwd
$ systemctl enable NetworkManager
$ reboot
|
4 KDE 的中文化
System Settings(系统设置)>> Regional Settings(区域设置)>> Language(语言)>>Add language(添加语言),找到简体中文后点 Add(添加)。
添加简体中文后,将其移到最上面,并删除其他多余语言,否则会出现汉化不全的情况。上述操作完成后,点击Apply(应用)。
System Settings(系统设置)>>Regional Settings(区域设置)>>Formats(格式)>>Region(区域),选择简体中文(中国)。
上述操作完成后,点击Apply(应用)。
5 AUR helper 的安装
1 2 3 4 5
| $ sudo pacman -S yay
$ sudo pacman -S yay
|
6 添加其他软件源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $ sudo pacman-key --recv-keys 7931B6D628C8D3BA && sudo pacman-key --finger 7931B6D628C8D3BA && sudo pacman-key --lsign-key 7931B6D628C8D3BA
$ sudo vim /etc/pacman.conf
[arch4edu] Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch
$ sudo pacman -Syy
$ sudo pacman -S arch4edu-keyring
$ sudo rm -rf /etc/pacman.d/gnupg && sudo pacman-key --init && sudo pacman-key --populate archlinux && sudo pacman-key --populate archlinuxcn && sudo pacman-key --populate arch4edu
$ sudo pacman -Syy
|
7 更新系统
1 2 3 4 5
| $ sudo pacman -Syu
$ yay
|
WARNING
在更新时请先查看 ArchLinux 官网的新闻公告,看是否需要升级时人为干预,请勿无脑更新。
8 END
想再看一遍本教程吗?输入 sudo rm -rf /*
,你会回来的。