13.6 Gentoo Linux 兼容层

Gentoo 兼容层通过 stage3 tarball 构建基本系统,构建前需启用 linux 内核模块。本节给出从守护进程配置到基本系统完成的完整脚本。

构建基本系统

构建 Gentoo Linux 兼容层前需启用核心守护进程。

守护进程

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

获取基本系统镜像

下载 Gentoo Stage3 镜像:

# fetch https://mirrors.ustc.edu.cn/gentoo/releases/amd64/autobuilds/20230101T164658Z/stage3-amd64-llvm-openrc-20230101T164658Z.tar.xz

上述链接会随版本更新,请自行获取最新链接。

创建 Gentoo 兼容层目录:

# mkdir -p /compat/gentoo

将 Gentoo 镜像解压到兼容层目录:

# tar xpvf stage3-amd64-llvm-openrc-20230101T164658Z.tar.xz -C /compat/gentoo --numeric-owner

挂载文件系统

构建完成后,须挂载必要的文件系统。将 Linux 兼容层默认路径指向 /compat/gentoo 以实现相关文件系统的自动挂载。

立即生效:

永久设置:

重启 Linux 兼容层服务:

项目结构:

编辑 Gentoo 配置文件

编辑 /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 树:

测试使用

使用 Gentoo Portage 安装 fastfetch 工具,并显示详细输出:

可以直接在 FreeBSD 命令行运行 fastfetch

输出如下:

Gentoo 兼容层

shell 脚本

脚本内容:

最后更新于