Redox OS: Build System Deployment and Usage Guide
This guide provides comprehensive instructions for deploying and using the Redox OS build system. Redox OS is an open-source operating system written in Rust, focusing on safety, efficiency, and performance.
1. Prerequisites
To build Redox OS, you will need a Linux-based system. The recommended way to build Redox is using podman or docker.
Software Requirements:
- Podman or Docker: For containerized builds.
- Git: For cloning the repository.
sudo apt install git(Debian/Ubuntu)sudo dnf install git(Fedora)
- Rust Toolchain (Optional, for host development): If you plan to contribute to the build system itself or other Rust components on your host machine.
- Install
rustup:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Ensure
cargois in your PATH.
- Install
Hardware Requirements:
- RAM: At least 8GB recommended.
- Disk Space: At least 50GB of free disk space for the build artifacts.
- CPU: A multi-core processor is highly recommended for faster build times.
2. Installation
The Redox OS build system is primarily designed to be run within a container.
-
Clone the Redox OS repository:
git clone https://gitlab.redox-os.org/redox-os/redox.git cd redox -
Initialize and Update Submodules: The Redox OS build system relies on various submodules for its components.
git submodule update --init --recursive
3. Configuration
The Redox build system uses environment variables and configuration within its build scripts. Most configuration is handled automatically by the cookbook utility within the container.
Key Configuration Concepts:
COOKBOOK_SYSROOT: This environment variable points to the sysroot of the Redox OS build. It's crucial for cross-compilation and dynamic linking.COOKBOOK_DYNAMIC: Set to1when building dynamically linked binaries.COOKBOOK_CONFIGURE_FLAGS,COOKBOOK_CMAKE_FLAGS,COOKBOOK_MESON_FLAGS: These arrays hold standard configuration flags for different build systems (Autotools, CMake, Meson) used by various packages within Redox. They are dynamically populated based on whether a dynamic or static build is performed (seeSHARED_PRESCRIPTinsrc/cook/script.rs).- Mirrors: The build system can use mirrors for fetching sources. This is configured internally via
translate_mirrorinsrc/config.rsandsrc/cook/fs.rs.
No manual configuration is typically required for a standard build. The build process handles these settings automatically.
4. Build & Run
The recommended way to build and run Redox OS is using the provided podman or docker scripts.
Build Redox OS
-
Build using Podman (Recommended):
./podman.shThis command will:
- Pull or build the necessary
redox-buildercontainer image. - Mount the Redox OS source directory into the container.
- Execute the build process inside the container.
- The build output will be located in the
build/directory.
- Pull or build the necessary
-
Build using Docker (Alternative):
./docker.shThis command performs the same actions as
./podman.shbut uses Docker instead.
Run Redox OS
After a successful build, a disk image will be created (e.g., build/harddrive.img). You can run this image in a virtual machine.
-
Run in QEMU (within the container):
./podman.sh qemuor
./docker.sh qemuThis will launch QEMU with the built Redox OS image.
-
Run in QEMU (manually on host): If you want to run QEMU directly on your host machine (assuming QEMU is installed), you can find the generated image and run it.
# After a successful build, the image is in build/harddrive.img qemu-system-x86_64 -drive file=build/harddrive.img,format=raw -m 4G -cpu host -smp 4 -vga std -display sdl(Adjust QEMU parameters as needed for your system and desired configuration.)
Development Workflow
For developing and testing individual packages within Redox, the cookbook utility is used. This is typically invoked within the builder container.
Example: Building a specific package (e.g., relibc)
# Enter the builder container (using podman as an example)
podman run -it --rm -v "$(pwd)":/redox redox-builder bash
# Inside the container, navigate to the redox directory
cd /redox
# Build a specific package (e.g., relibc)
./cookbook.sh relibc
5. Deployment
Redox OS is an operating system, not an application to be deployed on existing platforms. Deployment means running it on a virtual machine or real hardware.
Virtual Machine Deployment
As shown in the "Run Redox OS" section, you can run the generated harddrive.img in virtual machine software like QEMU, VirtualBox, or VMware.
- QEMU: The most common and supported method.
qemu-system-x86_64 -drive file=build/harddrive.img,format=raw -m 4G -cpu host -smp 4 -vga std -display sdl
- VirtualBox/VMware: Create a new virtual machine and attach
build/harddrive.imgas a raw disk image. Refer to your VM software's documentation for specific steps.
Real Hardware Deployment
Running Redox OS on real hardware is an advanced topic and requires careful consideration of hardware compatibility.
-
Check Hardware Compatibility: Refer to the Redox Book's Hardware Compatibility section.
-
Flash to USB Drive: You can flash the
build/harddrive.imgto a USB drive using tools likedd(use with extreme caution as incorrect usage can erase your system drive).# Identify your USB drive (e.g., /dev/sdX, BE VERY CAREFUL!) lsblk # Flash the image sudo dd if=build/harddrive.img of=/dev/sdX bs=4M status=progressReplace
/dev/sdXwith the correct device name for your USB drive.
6. Troubleshooting
Common Issues and Solutions
-
"Error: permission denied" when running
./podman.shor./docker.sh:- Ensure the scripts are executable:
chmod +x podman.sh docker.sh - Ensure your user has permissions to run
podmanordockercommands. You might need to add your user to thedockergroup (sudo usermod -aG docker $USER) and then log out and back in.
- Ensure the scripts are executable:
-
Build fails inside the container with "No space left on device":
- The build process requires significant disk space. Ensure your host machine has enough free space where the Redox repository is located and where Podman/Docker stores its images/volumes.
- Clean up old Docker/Podman images and containers:
docker system pruneorpodman system prune.
-
git submodule update --init --recursivefails or reports issues:- Check your internet connection.
- Ensure Git is correctly installed and configured.
- Try running
git submodule deinit -f .and thengit submodule update --init --recursiveagain.
-
podman.shordocker.shfails to pull theredox-builderimage:- Verify your internet connection.
- Check if the container registry is accessible.
- Ensure Podman/Docker is correctly configured and running.
-
QEMU fails to start or shows a black screen:
- Ensure the build process completed successfully and
build/harddrive.imgexists and is not empty. - Check QEMU installation and its dependencies on your host system.
- Try different QEMU parameters (e.g.,
-vga std,-vga cirrus). - Increase allocated RAM (
-m).
- Ensure the build process completed successfully and
-
Build takes a very long time:
- Redox OS is a full operating system; a complete build can take several hours, especially on less powerful hardware.
- Ensure your system meets the recommended hardware requirements.
- Ensure you have enough CPU cores allocated to the container (Podman/Docker typically uses all available by default, but check your configuration).
-
Specific package build failure:
- The build logs inside the container will provide details. Look for error messages related to
cargo,make,cmake, ormeson. - If you're modifying a package, ensure your changes are compatible with the Redox environment and its toolchain.
- Consult the Redox Chat and Support for assistance with specific build errors.
- The build logs inside the container will provide details. Look for error messages related to