21.7 Gentoo Linux 兼容层

构建基本系统

守护进程

# service linux enable       # 设置 Linux 内核模块开机自启
# service linux start        # 启动 Linux 内核模块
# service dbus enable        # 设置 dbus 服务开机自启(一般桌面环境已配置)
# service dbus start         # 启动 dbus 服务(一般桌面环境已配置)

获取基本系统镜像

# wget https://mirrors.ustc.edu.cn/gentoo/releases/amd64/autobuilds/20230101T164658Z/stage3-amd64-systemd-20230101T164658Z.tar.xz  # 下载 Gentoo Stage3 镜像,链接会随版本更新,请读者自行查找最新链接
# mkdir -p /compat/gentoo        # 创建 Gentoo 兼容层目录
# tar xpvf stage3-amd64-systemd-20230101T164658Z.tar.xz -C /compat/gentoo --numeric-owner  # 将 Gentoo 镜像解压到兼容层目录

fstab 文件

编辑 /etc/fstab,加入:

# Device        Mountpoint              FStype          Options                      Dump    Pass#
devfs           /compat/gentoo/dev      devfs           rw,late                      0       0
tmpfs           /compat/gentoo/dev/shm  tmpfs           rw,late,size=1g,mode=1777    0       0
fdescfs         /compat/gentoo/dev/fd   fdescfs         rw,late,linrdlnk             0       0
linprocfs       /compat/gentoo/proc     linprocfs       rw,late                      0       0
linsysfs        /compat/gentoo/sys      linsysfs        rw,late                      0       0
/tmp            /compat/gentoo/tmp      nullfs          rw,late                      0       0
#/home           /compat/gentoo/home     nullfs          rw,late                      0       0

挂载 /etc/fstab 中定义的所有文件系统:

编辑 /compat/gentoo/etc/portage/make.conf 文件,加入:

进行常见配置:

Gentoo 换源

在 FreeBSD 下,编辑 /compat/gentoo/etc/portage/repos.conf/gentoo.conf 文件,修改 Gentoo 仓库配置文件:将 sync-uri = rsync://rsync.gentoo.org/gentoo-portage 修改为 sync-uri = rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage

进入 Gentoo 兼容层环境,使用 Bash 作为 shell:

使用 Gentoo 的 webrsync 工具同步 Portage 树:

测试使用

测试安装 screenfetch:

可以正常安装软件。

在 Gentoo 环境中运行 screenfetch 命令,显示系统信息:

Shell 脚本

脚本内容:

最后更新于

这有帮助吗?