UFSの備忘録 % Home / Categories

ArchLinux安装笔记

Created 2025-03-15 / Updated 2025-03-15

先在BIOS中关闭「安全启动」,然后在Windows下关闭磁盘的「BitLocker」,用「压缩卷」为硬盘分出一个区(即下文的nvme0n1p4),用来安装Linux。

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

格式化根分区:

# mkfs.ext4 /dev/nvme0n1p4

关闭日志:

# tune2fs -O "^has_journal" /dev/nvme0n1p4

挂载根分区:

# mount /dev/nvme0n1p4 /mnt

挂载efi分区:

# mkdir /mnt/efi
# mount /dev/nvme0n1p1 /mnt/efi

(由于硬盘上的win11已经有一个efi分区,这里直接挂载它)

使用国内镜像源:

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

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

安装基本系统:

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

生成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/hostname
主机名

设置root的密码:

# passwd

安装微码:

# pacman -S intel-ucode

安装grub:

# pacman -S grub efibootmgr os-prober

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

# vi /etc/default/grub
GRUB_DISABLE_OS_PROBER=false
(取消该行注释)

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

安装iwd:

# pacman -S iwd

启用内置网络配置:

# vi /etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true

添加DNS服务器:

# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

卸载分区并重启:

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

参考:

Categories: [Linux]