接触 Linux 二十多年了,一直是排斥 Gentoo Linux 和 Arch Linux 的,觉得前者编译太慢太浪费电力,后者连个官方安装程序都没有而且软件包质量太低。然而今天心血来潮,总算挑战两个发行版的安装成功,Gentoo Linux 的手册写的非常规范,安装过程除了编译慢,倒也没太大槽点,安装完基础系统后重启进入系统,占用内存 77MB,挺惊艳的。GentooGentoo-Portage 有清华 TUNA 镜像源,下载很快。

Arch Linux 则安装了两次,第一次失败了,看漏了 Installation_Guide 关于挂载 ESP 分区的文字,而且这份指南中关于网络配置和启动引导器配置指向了两个满满当当的 wiki 页面,其实需要的信息只有一点点,看的好不烦躁😓️

下面简单记录下在 VMware Fusion 中安装 Arch Linux 的流水帐,安装文件来自 https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/latest/ 下的 .iso 文件,虚拟机使用 UEFI 引导操作系统。

timedatectl set-ntp true

fdisk /dev/sda
# 按 g 选择 gpt 分区
# 按 n 创建 300M 分区,按 t 选择 EFI system partition 分区类型
# 按 n 创建 1G 分区,按 t 选择 Linux swap 分区类型
# 按 n 创建分区,按 t 选择 Linux root(x86-64) 分区类型
# 按 w 写出分区表

mkfs.ext4 /dev/sda3
mkswap /dev/sda2
mkfs.vfat /dev/sda1

mount /dev/sda3 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/sda2

cat >/etc/pacman.d/mirrorlist <<'EOF'
Server = https://opentuna.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
EOF

pacstrap /mnt base linux linux-firmware

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

arch-chroot /mnt

### >>>> 以下命令在 chroot 环境执行 >>>>
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc

sed -i -e 's/^#en_US.UTF-8/en_US.UTF-8/; s/^#en_US /en_US /; s/^#zh_CN.UTF-8/zh_CN.UTF-8/' /etc/locale.gen
locale-gen

echo 'LANG=en_US.UTF-8' >> /etc/locale.conf
echo 'LC_CTYPE=zh_CN.UTF-8' >> /etc/locale.conf

echo arch > /etc/hostname

cat >/etc/hosts <<EOF
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1       localhost
::1             localhost
127.0.1.1       arch
EOF

## 使用 systemd-networkd systemd-resolved
systemctl enable systemd-networkd systemd-resolved
cat >/etc/systemd/network/20-wired.network <<EOF
[Match]
Name=ens33

[Network]
DHCP=yes
EOF
ln -snf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

	## 使用 dhcpcd
	#pacman -S dhcpcd
	#systemctl enable dhcpcd

# 修改 root 账户密码
passwd

## 使用 GRUB
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

exit

# <<<< 以下两条命令在 liveCD 环境执行 <<<<
umount -R /mnt
reboot


### 重启后进入刚安装好的系统,创建第一个用户
useradd -m -G wheel,audio,video -s /bin/bash dieken
passwd dieken

### 安装一些软件包
pacman -S openssh sudo vim which man-db pacutils htop open-vm-tools
systemctl enable sshd vmtoolsd vmware-vmblock-fuse
systemctl restart sshd vmtoolsd vmware-vmblock-fuse

export EDITOR=vim
visudo   # 把 %wheel 两行中的「其中一行」去掉开头的 "# "


### 安装 yay 和 paru,以普通用户身份执行
sudo pacman -Sy --needed base-devel asp pkgfile go
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

mkdir ~/builds && cd ~/builds
git config --global url.https://github.com.cnpmjs.org/.insteadOf https://github.com/
git clone https://aur.tuna.tsinghua.edu.cn/yay.git
cd yay
makepkg -sirc
yay --aururl "https://aur.tuna.tsinghua.edu.cn" --save

