1 min
69

安装 Arch Linux

关于安装 Arch Linux 的备忘笔记

  • #linux
  • #arch

网络设置

解除 Wi‑Fi 适配器屏蔽并启动无线接口,然后使用 `iwctl` 连接无线网络。
  • `rfkill unblock wifi` — 若 Wi‑Fi 被 soft-block,用于启用无线硬件
  • `ip link set wlan0 up` — 启动无线接口
  • `iwctl` — 打开 iwd 交互式 shell
terminal
rfkill unblock wifiip link set wlan0 upiwctl[iwd] station wlan0 scan[iwd] station wlan0 get-networks[iwd] station wlan0 connect <SSID>

磁盘设置

对磁盘分区、格式化分区、挂载,然后安装 base 系统。
  • `lsblk` — 列出所有 block device,找到目标磁盘
  • `cfdisk` — 交互式分区编辑器,创建 2 个分区:EFI(FAT32)与 root(ext4)
  • `mkfs.fat -F32` — 将第一个分区格式化为 FAT32,供 EFI 使用
  • `mkfs.ext4` — 将第二个分区格式化为 ext4,作为 root
  • 将 root 挂载到 `/mnt`,EFI 挂载到 `/mnt/boot/efi`
  • `pacstrap -K` — 使用全新的 pacman keyring 安装 base 系统
  • `genfstab` — 使用 UUID 生成 `/etc/fstab`
terminal
lsblkcfdisk /dev/{name_disk}mkfs.fat -F32 /dev/{name_disk}1mkfs.ext4 /dev/{name_disk}2mount /dev/{name_disk}2 /mntmount --mkdir /dev/{name_disk}1 /mnt/boot/efipacstrap -K /mnt base base-devel linux linux-firmware vim intel-ucodegenfstab -U /mnt >> /mnt/etc/fstab

系统配置

chroot 进入新系统进行配置。
terminal
arch-chroot /mnt

创建 swap file

创建一个 3GB 的 swap file,并写入 `/etc/fstab`,以便重启后仍然生效。
terminal
dd if=/dev/zero of=/swapfile bs=1G count=3 status=progresschmod 600 /swapfilemkswap /swapfileswapon /swapfilevim /etc/fstabswapon --show

设置时区与硬件时钟

  • `ln -sf` — 将时区文件 symlink 到 `/etc/localtime`
  • `hwclock --systohc` — 将 hardware clock 同步为系统时间
terminal
ln -sf /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtimels -l /etc/localtimehwclock --systohc

设置 locale

`/etc/locale.gen` 中取消注释 `en_US.UTF-8 UTF-8`,然后生成 locale。
terminal
vim /etc/locale.gen # uncomment: en_US.UTF-8 UTF-8locale-genvim /etc/locale.conf # add: LANG=en_US.UTF-8

设置 hostname 与 hosts

terminal
vim /etc/hostname # add: archvim /etc/hosts

设置 root 密码

terminal
passwd

安装常用软件包

安装 bootloader、network manager 及其他常用工具。
terminal
pacman -S grub efibootmgr neovim networkmanager network-manager-applet xdg-utils xdg-user-dirs

启用 NetworkManager 服务

Arch 使用 systemd,因此用 `systemctl` 启用服务。
terminal
systemctl enable NetworkManager

安装 GRUB bootloader

terminal
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ARCHgrub-mkconfig -o /boot/grub/grub.cfg

创建用户

  • `useradd -mG wheel` — 创建带 home 目录的用户,并加入 `wheel`
  • `visudo` — 取消注释 `%wheel ALL=(ALL) ALL` 以允许 sudo
terminal
useradd -mG wheel baichupasswd baichuEDITOR=vim visudo # uncomment: %wheel ALL=(ALL) ALL

退出并重启

terminal
exitumount -R --lazy /mntreboot

参考

>Newsletter

Stay Updated

Get notified when I publish new articles, tutorials, and project updates. Subscribe for insights and actionable content.