For the complete documentation index, see llms.txt. This page is also available as Markdown.

18.6 Gentoo Linux Compatibility Layer

The Gentoo compatibility layer builds the base system through a stage3 tarball; the Linux kernel module must be enabled before building. This section provides a complete script from daemon configuration to base system completion.

Building the Base System

Before building the Gentoo Linux compatibility layer, you need to enable the core daemons.

Daemons

# service linux enable       # Set the Linux kernel module to start on boot
# service linux start        # Start the Linux kernel module
# service dbus enable        # Set the dbus service to start on boot (usually already configured by the desktop environment)
# service dbus start         # Start the dbus service (usually already configured by the desktop environment)

Obtaining the Base System Image

Download the Gentoo Stage3 image:

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

The above link will change with version updates; please obtain the latest link yourself.

Create the Gentoo compatibility layer directory:

# mkdir -p /compat/gentoo

Extract the Gentoo image to the compatibility layer directory:

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

Mounting File Systems

After building, you must mount the necessary file systems. Point the Linux compatibility layer default path to /compat/gentoo to enable automatic mounting of the relevant file systems.

Take effect immediately:

Permanent setting:

Restart the Linux compatibility layer service:

Project structure:

Editing Gentoo Configuration Files

Edit the /compat/gentoo/etc/portage/make.conf file and add:

Basic configuration:

Modifying Gentoo Software Sources

On FreeBSD, edit the /compat/gentoo/etc/portage/repos.conf/gentoo.conf file and modify the Gentoo repository configuration: change sync-uri = rsync://rsync.gentoo.org/gentoo-portage to sync-uri = rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage.

Enter the Gentoo compatibility layer environment using Bash as the shell:

Use Gentoo's webrsync tool to synchronize the Portage tree:

Testing

Use Gentoo Portage to install the fastfetch tool and display detailed output:

You can run fastfetch directly from the FreeBSD command line:

The output is as follows:

Gentoo Compatibility Layer

Shell Script

The script content:

Last updated