UFSの備忘録 % Home / Categories

ArchLinux安装笔记

Created 2025-08-19 / Updated 2026-02-20

在BIOS中关闭「安全启动」。

u盘启动后,按如下步骤安装ArchLinux。

配置网络:

# iwctl
[iwd]# device list
[iwd]# station <name> scan
[iwd]# station <name> get-networks
[iwd]# station <name> connect <SSID>

查看分区:

# fdisk -l

修改分区:

# fdisk /dev/nvme0n1

Device           Start        End   Sectors   Size Type
/dev/nvme0n1p1    2048    2099199   2097152     1G EFI System
/dev/nvme0n1p2 2099200 1000214527 998115328 475.9G Linux filesystem

格式化efi分区:

# mkfs.fat -F 32 /dev/nvme0n1p1

格式化根分区:

# mkfs.ext4 /dev/nvme0n1p2

挂载分区:

# mount /dev/nvme0n1p2 /mnt

# mkdir -p /mnt/boot/efi
# mount /dev/nvme0n1p1 /mnt/boot/efi

使用国内镜像源:

# curl -L 'https://archlinux.org/mirrorlist/?country=CN&protocol=https&ip_version=4&ip_version=6' -o /etc/pacman.d/mirrorlist

(编辑该/etc/pacman.d/mirrorlist文件,选择要使用的镜像源,去掉前面的注释)

安装基本系统:

# pacstrap -K /mnt base linux linux-firmware-intel linux-firmware-realtek vim

(根据自己的硬件选择对应的firmware

生成fstab文件:

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

(编辑生成的/mnt/etc/fstab文件,为根分区挂载增加noatime,commit=60,barrier=0选项)

chroot到新安装的系统:

# arch-chroot /mnt

设置时区:

# ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

生成/etc/adjtime

# hwclock --systohc

vim创建一个vi软链接:

# ln -s /usr/bin/vim /usr/bin/vi

编辑/etc/locale.gen,去掉en_US.UTF-8zh_CN.UTF-8的注释,然后运行:

# locale-gen

设置LANG变量:

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

设置控制台键盘布局

# vi /etc/vconsole.conf
us

设置主机名

# vi /etc/hostname
主机名

设置root的密码:

# passwd

安装微码:

# pacman -S intel-ucode

安装grub:

# pacman -S grub efibootmgr

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

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

安装iwd:

# pacman -S iwd

配置iwd:

# mkdir /etc/iwd
# vi /etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true
[Network]
RoutePriorityOffset=300
NameResolvingService=systemd
[Scan]
DisablePeriodicScan=true

(我禁止了定期扫描,iwd服务启动后如果没连上网络,需要手动扫描网络:iwctl station wlan0 scan

卸载分区并重启:

# exit
# umount -R /mnt
# shutdown -r now

调节屏幕亮度:

# echo 9600 > /sys/class/backlight/intel_backlight/brightness

创建并激活swapfile

# mkswap -U clear --size 4G --file /swapfile
# swapon /swapfile

写入fstab

# vi /etc/fstab
...
/swapfile none swap defaults 0 0

配置systemd-resolved

# vi /etc/systemd/resolved.conf
DNS=8.8.8.8 8.8.4.4 2001:4860:4860:0:0:0:0:8888 2001:4860:4860:0:0:0:0:8844

# ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
# systemctl enable --now systemd-resolved.service

启动iwd并配置网络:

# systemctl start iwd.service

# iwctl
[iwd]# device list
[iwd]# station <name> scan
[iwd]# station <name> get-networks
[iwd]# station <name> connect <SSID>

更新系统:

# pacman -Syu

声音:

# pacman -S alsa-utils
$ alsamixer
(声道下方标有MM表示已静音,移动到该声道,按下m取消静音,按上下方向键调节音量)

$ speaker-test -c 2
(测试声音)

安装各种软件包:

# pacman -S sway foot intel-media-driver vulkan-intel mesa-utils
# pacman -S brightnessctl
# pacman -S fcitx5-rime
# pacman -S firefox
# pacman -S rsync
# pacman -S openssh

参考:

Categories: [Linux]