This commit is contained in:
2021-11-14 14:32:08 +08:00
parent f75ad8bedd
commit b0f6120151
152 changed files with 22219 additions and 8 deletions

View File

@@ -0,0 +1,211 @@
---
title: "安装 Archlinux"
date: 2021-07-04T11:23:00+08:00
lastmod: 2021-07-04T11:23:00+08:00
keywords: []
tags: ["archlinux"]
categories: ["os"]
---
# U 盘启动,进入 archlinux live
- 下载 archlinux 镜像
```bash
curl -LO https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/2021.07.01/archlinux-2021.07.01-x86_64.iso
```
- 把镜像写进一个无用的 U 盘(/dev/sdX)
```bash
dd if=archlinux-2021.07.01-x86_64.iso bs=1M of=/dev/sdX
```
- 使用该 U 盘启动自己的 PC进入 archlinux live
# 联网,硬盘分区,安装系统
- 插上网线,自动分配地址,验证是否可以连接外网
```bash
curl -I https://www.baidu.com
# 返回 200
```
- 规划硬盘,选择一个无用硬盘(/dev/sdX),规划 efi 分区和根分区
```bash
# fdisk 规划分区
fdisk /dev/sdX
g # 创建新的 gpt 分区表
n # 创建一个新分区
# 直接回车
# 直接回车
+256M # 指定大小
t # 更改分区类型
# 直接回车
1 # 选择 EFI System
n # 创建一个新分区
# 直接回车
# 直接回车
+XXXG # 指定根分区大小
w # 保存并退出 fdisk
官网还有 swap 分区,现在内存都比较大,不需要 swap 了
```
- 格式化分区
```bash
mkfs.fat -F32 /dev/sdX1
mkfs.ext4 /dev/sdX2
```
- 挂载分区
```bash
mount /dev/sdX2 /mnt
mkdir /mnt/EFI
mount /dev/sdX1 /mnt/EFI
```
- 修改软件源(vim /etc/pacman.d/mirrorlist),只保留中国源
```
## China
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.bit.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch
## China
Server = https://mirrors.cloud.tencent.com/archlinux/$repo/os/$arch
## China
Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.xjtu.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.163.com/archlinux/$repo/os/$arch
## China
Server = http://mirrors.sohu.com/archlinux/$repo/os/$arch
## China
Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirrors.shu.edu.cn/archlinux/$repo/os/$arch
## China
Server = http://mirror.lzu.edu.cn/archlinux/$repo/os/$arch
```
- 安装系统包
```bash
pacstrap /mnt base linux linux-firmware
# 这里会从中国源里下载安装包并安装,具体时间就看网速了
```
- 生成 fstab
```bash
genfstab -U /mnt >> /mnt/etc/fstab
```
- chroot 进入新系统
```bash
arch-chroot /mnt /bin/bash
```
# 配置新安装的系统
- 设置时区
```bash
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
```
- 编辑 /etc/locale.gen选择 en_US 和 zh_CN
```bash
sed -i \
-e '/^#en_US.UTF-8/s/^#//' \
-e '/^#zh_CN/s/^#//' \
/etc/locale.gen
locale-gen
# 生成 /etc/locale.conf
echo 'LANG=zh_CN.UTF-8' > /etc/locale.conf
```
- 设置主机名(xxxx)
```bash
echo xxxx > /etc/hostname
```
- 安装内核
```bash
mkinitcpio -P
```
- 设置 root 密码
```bash
passwd
```
- 创建一个普通用户(xxxx),用于自己日常使用
```bash
useradd -m xxxx
passwd xxxx
echo "xxxx ALL=(ALL) ALL" > /etc/sudoers.d/xxxx
```
- 安装其他必须包
```bash
pacman -S grub networkmanager
pacman -S intel-ucode # intel 处理器
pacman -S amd-code # amd 处理器
```
- 创建 efi 启动项(xxxx)
```bash
grub-install --target=x86_64-efi --efi-directory=/EFI --bootloader-id=xxxx
```
- 生成 grub.cfg
```bash
grub-mkconfig -o /boot/grub/grub.cfg
```
- 退出新系统,返回 archlinux live
```bash
exit
```
# 卸载硬盘,重启
- 卸载硬盘
```bash
umount -R /mnt
```
- 重启
```bash
reboot
```
# 日常使用
- 登陆普通用户
- 启动 NetworkManager并设置开机自动启动
```bash
sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager
```
- 连接网络
```bash
nmtui
```
- 安装常用命令行软件
```bash
sudo pacman -S ctags cscope tmux expect git p7zip unrar zip unzip \
ntfs-3g espeak hostapd dnsmasq openssh tcpdump vim cdrtools \
tree ethtool openbsd-netcat arch-install-scripts
```
- 安装 gnome 桌面
```bash
sudo pacman -S wqy-zenhei ttf-liberation
sudo pacman -S gnome
sudo systemctl enable gdm.service
sudo pacman -S gvim file-roller freerdp mpv ibus-sunpinyin
```
- [Gnome 主题网站](https://gnome-look.org)