Skip to main content
QEMU is the default and recommended way to run SerenityOS. The build system includes automated QEMU support for easy testing and development.

Prerequisites

QEMU 6.2 or later

Version 6.2 of QEMU is available in Ubuntu 22.04. On earlier versions of Ubuntu, you can build the recommended version of QEMU as provided by the toolchain.
1

Install QEMU dependencies

Install the required development packages:
2

Build QEMU from toolchain

If your distribution’s QEMU version is older than 6.2:

Running SerenityOS

The simplest way to build and run SerenityOS in QEMU:
This command will:
  • Compile all of SerenityOS
  • Install built files into Build/<architecture>/Root
  • Build a disk image
  • Start SerenityOS using QEMU
The chosen architecture defaults to your host architecture. Supported architectures are x86_64, aarch64, and riscv64.

First Build

The first time you run the build command, it will:
  • Download required database files from the internet
  • Build the SerenityOS cross-compiler toolchain
Subsequent builds will be much faster as these steps only need to be done once.

Default Credentials

By default, the anon user account’s password is: foo
The anon user can become root without a password by default as a development convenience. To prevent this, remove anon from the wheel group.

Build Options

Selecting an Architecture

Force a build for a specific architecture:
Supported values: x86_64, aarch64, riscv64

Build Only (No VM)

To test compilation without running the VM:

Kernel Command Line Parameters

Pass additional kernel parameters:

QEMU Integration Features

SPICE Integration

SPICE provides enhanced clipboard and display integration.
1

Build QEMU via toolchain

2

Install virt-viewer

On Ubuntu 23.04+:
For earlier versions, you may need to build virt-viewer 8.0 from source.
3

Enable SPICE and run

File Transfer from QEMU

Method 1: WebServer

Serenity has a built-in web server accessible from your host:
1

Start WebServer in SerenityOS

In the SerenityOS terminal:
2

Access from host browser

Open localhost:8000 in your host machine’s browser.
Some browsers download unrecognized files as plain text. Use wget to download files as-is instead.

Method 2: Mount the Disk Image

On *nix systems or inside WSL:

Method 3: Archiving Tool

Some archiving tools like 7-Zip can directly open ext2 images like Serenity’s _disk_image.
For WSL users: Access the WSL drive in Windows Explorer via \\wsl$\<distro name>\<path to serenity directory>.

Method 4: OpenSSH and SFTP

1

Setup OpenSSH server on host

Configure OpenSSH server on your host system (Windows or Linux).
2

Build OpenSSH port in SerenityOS

3

Connect via SFTP

From within SerenityOS:
Use commands like ls, cd, put [filename], get [filename], and quit.

Debugging

GDB Remote Session

Start SerenityOS with GDB attached:
This runs the image in QEMU and attaches a GDB session, setting a breakpoint at the init() function in the Kernel.

Self-Test Mode

Run the built image in self-test mode:
This passes system_mode=self-test to the Kernel.

Advanced Configuration

Custom QEMU Arguments

Set additional QEMU arguments:

Disk Image Types

Build different disk image formats:

Troubleshooting

Toolchain Outdated

If prompted to rebuild the toolchain after updates:

Filesystem Errors

If you see fusermount: failed to open /etc/mtab:

Performance on Windows

If using native Windows QEMU with WSL2, QEMU accesses the ext4 partition via 9P network share, which may be slower. Your WSL2 distro is accessible at \\wsl$\{distro-name}.
Consider copying Build/_disk_image and Build/Kernel/Kernel to a native Windows partition before running.