镜像准备
前往镜像站下载
1
| https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso
|
安装流程
基础安装
加载镜像
进入 VirtualBox
加载镜像
校准时间
1 2 3 4 5 6 7 8 9 10 11
| timedatectl list-timezones
timedatectl set-timezone Asia/Hong_Kong
timedatectl set-ntp true
timedatectl status
|
切换镜像源
1
| vim /etc/pacman.d/mirrorlist
|
1 2 3 4 5
| Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
|
全新安装
建立分区表
1 2 3 4
| parted /dev/sdx (parted) mktable New disk label type? gpt (parted) quit
|
建立EFI分区
具体的磁盘设备各有差异,SATA名称为sdx
,NVME硬盘有另外的名称nvmexn1
此处以 SATA
为例
- EFI分区:300M
- 剩余空间自行分配
- Swap可选
格式化 EFI 分区
格式化 Swap 分区(若有)
格式化 Btrfs 分区
将整一个分区格式化为 Btrfs 文件系统 1
| mkfs.btrfs -fL Lingmo /dev/sdxn
|
> -L
选项后指定该分区的
LABLE,可以自定义,但不能使用特殊字符以及空格,且最好有意义
挂载 Btrfs 分区
1 2
| mount -t btrfs -o compress=zstd /dev/sdxn /mnt
|
为后续创建子卷做准备
相关参数: - -t
:选项后指定挂载分区文件系统类型 -
-o
:选项后添加挂载参数: -
compress=zstd
:开启透明压缩
创建 Btrfs 子卷
1 2 3 4 5
| btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
|
1 2
| btrfs subvolume list -p /mnt
|
卸载 /mnt
挂载各目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| mount -t btrfs -o subvol=/@,compress=zstd /dev/sdxn /mnt
mkdir /mnt/home
mount -t btrfs -o subvol=/@home,compress=zstd /dev/sdxn /mnt/home
mkdir -p /mnt/boot
mount /dev/sdxn /mnt/boot
swapon /dev/sdxn
|
安装系统
- 使用
pacstrap
脚本安装基础包:
Pacstrap is designed to create a new system installation from
scratch.
1 2
| pacstrap /mnt base base-devel linux linux-firmware btrfs-progs
|
相关参数: - base-devel
:在 AUR
包的安装过程中是必须用到的 -
linux
:内核软件包,这里建议先不要替换为其它内核
- 如果提示 GPG 证书错误,可能是因为使用的不是最新的镜像文件
1 2
| pacman -S archlinux-keyring
|
- 安装其它必要的功能性软件:
1
| pacstrap /mnt networkmanager vim sudo zsh zsh-completions
|
生成 fstab 文件
fstab 用来定义磁盘分区。它是 Linux 系统中重要的文件之一。
1 2
| genfstab -U /mnt > /mnt/etc/fstab
|
如下:
1 2 3 4 5 6 7 8
| UUID=d34ad4d9-8c4f-4ffc-adf4-6d5985dd4da3 / btrfs rw,relatime,compress=zstd:3,space_cache=v2,subvolid=256,subvol=/@ 0 0
UUID=d34ad4d9-8c4f-4ffc-adf4-6d5985dd4da3 /home btrfs rw,relatime,compress=zstd:3,space_cache=v2,subvolid=257,subvol=/@home 0 0
UUID=4CF3-8291 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
|
进入 chroot
修改主机名
1 2 3 4
| 127.0.0.1 localhost ::1 localhost 127.0.1.1 myarch.localdomain myarch
|
设置时区
1 2
| ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime
|
硬件时间设置
设置 Locale
Locale 决定了软件使用的语言、书写习惯和字符集。
1 2 3
|
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
为 root 用户设置密码
安装微码
1 2
| pacman -S intel-ucode pacman -S amd-ucode
|
安装引导程序
- 安装相应的包
1
| pacman -S grub efibootmgr os-prober
|
相关参数 - -S
:选项后指定要通过 pacman
包管理器安装的包: - grub
:启动引导器 -
efibootmgr
:efibootmgr 被 grub 脚本用来将启动项写入 NVRAM -
os-prober
:为了能够引导 win10,需要安装 os-prober
以检测到它
- 安装
GRUB
到 EFI
分区
1 2
| grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH
|
相关参数 - --efi-directory=/boot
:将 grubx64.efi
安装到之前的指定位置(EFI 分区) -
--bootloader-id=ARCH
:取名为 ARCH -
--removable
:用于安装到移动介质
- 编辑
/etc/default/grub
文件
进行如下修改:
- 去掉
GRUB_CMDLINE_LINUX_DEFAULT
一行中最后的 quiet
参数
- 把
loglevel
的数值从 3
改成
5
。这样是为了后续如果出现系统错误,方便排错
- 加入
nowatchdog
参数,这可以显著提高开关机速度
- 生成
GRUB
所需的配置文件
1
| grub-mkconfig -o /boot/grub/grub.cfg
|
完成安装
1 2 3
| exit umount -R /mnt reboot
|
设置开机启动项
1 2
| systemctl enable --now NetworkManager
|
1 2 3 4 5 6 7
|
nmcli dev wifi list
nmcli dev wifi connect "SSID" password "PWD"
|
也可以使用 nmtui
来配置网络
更新系统所有包
使用 neofetch 打印系统信息 1 2
| pacman -S neofetch neofetch
|
添加用户 & 进组 1 2 3 4 5 6 7 8
| useradd -m username
passwd username
gpasswd -a user groupname
|
安装 openssh 并启用 1 2
| pacman -S openssh systemctl enable --now sshd
|
后日谈
Why Btrfs ?
纵观 Btrfs
的历史,可以说 Btrfs
未来的发展是道阻且长的。也让我们感受到开源社区也并不是一根绳上的蚂蚱 ——
开源社区之间也有着各种各样的分歧。
但不管怎么说,Btrfs
的未来现在来看是光明的;我们也可以在
archlinux
上享受到 Btrfs
文件系统的特性带来的好处:
- 快照
archlinux
作为滚动发行版,若滚挂了可以使用 Btrfs
的快照特性快速回滚 若使用传统的 ext4
文件系统,我们可以使用
timeshift
的 RSYNC
模式进行增量备份。但是,一般来说 RSYNC
方式的快照大小略大于当前实际使用大小,也就是说实际上开启了
timeshift
的 RSYNC
模式快照相当于磁盘可用空间直接少了一半多。因为虽然 RSYNC
方式的快照是增量的,但历史最久远的快照依然是完整备份,随后才是增量的
- 透明压缩 可以大大减少磁盘的使用空间(压缩率大概在
10%
左右)