690 字
3 分钟
ArchLinux笔记(1) 系统安装与基本配置
设置字体
高分屏可能觉得字体太小看不清
setfont ter-132b联网
先查看网卡信息
ip link可能有网卡的状态是DOWN的,需要启用
稍后安装好系统后也可以用下面的命令启用网卡
ip link set <接口名> up设置时间同步
查看时间同步状态
timedatectl status设置时区
timedatectl set-timezone Asia/Shanghai磁盘分区及格式化并挂载
分区
我推荐使用cfdisk
查看磁盘情况
lsblk启动cfdisk
cfdisk <磁盘设备>格式化
同样使用lsblk查看磁盘情况
格式化EFI分区为FAT32
mkfs.fat -F32 <EFI分区>格式化交换分区为swap
mkswap <交换分区>格式化根分区为btrfs
mkfs.btrfs <根分区>btrfs子卷创建
先挂载根分区
mount <根分区> /mnt创建子卷
btrfs subvolume create /mnt/@btrfs subvolume create /mnt/@homebtrfs subvolume create /mnt/@rootbtrfs subvolume create /mnt/@srvbtrfs subvolume create /mnt/@cachebtrfs subvolume create /mnt/@logbtrfs subvolume create /mnt/@tmpbtrfs subvolume create /mnt/@nixCAUTION卸载根分区
umount /mnt挂载
挂载btrfs子卷
mount -o compress=zstd:3,noatime,ssd,space_cache=v2,discard=async,subvol=@ <btrfs分区> /mntmkdir -p /mnt/{home,root,srv,var/cache,var/log,tmp,nix}mount -o compress=zstd:4,noatime,ssd,space_cache=v2,discard=async,subvol=@home <btrfs分区> /mnt/homemount -o compress=zstd:4,noatime,ssd,space_cache=v2,discard=async,subvol=@root <btrfs分区> /mnt/rootmount -o compress=zstd:4,noatime,ssd,space_cache=v2,discard=async,subvol=@srv <btrfs分区> /mnt/srvmount -o compress=zstd:3,noatime,ssd,space_cache=v2,discard=async,subvol=@cache <btrfs分区> /mnt/var/cachemount -o compress=zstd:3,noatime,ssd,space_cache=v2,discard=async,subvol=@log <btrfs分区> /mnt/var/logmount -o compress=zstd:3,noatime,ssd,space_cache=v2,discard=async,subvol=@tmp <btrfs分区> /mnt/tmpmount -o compress=zstd:4,noatime,ssd,space_cache=v2,discard=async,subvol=@nix <btrfs分区> /mnt/nix挂载EFI分区
mkdir -p /mnt/bootmount <EFI分区设备位置> /mnt/boot启用交换分区
swapon <交换分区设备位置>安装基础系统
pacman镜像源设置
使用reflector选择镜像源
reflector --country China --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist基础系统安装
使用pacstrap安装基础系统
pacstrap /mnt base linux linux-firmware btrfs-progs vim安装CPU微码
pacstrap /mnt intel-ucodepacstrap /mnt amd-ucode生成fstab文件
genfstab -U /mnt >> /mnt/etc/fstab进入新系统进行配置
arch-chroot /mnt设置时间
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohc本地化设置
编辑/etc/locale.gen,取消需要的语言前的注释
取消zh_CN.UTF-8 UTF-8和en_US.UTF-8 UTF-8的注释
vim /etc/locale.gen生成语言环境
locale-gen创建/etc/locale.conf,写入以下内容
LANG=en_US.UTF-8设置主机名
创建/etc/hostname,写入主机名
生成initramfs
mkinitcpio -P设置root密码
passwd安装引导
我用grub
pacman -S grub efibootmgr安装grub到EFI分区并创建配置文件
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUBgrub-mkconfig -o /boot/grub/grub.cfg安装os-prober以支持多系统启动
pacman -S os-probergrub-mkconfig -o /boot/grub/grub.cfg退出并重启
关机后记得拔U盘
exitumount -R /mntswapoff -areboot进入新系统后的必要配置
先登录root账号
网络配置
安装networkmanager
pacman -S networkmanagersystemctl enable NetworkManagersystemctl start NetworkManager连接无线网络
nmcli device wifi listnmcli device wifi connect <SSID> password <PASSWORD>添加普通用户
useradd -m -G wheel -s /bin/bash <用户名>passwd <用户名>允许wheel组使用sudo
EDITOR=vim visudo取消以下行的注释
%wheel ALL=(ALL) ALL安装snapper
pacman -S snappersnapper -c root create-config /创建快照命令
snapper -c root create -d "描述信息" ArchLinux笔记(1) 系统安装与基本配置
https://a1kari8.github.io/posts/archlinux/arch_note1_install/