Home Categories About RSS

最基础的Archlinux安装配置记录

由于一些原因,我的笔记本要重新安装archlinux(并不是因为它滚挂了)。为了防止以后忘记了这个安装过程,于是有了这篇记录。

假设已经正确地进入了live环境。

在live环境中

验证引导模式、确定网络接口

ls /sys/firmware/efi/efivars
ip link

联网

我的这台笔记本使用的是无线网卡,所以通过iwd来联网,并通过ping测试:

iwctl

更新系统时间并检查

timedatectl set-ntp true #现在好像连上网就自动同步了,只用检查一下就行
timedatectl

磁盘分区、格式化以及挂载

fdisk -l
cfdisk /dev/nvme0n1 #我习惯efi分区300M,其他都给根目录
mkfs.ext4 /dev/nvme0n1p2 #格式化根目录
mkfs.fat -F 32 /dev/nvme0n1p1 #格式化efi目录
mount /dev/nvme0n1p2 /mnt
mkdir /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot

安装很多的软件包

reflector --latest 5 --country China --protocol https --sort rate --save /etc/pacman.d/mirrorlist
pacstrap -K /mnt base base-devel linux linux-firmware linux-headers neovim iwd

生成fstab文件并检查

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

chroot到安装的系统并进行一系列操作

arch-chroot /mnt
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #设置时区
hwclock --systohc #调节时间
nvim /etc/locale.gen #本地化,我选择en_SG.UTF-8还有zh_CN.UTF-8
locale-gen
nvim /etc/locale.conf	# 写入LANG=en_SG.UTF-8
vim /etc/hostname #设置主机名
vim /etc/hosts	# 现在好像已经不需要这个了
passwd #设置root密码
pacman -S intel-ucode #安装cpu微码

系统引导

开始弄系统引导,我不选择grub,因为不需要多系统:

pacman -S efibootmgr
blkid	# 找到根目录的PARTUUID
efibootmgr -d /dev/nvme0n1 -p 1 -c -L "Arch Linux" -l /vmlinuz-linux -u "root=PARTUUID=根目录的PARTUUID rw initrd=intel-ucode.img initrd=\initramfs-linux.img"

之后就能reboot了。

进入新系统

创建新的普通用户

useradd -m -G wheel 用户名 #新建用户
passwd 密码 #给他创建密码
EDITOR=vim visudo #去掉"%wheel ALL=(ALL:ALL) ALL"这行的'#'

配置网络

我使用iwd自带的DHCP和systemd-resolved

nvim /etc/iwd/main.conf #新建

添加:

[General] EnableNetworkConfiguration=true [Network] NameResolvingService=systemd

然后:

systemctl enable iwd
systemctl start iwd
systemctl enable systemd-resolved
systemctl start systemd-resolved

配置pacman

nvim /etc/pacman.conf	#去掉"color"那一行的'#'

在文件的最后添加如下几行来使用archlinuxcn

[archlinuxcn] Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch

pacman -S archlinuxcn-keyring

开启交换空间(使用交换文件)

dd if=/dev/zero of=/swapfile bs=1G count=16 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
nvim /etc/fstab

在最后添加

/swapfile none swap defaults 0 0

安装一系列软件

pacman -S git wget paru neofetch zsh zsh-completions zsh-syntax-highlighting ntfs-3g ranger dosfstools bluez bluez-utils pulseaudio pulseaudio-alsa pulseaudio-bluetooth alsa-utils sof-firmware

zsh相关

通过chsh -s /usr/bin/zsh来切换成zsh~/.zshrc中添加以下内容使zsh有高亮效果:

source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

改键位(Capslock和Left_Control互换)

这与一般的改键位不同,这里改变的是TTY中的键位

cd /usr/share/kbd/keymaps/i386/qwert
sudo cp us.map.gz ./personal.map.gz
sudo gunzip personal.map.gz
sudo nvim personal.map	# 29和58互换
sudo gzip personal.map
sudo nvim /etc/vconsole.conf	# 去掉'#',并修改为KEYMAP=personal

设置蓝牙

sudo systemctl enable bluetooth
sudo usermod -aG lp 用户名 #用户添加到lp组
sudo nvim /etc/bluetooth/main.conf

[General] DiscoverableTimeout = 0 [Policy] AutoEnable=true

其他的一些东西

sudo nvim /etc/systemd/system.conf

修改DefaultTimeoutStopSec,去掉#,并赋值为 30s

sudo systemctl daemon-reload

这样可以减少关机时遇到timeout等待的时间,之后再使用journalctl -p5来排查问题