原创文章,转载请注明出处
https://qiedd.com/

将ArchLinux写入进u盘

推荐使用Rufus,轻巧简便
写入方式为GPT
启动方式务必选择UEFI

开始安装

Bios设置从U盘启动,建议连网,通过ssh安装,复制命令方便
我使用的arch镜像为20.01.1

准备工作

wifi-menu                         //选择连接wifi  
systemctl start sshd        //开启ssh
passwd                              //设置一个密码

后面的版本使用iwctl管理无线,请查阅wiki

这里我使用的Xshell 6进行操作(个人版免费使用,上官网操作一下,会发邮件给你,邮件里面有下载地址)

调整时间

timedatectl set-ntp true

查看硬盘分分区

fdisk -l

Disk /dev/sda: 1.32 TiB, 1440290267136 bytes, 2813066928 sectors
Disk model: GLOWAY STK1.5TS3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F2822167-2B39-4099-92EC-5E45F4198A73

Device          Start        End    Sectors  Size Type
/dev/sda1          34      32767      32734   16M Microsoft reserved
/dev/sda2       32768 1048608767 1048576000  500G Microsoft basic data
/dev/sda3  1048608768 1258323967  209715200  100G Microsoft basic data
/dev/sda4  1258323968 1677754367  419430400  200G Microsoft basic data

进行分区,分两个区 300M EFI和204G LVM

fdisk /dev/sda

#新建分区 /dev/sda5
Command (m for help): n
Partition number (5-128, default 5): 
First sector (1677754368-2813066894, default 1677754368): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1677754368-2813066894, default 2813066894): +300M

#新建分区 /dev/sda6
Command (m for help): n
Partition number (6-128, default 6): 
First sector (1678368768-2813066894, default 1678368768): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1678368768-2813066894, default 2813066894): +204G

#将 /dev/sda5 的分区类型改为 EFI System
Command (m for help): t
Partition number (1-6, default 6): 5
Partition type (type L to list all types): 1

Changed type of partition 'Linux filesystem' to 'EFI System'.

#保存
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

格式化一下新建的两个分区

mkfs.vfat -F 32 /dev/sda5
mkfs.ext4 /dev/sda6

现在的分区

fdisk -l /dev/sda

Device          Start        End    Sectors  Size Type
/dev/sda1          34      32767      32734   16M Microsoft reserved
/dev/sda2       32768 1048608767 1048576000  500G Microsoft basic data
/dev/sda3  1048608768 1258323967  209715200  100G Microsoft basic data
/dev/sda4  1258323968 1677754367  419430400  200G Microsoft basic data
/dev/sda5  1677754368 1678368767     614400  300M EFI System
/dev/sda6  1678368768 2106187775  427819008  204G Linux filesystem

建立物理卷

pvcreate /dev/sda6

建立卷组,命名为arch,加入到/dev/sda6

vgcreate arch /dev/sda6

分卷

lvcreate -L 50G arch -n root
lvcreate -L 150G arch -n home
lvcreate -l +100%FREE arch -n swap

格式化

mkfs.ext4 /dev/mapper/arch-root    
mkfs.ext4 /dev/mapper/arch-home    
mkswap /dev/mapper/arch-swap

开启swap

swapon /dev/mapper/arch-swap

挂载lvm分区

mount /dev/mapper/arch-root /mnt
mkdir /mnt/boot /mnt/home
mount /dev/sda5 /mnt/boot
mount /dev/mapper/arch-home /mnt/home

将国内镜像源放在最前面

vim /etc/pacman.d/mirrorlist 
----------------------------------------------------------------
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.cloud.tencent.com/archlinux/$repo/os/$arch
Server = https://mirrors.aliyun.com/archlinux/$repo/os/$arch

# 腾讯云内网专用
Server = http://mirrors.tencentyun.com/archlinux/$repo/os/$arch

正式开始安装

AMD

pacstrap /mnt base linux linux-firmware base-devel lvm2 vim os-prober amd-ucode dhclient dialog dhcpcd openssh wget wireless-regdb wireless_tools wpa_supplicant efibootmgr networkmanager

INTEL

pacstrap /mnt base linux linux-firmware base-devel lvm2 vim os-prober intel-ucode dhclient dialog dhcpcd openssh wget wireless-regdb wireless_tools wpa_supplicant efibootmgr networkmanager

配置系统并检查

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
date

配置Locale,加在前面即可

vim /etc/locale.gen
--------------------------------
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8

然后执行

locale-gen

设置locale.conf

vim /etc/locale.conf
--------------------------------
LANG=en_US.UTF-8

网络hostname设置

vim /etc/hostname
------------------------
Yourname

hosts设置

vim /etc/hosts
-------------------------------------------
127.0.0.1         localhost
::1                    localhost
192.168.123.232         Yourname.localdomain   Yourname

lvm配置 在block 和 filesystems之间添加lvm2

vim /etc/mkinitcpio.conf
---------------------------------------------------------------------------------------------------------
HOOKS=(base udev autodetect modconf block lvm2 filesystems keyboard fsck)

然后应用此配置

mkinitcpio -p linux

两种引导方式的安装(二选一)

使用grub引导

pacman -S grub efibootmgr
grub-install --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg

重启后再执行(不是现在,请看收尾工作)

grub-mkconfig -o /boot/grub/grub.cfg

使用systemd-boot 引导

安装 systemd-boot 到 EFI 分区中

bootctl --path=/boot$esp install

配置 /boot/loader/loader.conf

vim /boot/loader/loader.conf 
---------------
default  arch.conf
timeout  4
console-mode auto
editor   no

配置 /boot/loader/entries/arch.conf

vim /boot/loader/entries/arch.conf
--------------------------
title   Arch Linux (LVM)
linux   /vmlinuz-linux
initrd  /amd-ucode.img
initrd  /initramfs-linux.img
options root=/dev/mapper/arch-root rw 

如果你是Intel的CPU,则改成

title   Arch Linux (LVM)
linux   /vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux.img
options root=/dev/mapper/arch-root rw 

收尾

开启NetworkManager连接wifi

systemctl enable NetworkManager

//输入nmtui连接WiFi
nmtui

设置root密码

passwd

退出并重启

exit
umount -R /mnt
reboot

重启后配置

建议暂时开启ssh

重启后不会自动启动sshd,并且不支持root登陆,需要修改配置文件

开启ssh后可以在另一台设备复制粘贴命令

#编辑 /etc/ssh/sshd_config
 vim /etc/ssh/sshd_config

#在文件末尾增加
PermitRootLogin yes

#然后启动sshd
systemctl start sshd

安装haveged

pacman -Syu haveged
systemctl start haveged
systemctl enable haveged

配置ArchLinuxCN原

/etc/pacman.conf 文件末尾添加以下两行:

[archlinuxcn]
Server = https://mirrors.aliyun.com/archlinuxcn/$arch

安装私钥

pacman -Sy archlinuxcn-keyring

如果出现 (invalid or corrupted package (PGP signature)).

请使用 pacman-key 导入私钥

rm -fr /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux
pacman-key --populate archlinuxcn

配置Aur源

安装yay

pacman -S yay

其他教程

Arch安装桌面(KDE)

分类: Linux

0 条评论

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据