记录第一次安装archlinux

my device

1
2
3
Host: RedmiBook Pro 15
CPU: 11th Gen Intel i5-11300H (8) @ 4.400GHz
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]

USB drive install ventory

copy archlinux image to ventory push USB driver in target computer # Enter BIOS(UEFI) reboot from USB driver, then choose archlinux grub2

Here CLI

以下分区、mktable、mkfs、mkswap 会清空选中磁盘/分区的数据。这是当时的全盘安装记录,不适用于保留现有系统的双启动操作。只在已确认的目标空盘,或已决定擦除且备份并验证恢复的目标盘上继续;不要照抄历史设备名 /dev/nvme0n1。先备份重要数据,断开不需要的外置盘,并用设备型号、序列号、容量和挂载点核对目标。不能确认时停止,不执行分区或格式化。

下面保留当时的交互笔记,但使用由你手动填写并确认的 $DISK、$ROOT_PART、$SWAP_PART、$EFI_PART。先完成独立的只读确认步骤,分区完成后再核对各分区对应关系;整段笔记包含交互命令和配置摘录,不是可整块执行的 shell 脚本。

1
2
3
4
5
6
lsblk -o NAME,PATH,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTS
read -r -p '已备份并核对型号/序列号后,输入待擦除整盘的绝对路径: ' DISK
[[ -b "$DISK" ]] || { printf '不是块设备,停止。\n'; exit 1; }
lsblk -o NAME,PATH,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTS "$DISK"
read -r -p "确认擦除 $DISK?请再次输入完整路径: " CONFIRM_DISK
[[ "$CONFIRM_DISK" == "$DISK" ]] || { printf '未确认,停止。\n'; exit 1; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# if font small
setfont ter-132n

systemctl stop reflector.service

iwctl
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect WIFI
exit

ping www.bilibili.com
timedatectl set-ntp true

lsblk
parted "$DISK"
(parted)mktable
New disk label type? gpt
quit

cfdisk "$DISK"
# then set partition and its type
# set 1G EFI system
# set 4G swap
# set [the rest space] linux root x86-64
# quit
fdisk -l "$DISK"

# 分区后逐一手动输入实际路径;不要假定分区编号顺序。
read -r -p '核对后的 Linux root 分区绝对路径: ' ROOT_PART
read -r -p '核对后的 swap 分区绝对路径: ' SWAP_PART
read -r -p '核对后的 EFI 分区绝对路径: ' EFI_PART
for PART in "$ROOT_PART" "$SWAP_PART" "$EFI_PART"; do
[[ -b "$PART" ]] || { printf '分区路径不是块设备,停止。\n'; exit 1; }
done
[[ "$ROOT_PART" != "$SWAP_PART" && "$ROOT_PART" != "$EFI_PART" && "$SWAP_PART" != "$EFI_PART" ]] || exit 1
lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS "$DISK"
# 继续前人工确认三个分区都属于目标盘、类型正确且未挂载;上面的 -b 检查不证明这一点。
read -r -p '输入 FORMAT 确认清空上述三个分区: ' CONFIRM_FORMAT
[[ "$CONFIRM_FORMAT" == FORMAT ]] || exit 1

# linux root x86-64
mkfs.ext4 "${ROOT_PART:?先核对并设置 ROOT_PART}"
# swap
mkswap "${SWAP_PART:?先核对并设置 SWAP_PART}"
# EFI system
mkfs.fat -F 32 "${EFI_PART:?先核对并设置 EFI_PART}"

# keep linux root x86-64 first
mount "$ROOT_PART" /mnt
mkdir /mnt/efi
mount "$EFI_PART" /mnt/efi
swapon "$SWAP_PART"

vim /etc/pacman.d/mirrorlist
# Put in the first line
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch

pacstrap /mnt base base-devel linux linux-headers linux-firmware
pacstrap /mnt dhcpcd iwd vim bash-completion

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

arch-chroot /mnt
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc

vim /etc/locale.gen
# uncomment en_US.UTF-8 an zh_CN.UTF-8

locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
vim /etc/hostname
ark233
vim /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 ark233

passwd root
pacman -S intel-ucode
# or pacman -S amd-ucode
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB
vim /etc/default/grub
# set GRUB_CMDLINE_LINUX_DEFAULT loglevel=5
# i missed this command in the first installation xD
grub-mkconfig -o /boot/grub/grub.cfg

exit
umount -R /mnt
# pull out USB driver
reboot

# accomplished

after installation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
setfont -d

vim ~/.bash_profile
export EDITOR='vim'

useradd -m -G wheel -s /bin/bash arch
passwd arch
# still in CLI
EDITOR=vim visudo
# uncomment %wheel ALL=(ALL:ALL) ALL

vim /etc/pacman.conf
# unmount [multilib] section
# add these
[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch
Server = https://mirrors.hit.edu.cn/archlinuxcn/$arch
Server = https://repo.huaweicloud.com/archlinuxcn/$arch

sudo pacman-key --lsign-key "farseerfc@archlinux.org"
sudo pacman -S archlinuxcn-keyring
sudo pacman -S paru

pacman -Syyu


# learn from https://medium.com/@mynameised/using-keyd-in-hyprland-to-rebind-your-right-alt-key-to-escape-linux-782086c81c75
sudo paru -S keyd
sudo vim /etc/keyd/default.conf
[ids]

*

[main]
# hold is control, tap is esc
capslock = overload(control, esc)

vim ~/.config/hypr/hyprland.conf
# add these
exec-once = sudo keyd

paru -S fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-zhwiki
# add pinyin
# ctrl+space switch

vim /etc/environment
GTK_IM_MODULE=fcitx
# or choose setting as https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland#GTK_IM_MODULE
QT_IM_MODULE=fcitx5
XMODIFIERS=@im=fcitx

# from https://www.bilibili.com/read/cv24998287/
paru -S xorg-xrdb
vim ~/.config/hyprland.conf
monitor = ,highres,auto,2
# exec-once = xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
# exec-once = echo 'Xft.dpi:192' | xrdb -merge
env = GDK_SCALE,2
env = XCURSOR_SIZE,32

# Chrome
# Go to chrome://flags and search for Preferred Ozone platform. From the drop-down menu, select Wayland and restart Chrome.
# enable Wayland text-input-v3

paru -S sof-firmware linux-firmware

dotfiles

myDotfiles