# 加快 paru 安装速度
mkdir -p ~/.cargo
cat > ~/.cargo/config <<EOF
[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
EOF

yay paru
## 编辑 /etc/paru.conf,在 [options] 一节下面添加 AurUrl = https://aur.tuna.tsinghua.edu.cn/

sudo sed -i -e 's/^#BottomUp$/BottomUp/' /etc/paru.conf
sudo sed -i -e 's/^#Color$/Color/' /etc/pacman.conf

paru pbget
paru lf
paru downgrade

Pacman 常用命令:

  • pacman -S foo: 安装软件包
  • pacman -Scc: 清除软件包缓存
  • pacman -Ss foo: 搜索软件包
  • pacman -Sy: 更新软件包数据库

Arch Linux 的优点:

  1. pacman 软件包管理器设计简单,安装二进制软件包非常快速,PKGBUILD 文件方便编写;
  2. Arch Linux 对 FHS 以及软件包的文件布局改造很少,/etc目录几乎看不到 Arch 自定义的痕迹;
  3. Arch Linux 滚动更新,软件包版本非常新;
  4. Arch Linux 社区集中运作的 AUR 软件仓库,便于大家共享非官方软件包;

更多 VMWare 下安装 Arch Linux 的信息参考 https://wiki.archlinux.org/index.php/VMware/Install_Arch_Linux_as_a_guest


Gentoo 的一些重要文件:

/etc/portage/make.conf

# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C

FEAUTURES="${FEATURES} binpkg-request-signature"
EMERGE_DEFAULT_OPTS="--jobs 4 --load-average=3.6 --ask --quiet-build=y --keep-going --getbinpkg --binpkg-respect-use=y"
GENTOO_MIRRORS="https://mirrors.tuna.tsinghua.edu.cn/gentoo"
MAKEOPTS="-j4"
USE="elogind"

/etc/portage/package.license

sys-kernel/linux-firmware linux-fw-redistributable no-source-code
media-fonts/font-bh-ttf bh-luxi
media-fonts/font-bh-type1 bh-luxi

/etc/portage/repos.conf/gentoo.conf

[DEFAULT]
main-repo = gentoo

[gentoo]
location = /var/db/repos/gentoo
#sync-type = rsync
#sync-uri = rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-keyserver = hkps://keys.gentoo.org
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4
sync-webrsync-verify-signature = yes

sync-type = git
sync-uri = https://mirrors.tuna.tsinghua.edu.cn/git/gentoo-portage.git
sync-depth = 1
sync-git-verify-commit-signature = yes

/var/lib/portage/world

app-admin/eclean-kernel
app-admin/sudo
app-admin/sysklogd
app-editors/vim
app-emulation/open-vm-tools
app-eselect/eselect-repository
app-misc/neofetch
app-misc/ranger
app-portage/eix
app-portage/genlop
app-portage/gentoolkit
dev-vcs/git
net-misc/chrony
net-misc/dhcpcd
net-misc/netifrc
sys-apps/lsb-release
sys-apps/mlocate
sys-boot/grub:2
sys-fs/ncdu
sys-kernel/gentoo-kernel-bin
sys-kernel/installkernel-gentoo
sys-kernel/linux-firmware
sys-process/cronie
x11-base/xorg-x11
x11-drivers/xf86-video-vmware
x11-misc/dmenu
x11-misc/i3lock
x11-misc/i3status
x11-misc/slim
x11-misc/urxvt-font-size
x11-misc/urxvt-perls
x11-misc/urxvt-tabbedex
x11-misc/xss-lock
x11-terms/rxvt-unicode
x11-themes/slim-themes
x11-wm/i3-gaps

/etc/conf.d/xdm 中设置 DISPLAYMANAGER=“slim”,注意 slim, lightdm, lxdm 都不支持 non-root X,slim 也不支持 elogind。

重要服务:

rc-update add net.eno16777736 default       # /etc/init.d/net.eno16777736 -> net.lo
rc-update add sysklogd default
rc-update add cronie default
rc-update add sshd default
rc-update add chronyd default
rc-update add xdm default
rc-update add elogind boot
rc-update add dbus default
rc-update add vmware-tools default

升级 Gentoo:

sudo eix-sync                   # sudo emerge --sync && sudo eix-update && sudo eix-diff
sudo emerge -avuDN @world      # sudo emerge --ask --verbose --update --deep --newuse @world

参考: https://wiki.gentoo.org/wiki/Gentoo_Cheat_Sheet

Overlay 搜索: https://gpo.zugaina.org/


中文 Linux 论坛:

  1. 水木社区LinuxApp版: https://m.newsmth.net/board/LinuxApp
  2. Debian: https://forums.debiancn.org/
  3. Ubuntu: https://forum.ubuntu.com.cn/ https://forum.ubuntu.org.cn/ 两个是同一个站。
  4. Arch: https://bbs.archlinuxcn.org/
  5. Manjaro: https://manjaro.org.cn/bbs https://forum.manjaro.org/c/languages/70-category/70 后一个是官方的,人很少
  6. Gentoo: https://bbs.gentoocn.org 跳转到了 https://forums.gentoo.org/viewforum-f-50.html
  7. openSUSE: https://forum.suse.org.cn/
  8. Fedora: https://ask.fedoraproject.org/c/simplified-chinese/103
  9. Deepin: https://bbs.deepin.org/
  10. Redflag: http://www.linuxsir.cn/ (这个是2019年成立的,不知道和之前的中科红旗啥关系)