Featured image of post Archlinux安装指南

Archlinux安装指南

一、下载ISO镜像与工具

ISO镜像下载(archlinux-xxxx.xx.xx-x86_64.iso)

rufus下载(rufus-x.xp.exe)

ihasher下载

L4o0YqrTRt.png

二、制作安装U盘

注意:制作的安装U盘将被格式化,即删除里面所有内容!

如果询问是否允许更新、确认格式化U盘,点击yes即可

GUdAxCxxop.png

三、预留分区

Windows+R输入diskmgmt.msc mmexport1647324031181.png

mmexport1647324029962.png

四、选择UEFI模式并进入u盘安装系统

选择UEFI模式启动,不同电脑不太一样,请按照电脑说明书或上网搜索进行该步骤。

更新系统时间

root@archiso ~ # timedatectl set-ntp true

分区

root@archiso ~ # fdisk -l

结果中以 rom、loop 或者 airoot 结尾的设备可以被忽略。

对于一个选定的设备,以下分区是必须要有的:

一个根分区(挂载在 根目录)/

一个 EFI 系统分区

请使用 fdisk 或 parted 修改分区表。例如:

root@archiso ~ # fdisk /dev/the_disk_to_be_partitioned(要被分区的磁盘)
挂载点 分区 分区类型 建议大小
/mnt/boot /dev/efi_system_partition(efi 系统分区) EFI 系统分区 至少 260 MiB
/mnt /dev/root_partition(根分区) Linux x86-64 根目录 (/) 剩余空间

格式化分区

root@archiso ~ # mkfs.ext4 /dev/root_partition(根分区)
root@archiso ~ # mkfs.fat -F 32 /dev/efi_system_partition

挂载分区

将根磁盘卷 挂载 到 /mnt,将efi系统卷挂载到/mnt/boot

root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/root_partition(根分区) /mnt
root@archiso ~ # mount /dev/(efi系统分区) /mnt/boot

设置镜像源

root@archiso ~ # reflector --country China --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

安装必需的软件包

root@archiso ~ # pacstrap /mnt base linux linux-firmware

配置系统

Fstab 用以下命令生成 fstab 文件 (用 -U 或 -L 选项设置UUID 或卷标):

root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab

强烈建议在执行完以上命令后,后检查一下生成的 /mnt/etc/fstab 文件是否正确。

Chroot

Change root 到新安装的系统:

root@archiso ~ # arch-chroot /mnt
[root@archiso /]#

时区

要设置时区:

[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@archiso /]# hwclock --systohc

本地化

编辑 /etc/locale.gen,然后取消掉 en_US.UTF-8 UTF-8 和其他需要的 地区 前的注释(#)。

[root@archiso /]# vim /etc/locale.gen
[root@archiso /]# locale-gen
[root@archiso /]# vim /etc/locale.conf
LANG=en_US.UTF-8

网络配置

创建 hostname 文件:

/etc/hostname

myhostname(主机名)

添加对应的信息到 hosts:

[root@archiso /]# vim /etc/hosts
127.0.0.1	localhost
::1		localhost
127.0.1.1	myhostname.localdomain	myhostname # 主机名.本地域名 主机名

设置root密码

[root@archiso /]# passwd

安装引导、内核、联网相关软件包

[root@archiso /]# pacman -S grub efibootmgr intel-ucode os-prober wpa_supplicant dhcpcd

配置grub引导

[root@archiso /]# mkdir /boot/grub
[root@archiso /]# grub-mkconfig > /boot/grub/grub.cfg
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/boot
[root@archiso /]# 
[root@archiso /]# 

退出chroot

[root@archiso /]# exit
root@archiso ~ # umount -R /mnt
root@archiso ~ # reboot

[1]ArchWiki. Installation guide[EB/OL]. [2022-3-16]. https://wiki.archlinux.org/title/Installation_guide.

Licensed under CC BY-NC-SA 4.0
Built with Hugo
主题 StackJimmy 设计