Ubuntu 安装 Arch

安装 pacman

  1. apt install pacman -y

下载镜像

  • archlinux.org 下载镜像

    1. 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 值

    1. md5sum -c <<<"9cedcaf056b415e0b33bc5aaf28d3c36 /tmp/archlinux-bootstrap-2021.08.01-x86_64.tar.gz"

    创建 chroot

  • 解压文件,解压过程中产生的信息不用理会

    1. tar xzf archlinux-bootstrap-2021.08.01-x86_64.tar.gz
  • 选择服务器,修改 /tmp/root.x86_64/etc/pacman.d/mirrorlist

  • 进入chroot

    1. mount --bind /tmp/root.x86_64 /tmp/root.x86_64
    2. cd /tmp/root.x86_64
    3. cp /etc/resolv.conf etc
    4. mount -t proc /proc proc
    5. mount --make-rslave --rbind /sys sys
    6. mount --make-rslave --rbind /dev dev
    7. mount --make-rslave --rbind /run run # (assuming /run exists on the system)
    8. chroot /tmp/root.x86_64 /bin/bash

    使用 chroot 环境

    初始化 pacman keyring

    1. pacman-key --init
    2. pacman-key --populate archlinux

    下载基本工具

  • 刷新安装包列表

    1. pacman -Syyu

    此过程出错请仔细检查上一步「创建 chroot」是否出错。

  • 安装

    1. pacman -S base-devel parted

    磁盘分区

  • 查看分区

    1. fdisk -l

    部分输出:

    1. Device Start End Sectors Size Type
    2. /dev/sda1 2048 1050623 1048576 512M EFI System
    3. /dev/sda2 1050624 3147775 2097152 1G Linux filesystem
    4. /dev/sda3 3147776 250066943 246919168 117.7G Linux filesystem
  • 挂载分区

    1. mount /dev/sda3 /mnt
    1. mount /dev/sda1 /mnt/boot

    /mnt/boot 不存在需要先创建目录

    安装必要包

    1. pacstrap /mnt base linux linux-firmware iproute2

    配置系统

    Fstab

    1. genfstab -U /mnt >> /mnt/etc/fstab

    Chroot

    1. arch-chroot /mnt

    Time zone

    1. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    1. hwclock --systohc

    Localization

  • 编辑 /etc/locale.gen ,注释掉 en_US.UTF-8 UTF-8 ,执行下面的命令生成 locales

    1. locale-gen
  • 创建 locale.conf

    1. vim /etc/locale.conf
    2. LANG=en_US.UTF-8
  • 设置键盘布局

    1. vim /etc/vconsole.conf
    2. KEYMAP=us

    网络配置

  • 创建 hostname 文件

    1. vim /etc/hostname
    2. arch
  • 添加下列 hosts

    1. vim /etc/hosts
    2. 127.0.0.1 localhost
    3. ::1 localhost
    4. 127.0.1.1 arch.localdomain arch
  • 安装 DHCP

    1. pacman -S dhcpcd
    1. systemctl enable dhcpcd

    root 密码

    1. passwd

    Boot loader

    Microcode

  • 安装对应CPU包

    1. pacman -S intel-ucode # or amd-ucode

    EFISTUB

    1. 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卡需要禁用,在引号内添加

    1. 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 the root= and resume= 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/--unicode argument 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).

  • 查看引导顺序

    1. efibootmgr --verbose

    重启

  • 退出 chroot 环境,重启电脑

    1. exit
    2. reboot

    更改网卡名

    查看网卡 MAC 地址

    1. ip a

    添加规则

    1. vim /etc/udev/rules.d/10-local.rules
    1. SUBSYSTEM=="net", ATTR{address}=="05:a1:d8:cb:c5:18", NAME:="eth0"

    使配置生效

    1. udevadm control --reload

    配置固定IP

    1. vim /etc/dhcpcd.conf
    1. interface eth0
    2. static ip_address=192.168.1.114/24
    3. static routers=192.168.1.1
    4. static domain_name_servers=8.8.8.8 8.8.4.4

    临时网络配置

    IP 地址

    1. ip address show

    选择列出的网卡,为其添加 IP 地址。

    1. ip address add 192.168.1.113/24 broadcast + dev enp1s0

    路由表

    查看路由

    1. ip route show

    添加路由

    1. ip route add default via 192.168.1.1 dev enp1s0

    设置仓库

    添加Arch Linux中文社区驱动的非官方用户仓库。包含中文用户常用软件、工具、字体/美化包等。
    使用方法:在 /etc/pacman.conf 文件末尾添加以下两行:

    1. sudo vim /etc/pacman.conf
    1. [archlinuxcn]
    2. Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

    安装 archlinuxcn-keyring 包导入 GPG key。

    1. sudo pacman -Sy
    2. sudo pacman -S archlinuxcn-keyring

    软件安装

    基本工具

    1. pacman -S git base-devel

    oh my zsh

    1. pacman-S zsh
    2. sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    3. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    4. git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

    配置 ~/.zshrc

    1. plugins=(
    2. zsh-syntax-highlighting
    3. zsh-autosuggestions
    4. git
    5. extract
    6. autojump
    7. )

    WSL

    WSL是不支持Systemd的,但可以通过genie实现

    1. 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 }

  1. ```shell
  2. yay -S daemonize
  3. makepkg -si # 处理依赖并安装

参考