Ubuntu 安装 Arch
安装 pacman
apt install pacman -y
下载镜像
到 archlinux.org 下载镜像
curl https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/2021.08.01/archlinux-bootstrap-2021.08.01-x86_64.tar.gz -o /tmp/archlinux-bootstrap-2021.08.01-x86_64.tar.gz
测试 MD5 值
md5sum -c <<<"9cedcaf056b415e0b33bc5aaf28d3c36 /tmp/archlinux-bootstrap-2021.08.01-x86_64.tar.gz"
创建 chroot
解压文件,解压过程中产生的信息不用理会
tar xzf archlinux-bootstrap-2021.08.01-x86_64.tar.gz
选择服务器,修改
/tmp/root.x86_64/etc/pacman.d/mirrorlist进入chroot
mount --bind /tmp/root.x86_64 /tmp/root.x86_64cd /tmp/root.x86_64cp /etc/resolv.conf etcmount -t proc /proc procmount --make-rslave --rbind /sys sysmount --make-rslave --rbind /dev devmount --make-rslave --rbind /run run # (assuming /run exists on the system)chroot /tmp/root.x86_64 /bin/bash
使用 chroot 环境
初始化 pacman keyring
pacman-key --initpacman-key --populate archlinux
下载基本工具
刷新安装包列表
pacman -Syyu
此过程出错请仔细检查上一步「创建 chroot」是否出错。
安装
pacman -S base-devel parted
磁盘分区
查看分区
fdisk -l
部分输出:
Device Start End Sectors Size Type/dev/sda1 2048 1050623 1048576 512M EFI System/dev/sda2 1050624 3147775 2097152 1G Linux filesystem/dev/sda3 3147776 250066943 246919168 117.7G Linux filesystem
挂载分区
mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
安装必要包
pacstrap /mnt base linux linux-firmware iproute2
配置系统
Fstab
genfstab -U /mnt >> /mnt/etc/fstab
Chroot
arch-chroot /mnt
Time zone
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
Localization
编辑
/etc/locale.gen,注释掉en_US.UTF-8 UTF-8,执行下面的命令生成 localeslocale-gen
创建
locale.confvim /etc/locale.confLANG=en_US.UTF-8
设置键盘布局
vim /etc/vconsole.confKEYMAP=us
网络配置
创建 hostname 文件
vim /etc/hostnamearch
添加下列 hosts
vim /etc/hosts127.0.0.1 localhost::1 localhost127.0.1.1 arch.localdomain arch
安装 DHCP
pacman -S dhcpcd
systemctl enable dhcpcd
root 密码
passwd
Boot loader
Microcode
安装对应CPU包
pacman -S intel-ucode # or amd-ucode
EFISTUB
efibootmgr --disk /dev/sda --part 1 --create --label "Arch Linux" --loader /vmlinuz-linux --unicode 'root=PARTUUID=a66c2efc-be9f-4a1c-af1a-ef0d655c147b rw initrd=\intel-ucode.img initrd=\initramfs-linux.img' --verbose
如果有N卡需要禁用,在引号内添加
nouveau.modeset=0
efibootmgr —disk /dev/sdX —part Y —create —label “Arch Linux” —loader /vmlinuz-linux —unicode ‘root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX rw initrd=\initramfs-linux.img’ —verbose
Where
_/dev/sdX_and_Y_are the drive and partition number where the ESP is located. Change theroot=andresume=parameters to reflect your Linux root and swap partitions, see kernel parameters for supported device name formats, and persistent block device naming for how to obtain the corresponding value. If omitted, then the first partition on_/dev/sda_is used as the ESP. Note that the-u/--unicodeargument in quotes is just the list of kernel parameters, so you may need to add additional parameters (e.g. for suspend to disk or microcode).查看引导顺序
efibootmgr --verbose
重启
退出 chroot 环境,重启电脑
exitreboot
更改网卡名
查看网卡 MAC 地址
ip a
添加规则
vim /etc/udev/rules.d/10-local.rules
SUBSYSTEM=="net", ATTR{address}=="05:a1:d8:cb:c5:18", NAME:="eth0"
使配置生效
udevadm control --reload
配置固定IP
vim /etc/dhcpcd.conf
interface eth0static ip_address=192.168.1.114/24static routers=192.168.1.1static domain_name_servers=8.8.8.8 8.8.4.4
临时网络配置
IP 地址
ip address show
选择列出的网卡,为其添加 IP 地址。
ip address add 192.168.1.113/24 broadcast + dev enp1s0
路由表
查看路由
ip route show
添加路由
ip route add default via 192.168.1.1 dev enp1s0
设置仓库
添加Arch Linux中文社区驱动的非官方用户仓库。包含中文用户常用软件、工具、字体/美化包等。
使用方法:在/etc/pacman.conf文件末尾添加以下两行:sudo vim /etc/pacman.conf
[archlinuxcn]Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch
安装
archlinuxcn-keyring包导入 GPG key。sudo pacman -Sysudo pacman -S archlinuxcn-keyring
软件安装
基本工具
pacman -S git base-devel
oh my zsh
pacman-S zshsh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightinggit clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
配置
~/.zshrcplugins=(zsh-syntax-highlightingzsh-autosuggestionsgitextractautojump)
WSL
WSL是不支持Systemd的,但可以通过genie实现
vim PKGBUILD
```shell
Maintainer: Arley Henostroza
Contibutor: facekapow
pkgname=genie-systemd _pkgname=genie pkgver=1.28 pkgrel=1 pkgdesc=”A quick way into a systemd \”bottle\” for WSL” arch=(‘x86_64’) url=”https://github.com/arkane-systems/genie“ license=(‘custom:The Unlicense’) depends=(‘daemonize’ ‘dotnet-runtime>=3.1’ ‘dotnet-host>=3.1’ ‘inetutils’) makedepends=(‘dotnet-sdk>=3.1’) conflicts=(‘genie-systemd’) provides=(‘genie-systemd’) source=(“${url}/archive/${pkgver}.tar.gz”) sha256sums=(‘688253faad5e3c40c9277dac00a481f48bc5ed62cf2bc82c2c1234d92604ea96’)
prepare() { tar -xzf ${pkgver}.tar.gz }
package() { export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true ls -alh cd genie-${pkgver}/genie export DESTDIR=$pkgdir make build make install mkdir -p ${pkgdir}/usr/bin chmod +x ${pkgdir}/usr/libexec/genie ln -s /usr/libexec/genie/main/genie ${pkgdir}/usr/bin/genie }
```shellyay -S daemonizemakepkg -si # 处理依赖并安装
