Skip to content

Commit

Permalink
docs: Add some tips on getting a rootfs
Browse files Browse the repository at this point in the history
#104 (review)
prompted me to try an experimentm it turns out conatiner runtimes
provide a super lightweight way to produce a rootfs.

Also provide a minimal example for mkosi.

This won't work without a user namespace so I guess we shouldn't merge
this until after #104 or something
simliar is in place.
  • Loading branch information
bjackman committed Dec 6, 2024
1 parent 92bc011 commit 1258e2f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ aarch64

For full configuration documentation, see [config.md](./docs/config.md).

For tips on getting a rootfs, see [rotfs.md](./docs/rootfs.md).

## Usage in Github CI

[vmtest-action](https://github.com/danobi/vmtest-action) is a convenient
Expand Down
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ The following fields are supported:
* UIDs from the host will be passed through directly; if you built your
rootfs without privileges in the host, try running `vmtest` via
`unshare -r`, so that QEMU (and hence the guest) sees UID 0.
* For tips on getting a rootfs, see [rotfs.md](rootfs.md).

* `arch` (string)
* Default: the architecture vmtest was built for.
* Under which machine architecture to run the kernel.
Expand Down
51 changes: 51 additions & 0 deletions docs/rootfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Getting a rootfs

There are many ways to produce a directory to pass to the `rootfs` config field,
here are a couple of potential solutions.

## From a container image

OCI images can be turned into tarballs which can be extracted into a rootfs. For
example:

```sh
❯❯ mkdir $rootfs_dir && cd $rootfs_dir
❯❯ cat > Containerfile
FROM docker.io/library/debian
RUN apt update
RUN apt install -y qemu-guest-agent

❯❯ podman build -t deb-qga # Docker would work exactly the same
❯❯ podman export -o deb.tar $(podman create deb-qga)
❯❯ tar xf deb.tar
❯❯ rm Containerfile deb.tar
```

## Using mkosi

[`mkosi`](https://github.com/systemd/mkosi) is a more advanced tool for building
OS images, as well as just producing a rootfs it can build full disk images with
a bootloader, plus many other features. You'll need to refer to the full
documentation to really understand `mkosi`, but here's a minimal example. This
will only work if you host system has `apt`, otherwise you'll need to adapt it
for your host distro or run it in a container.

`mkosi.conf`:

```ini
[Output]
Format=directory

[Distribution]
Distribution=debian
Release=testing

[Content]
Packages=
mount
qemu-guest-agent
```

Then from the directory containing that file, run `mkosi -f`. This should
produce a directory named `image` that you can use for your `rootfs` config
field.

0 comments on commit 1258e2f

Please sign in to comment.